Jump to content

node.getDescendants(), Find by name Inefficiency


Srisub
 Share

Recommended Posts

I am busy porting over an app from THREE.js over to Babylon.js, but am finding some surprising inefficiency and holes, that can easily be addressed i believe..

1. In THREE.js, i was able to simple say: item.findNodeByName( "Foo" ) - and it would do the right thing whether it was a scene or a node. I saw the latest code for getDescendants(). Thanks for adding the directChildrenOnly flag and the predicate, which i used in this case. I wrote a wrapper to mimic THREE, by doing scene.findMeshByName or node.getDescendants(false, predicate-check-for-name)

2. Secondly the code for getMeshByName, as well as getDescendants does a full-scan on ALL objects in the scene. Is that efficient. Wouldnt a recursive traversal of a children field in a node be necessary for efficiency?

 

Link to comment
Share on other sites

Hello!

1. We support scene.getNodeByName. Did you see it?

2. The full scan is required because a node does NOT have a list of children. We could think about adding it but then we need to handle .parent with a property in order to maintain the children list. I'm not opposed to it (just need to handle correctly dispose on children). I'll give a try to improve this

Link to comment
Share on other sites

@Deltakosh  Maybe you could use the new descandents handling to speed up AbstractMesh.dispose() because it also scans the full scene for child meshes.

here: https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.abstractMesh.ts#L1115
and here:  https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.abstractMesh.ts#L1122
 

Link to comment
Share on other sites

  • 3 weeks later...

So... until this change goes into production, I need to maintain instances of my "children"? It seems that JavaScript is garbage collecting them otherwise, but I could be wrong.

Do you set m.parent = s, where m is my mesh, and s is my scene? If so, that doesn't work, or I don't have the most up to date package.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...