I’m trying to load the helmet GLTF and replace each Mesh with its “thick” Wireframe equivalent but I end up with an unexpected 90 degree pitch in the end.
I traverse the node tree twice. On the first pass I run updateWorldMatrix() on each node, then create a new Wireframe node for each Mesh node I find and copy the Mesh.matrixWorld into the new Wireframe.matrixWorld. I don’t make any changes to the node tree on the first pass; the new Wireframe nodes and other bookkeeping data go into a temporary map structure.
On the second traversal pass, I assign each of the new Wireframe nodes to their proper parents in the node tree using parent.attach().
Finally, I iterate through the temporary map to delete the original Mesh nodes from the node tree.
The parent.attach() call seems to be squashing the rotations and I don’t know what I’m missing. What is the proper procedure to give a node a world rotation and then attach it to another node so that it calculates a valid local reference frame?
Before you go, let me play you something on my fiddle: Wireframe#3 - JSFiddle - Code Playground