Closed
Description
Description
Recent changes to GLTFLoader no longer loads child objects in an predictable order.
Object hierarchies from GLB files have loaded in predictable order for a few versions. That is no longer the case.
We now need to interrogate the properties of each sub object in an array to correctly assign meshes and bones. Not sure if this should have been the case and I have been relying on undocumented behaviour by assuming consistent indexes and ordering of components in arrays.
Recent optimisations in loading are great but I've lost more cycles interrogating each node in the hierarchy than I've saved.
Reproduction steps
- load a model with GLTFLoader on r147 with 2 children, mesh and bones
- assign mesh and skeleton using the predictable indexes of the children, in this case 0 = mesh, 1 = skeleton
- confirm working correctly
- upgrade to r148 and load the same object using the updated GLTFLoader
- note skeleton is now index 0, mesh is index 1 in the children array
- assign the wrong objects to the wrong values, embrace sadness
Code
// issue
this.armature = {'some object loaded with r148'}
this.mesh = this.armature.children[1]; // indexes are no longer predictable could be 1 or 0
this.skeleton = this.armature.children[0]; // its a 50/50 guess now
// fix
this.mesh = expensiveTraversalAndChecksForMesh(this.armature.children);
this.skeleton = expensiveTraversalAndChecksForSkeleton(this.armature.children);
Live example
- i don't have a live example
Screenshots
No response
Version
r148
Device
Desktop
Browser
Chrome
OS
Windows