From be4af8cdada96f364178b0ae932e906d4b94ac02 Mon Sep 17 00:00:00 2001 From: valentinMachado Date: Mon, 28 Aug 2023 14:03:09 +0200 Subject: [PATCH] clean(Widget) C3DTiles widget clean --- packages/browser/src/Widget/C3DTiles.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/browser/src/Widget/C3DTiles.js b/packages/browser/src/Widget/C3DTiles.js index 2fac8ab96..dec620f65 100644 --- a/packages/browser/src/Widget/C3DTiles.js +++ b/packages/browser/src/Widget/C3DTiles.js @@ -21,11 +21,10 @@ export class C3DTiles extends itownsWidget.Widget { constructor(view, options) { super(view, options, DEFAULT_OPTIONS); - /** @type {itowns.PlanarView} */ - this.view = view; - /** @type {THREE.Box3Helper} */ this.displayedBBFeature = new THREE.Box3Helper(new THREE.Box3()); + this.displayedBBFeature.visible = false; + view.scene.add(this.displayedBBFeature); // cant click through the widget this.domElement.onclick = (event) => event.stopImmediatePropagation(); @@ -138,9 +137,7 @@ export class C3DTiles extends itownsWidget.Widget { while (this.c3DTFeatureInfoContainer.firstChild) this.c3DTFeatureInfoContainer.firstChild.remove(); - if (this.displayedBBFeature.parent) - this.displayedBBFeature.parent.remove(this.displayedBBFeature); - + this.displayedBBFeature.visible = !!c3DTFeature; this.c3DTFeatureInfoContainer.hidden = !c3DTFeature; if (!c3DTFeature) return; @@ -178,8 +175,6 @@ export class C3DTiles extends itownsWidget.Widget { layer.computeWorldBox3(c3DTFeature, this.displayedBBFeature.box); this.displayedBBFeature.updateMatrixWorld(); - this.view.scene.add(this.displayedBBFeature); - // feature info this.c3DTFeatureInfoContainer.appendChild( createObjectDomElement(