From 0530a03428ca3aa82550fdcc85482ea6f0f5a239 Mon Sep 17 00:00:00 2001 From: ethan Date: Fri, 15 Mar 2024 17:08:04 +0800 Subject: [PATCH] Fix the issue where polygons and triangles cannot delete their outer edges when removed. --- src/arrow/attack-arrow.ts | 2 -- src/arrow/double-arrow.ts | 2 -- src/base.ts | 6 ++++++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/arrow/attack-arrow.ts b/src/arrow/attack-arrow.ts index a327698..7ca1b5a 100644 --- a/src/arrow/attack-arrow.ts +++ b/src/arrow/attack-arrow.ts @@ -38,8 +38,6 @@ export default class AttackArrow extends Base { } else if (this.points.length === 2) { this.setGeometryPoints(this.points); this.drawPolygon(); - } else { - this.lineEntity && this.viewer.entities.remove(this.lineEntity); } } diff --git a/src/arrow/double-arrow.ts b/src/arrow/double-arrow.ts index c569a37..e5d6d85 100644 --- a/src/arrow/double-arrow.ts +++ b/src/arrow/double-arrow.ts @@ -42,8 +42,6 @@ export default class DoubleArrow extends Base { } else if (this.points.length === 2) { this.setGeometryPoints(this.points); this.drawPolygon(); - } else if (this.points.length === 3) { - this.lineEntity && this.viewer.entities.remove(this.lineEntity); } else { this.finishDrawing(); } diff --git a/src/base.ts b/src/base.ts index 7d2a3a1..b2f6dbb 100644 --- a/src/base.ts +++ b/src/base.ts @@ -459,6 +459,7 @@ export default class Base { this.polygonEntity.show = true; this.outlineEntity.polyline.clampToGround = true; this.outlineEntity.show = true; + this.lineEntity && (this.lineEntity.show = true); } else if (this.type === 'line') { this.lineEntity.polyline.clampToGround = true; this.lineEntity.show = true; @@ -470,6 +471,7 @@ export default class Base { this.polygonEntity.show = false; this.outlineEntity.polyline.clampToGround = false; this.outlineEntity.show = false; + this.lineEntity && (this.lineEntity.show = false); } else if (this.type === 'line') { this.lineEntity.polyline.clampToGround = false; this.lineEntity.show = false; @@ -480,6 +482,10 @@ export default class Base { if (this.type === 'polygon') { this.viewer.entities.remove(this.polygonEntity); this.viewer.entities.remove(this.outlineEntity); + this.lineEntity && this.viewer.entities.remove(this.lineEntity); + this.polygonEntity = null; + this.outlineEntity = null; + this.lineEntity = null; } else if (this.type === 'line') { this.viewer.entities.remove(this.lineEntity); }