[Closed] Multiple parents in scenegraph



More notes on how Three seems to render the scene graph, roughly.

The traversal happens in the renderer, WebGLRenderer.

First, a renderlist is constructed in projectObject. It contains a flat list of renderables constructed from traversing the scene from top to bottom.

Then, the renderlist is rendered in sequence in renderObjects(), renderObject(), renderBufferDirect()

The modelViewMatrix() is computed and stored per object or mesh, as well as the world transform of the object.

So for multi-parenting this is where either cloning would be necessary, probably when constructing the renderlist. Or, there could be a separation, by introducing a renderObject which references the mesh and world related matrices separately:

renderObject.object = object;
renderObject.worldMatrix.mult(object.localMatrix, parent.worldMatrix);

renderObject() then would take renderObject rather than object

Of course, there are likely many other properties (needMatrixUpdate or so) and events(onbeforerender) which are tied to object safely assuming it occurs only once in the renderlist.

Well, I have a better appreciation now of how three works at the scene graph level. It looks like cloning and keeping track of clones perhaps via Proxys would be necessary to simulate multi-parenting.