Skip to content

Commit dd409b3

Browse files
committed
feat: fix selection logic
1 parent 3c14f91 commit dd409b3

1 file changed

Lines changed: 3 additions & 24 deletions

File tree

  • packages/@dcl/inspector/src/lib/babylon/decentraland

packages/@dcl/inspector/src/lib/babylon/decentraland/EcsEntity.ts

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -264,17 +264,12 @@ function updateMeshBoundingBoxVisibility(entity: EcsEntity, mesh: BABYLON.Abstra
264264
const isParentSelected = hasSelectedParent(entity, context)
265265
const children = entity.gltfContainer ? entity.gltfContainer.getChildMeshes(false) : entity.getChildMeshes(true)
266266

267-
const shouldShowBoundingBox =
268-
(isSelected && isEntityOutsideLayout(mesh)) || (isEntityOutsideLayout(mesh) && isParentSelected)
267+
const shouldShowBoundingBox = (isSelected || isParentSelected) && isEntityOutsideLayout(mesh)
269268

270269
if (shouldShowBoundingBox) {
271-
if (!mesh.showBoundingBox) {
272-
mesh.showBoundingBox = true
273-
}
270+
mesh.showBoundingBox = true
274271
} else {
275-
if (mesh.showBoundingBox) {
276-
mesh.showBoundingBox = false
277-
}
272+
mesh.showBoundingBox = false
278273
}
279274

280275
if (isEntityOutsideLayout(mesh)) {
@@ -301,22 +296,6 @@ function hasSelectedParent(entity: EcsEntity, context: any): boolean {
301296
return false
302297
}
303298

304-
function hasChildrenOutsideLayout(
305-
entity: EcsEntity,
306-
isEntityOutsideLayout: (mesh: BABYLON.AbstractMesh) => boolean
307-
): boolean {
308-
for (const child of entity.childrenEntities()) {
309-
if (child.boundingInfoMesh && isEntityOutsideLayout(child.boundingInfoMesh)) {
310-
return true
311-
}
312-
// Verificar recursivamente los hijos de los hijos
313-
if (hasChildrenOutsideLayout(child, isEntityOutsideLayout)) {
314-
return true
315-
}
316-
}
317-
return false
318-
}
319-
320299
function addOutsideLayoutMaterial(mesh: BABYLON.AbstractMesh, scene: BABYLON.Scene) {
321300
if (!(mesh.material instanceof BABYLON.MultiMaterial)) {
322301
const multiMaterial = new BABYLON.MultiMaterial(`entity_outside_layout_multimaterial`, scene)

0 commit comments

Comments
 (0)