diff --git a/packages/@dcl/inspector/src/lib/babylon/decentraland/EcsEntity.ts b/packages/@dcl/inspector/src/lib/babylon/decentraland/EcsEntity.ts index ab3c9c82c..fde33081e 100644 --- a/packages/@dcl/inspector/src/lib/babylon/decentraland/EcsEntity.ts +++ b/packages/@dcl/inspector/src/lib/babylon/decentraland/EcsEntity.ts @@ -173,7 +173,9 @@ export class EcsEntity extends BABYLON.TransformNode { const meshesBoundingBox = this.getMeshesBoundingBox() this.boundingInfoMesh = new BABYLON.Mesh(`BoundingMesh-${this.id}`) - this.boundingInfoMesh.parent = this + this.boundingInfoMesh.position = this.absolutePosition + this.boundingInfoMesh.rotationQuaternion = this.absoluteRotationQuaternion + this.boundingInfoMesh.scaling = this.absoluteScaling this.boundingInfoMesh.setBoundingInfo( new BABYLON.BoundingInfo(meshesBoundingBox.minimum, meshesBoundingBox.maximum, this.getWorldMatrix()) @@ -186,6 +188,15 @@ export class EcsEntity extends BABYLON.TransformNode { this.onAfterWorldMatrixUpdateObservable.addOnce((eventData) => { void validateEntityIsOutsideLayout(eventData as EcsEntity) }) + + // Updates the boundingInfoMesh position, rotation and scaling + this.onAfterWorldMatrixUpdateObservable.add((eventData) => { + if (this.boundingInfoMesh) { + this.boundingInfoMesh.position = eventData.absolutePosition + this.boundingInfoMesh.rotationQuaternion = eventData.absoluteRotationQuaternion + this.boundingInfoMesh.scaling = eventData.absoluteScaling + } + }) } } }