You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* fix: avoid removing nested entities when loading a gltf
* fix: spinner position if entity is nested
* chore: fix test
* fix: get entity absolute position
Copy file name to clipboardExpand all lines: packages/@dcl/inspector/src/lib/babylon/decentraland/sdkComponents/gltf-container.ts
+9-3Lines changed: 9 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -137,9 +137,15 @@ async function tryLoadGltfAsync(sceneId: string, entity: EcsEntity, filePath: st
137
137
(assetContainer)=>{
138
138
processGLTFAssetContainer(assetContainer)
139
139
140
-
// remove old entities
140
+
/*
141
+
The purpose of this is to solve the following issue:
142
+
When the scene is reloaded, the gltfs are loaded from two places, a useEffect in the Renderer.tsx component, and the CRDT messages coming from the engine.
143
+
That could cause GLTFs from being loaded twice in the babylon engine, so in order to avoid that, the loop below empties the entity from any previous GLTF loaded, so if it was loaded twice, the second time would clear the first load and it wouldn't end up duplicated.
144
+
The problem with that approach is that it would also remove any other entity that was nested onto the parent, and this would mess up the entity tree when the scene is loaded for the first time, that's why the loop needs to skip any node that is an EcsEntity, so it doesn't remove the entity from the tree.
145
+
*/
141
146
constprevChildren=entity.getChildren()
142
147
for(constchildofprevChildren){
148
+
if(childinstanceofEcsEntity)continue// skip EcsEntity nodes, only remove gltf related stuff
143
149
child.setEnabled(false)
144
150
child.dispose(false,true)
145
151
}
@@ -387,12 +393,12 @@ function createLoadingSpinner(
0 commit comments