GLTFLoader: Clone node associations.#31051
Conversation
What are the consequences of this? Does that means certain glTF asset can't be loaded properly? If so, can you share one so it's possible to reproduce the issue? |
|
GLTF assets will load properly, but the object returned by I need a way to reference an arbitrary point in the GLTF model with animations, so I can compute where it is positioned at each animation frame. The point can be uniquely specified by the following:
Node and primitive indices should suffice to uniquely determine the generated three.js mesh, from which further computations can be done. But since the |
donmccurdy
left a comment
There was a problem hiding this comment.
Let's go ahead with this, it sounds like a worthwhile fix to me.
I have been somewhat regretting the complexity of how GLTFLoader unpacks the scene and manages associations – this is a maintenance challenge but I don't have free personal time to work on it, which would need some careful testing. For the changes in output that we probably need to make eventually, see:
Description
GLTFLoader doesn't correctly assign the
nodesassociation when multiplenodes reference the same mesh. The problem occurs in
_loadNodeShallowwhere
nodesproperty is added to the shared object describing the node/meshassociation.
For example, in the CesiumMilkTruck model nodes 0 (Wheels) and 2 (Wheels.001)
reference the same mesh 0, but resulting associations for both three.js meshes are
{meshes: 0, primitives: 0, nodes: 2}.A simple solution is to clone the association object if there are multiple references to
the same mesh.