getChildren() returns empty array when in fact there are objects in _children

I have a mesh m parented to a transformNode t1 parented to another transform node t0.

The mesh displays fine, when I console.dir(t0) in chromeconsole I see t0 and t1 and even m under the _children attribute of t1, yet that line:


returns an empty array, even though the console clearly shows that _children attribute of t1 contains the mesh m?

Any obvious reason?

Finally doing:

t0.getChildMeshes(false); //returns an empty array
t0.getChildren()[0].getChildMeshes(false); //also return an empty array 

on t0 (first line) only would return meshes that are direct children of t0 as if the false attribute did not apply when dealing with TransformNodes in the hierarchy?

I just want to compute a bounding box that is the sum of all the nodes BB regardless of whether those nodes are transformNodes or Meshes, but because of the above behavior that is turning out to be much more complicated than I anticipated (I am coding with TS by the way).

  • Is the solution to drop the TranformNode for empty Mesh instead?
  • Or is there a more elegant way to get all of the meshes in the nodes hierarchy as one array despite using TransformNodes at various levels of the hierarchy?

(the example above to state the problem is a simplified example as I in fact need to deal with multiple layers of nested transformNodes and Meshes)

Could you reproduce the behavior in a TS PG? This will make it easier to track the issue.

1 Like

It does work for me: