How to get the root node of any picked child mesh

I’ve been scratching my head to get this to work.

I’ve tried to use .parent as a way to go up the node chain but I cant find a way to test if a given node is a root node.

See for below a replication

hi @avrdev21 welcome to the forum. You need to continue up the hierarchy until you find a node that does not have a parent:

if (pickResult.hit) {
  let mesh = pickResult.pickedMesh;
  while (mesh.parent !== null) {
    mesh = mesh.parent;
  //Print node name
1 Like

oh my, I didn’t think of that. Thank you very much for your quick response. I look forward to helping out in the forum.

1 Like