Skip to content

Commit

Permalink
feature(Widget) C3DTiles widget display bounding box
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinMachado committed Sep 12, 2023
1 parent fe55960 commit 21da06d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion packages/browser/src/Widget/C3DTiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ 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());

// cant click through the widget
this.domElement.onclick = (event) => event.stopImmediatePropagation();

Expand Down Expand Up @@ -132,6 +138,9 @@ 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.c3DTFeatureInfoContainer.hidden = !c3DTFeature;

if (!c3DTFeature) return;
Expand Down Expand Up @@ -166,9 +175,20 @@ export class C3DTiles extends itownsWidget.Widget {
labelLayerDomElement.innerText = layer.name;
this.c3DTFeatureInfoContainer.appendChild(labelLayerDomElement);

layer.computeWorldBox3(c3DTFeature, this.displayedBBFeature.box);
this.displayedBBFeature.updateMatrixWorld();

this.view.scene.add(this.displayedBBFeature);

// feature info
this.c3DTFeatureInfoContainer.appendChild(
createObjectDomElement(c3DTFeature.getInfo(), 'Feature info')
createObjectDomElement(
{
info: c3DTFeature.getInfo(),
boundingBox: this.displayedBBFeature.box,
},
'Feature'
)
);
}
}

0 comments on commit 21da06d

Please sign in to comment.