Skip to content

GLTFLoader: Non-deterministic order of children #25201

Closed
@epreston

Description

@epreston

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

  1. load a model with GLTFLoader on r147 with 2 children, mesh and bones
  2. assign mesh and skeleton using the predictable indexes of the children, in this case 0 = mesh, 1 = skeleton
  3. confirm working correctly
  4. upgrade to r148 and load the same object using the updated GLTFLoader
  5. note skeleton is now index 0, mesh is index 1 in the children array
  6. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions