New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add directly constructed Nodes to rootNodes #15089
Conversation
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://babylonsnapshots.z22.web.core.windows.net/refs/pull/15089/merge/index.html#WGZLGJ#4600 Links to test babylon tools with this snapshot: https://playground.babylonjs.com/?snapshot=refs/pull/15089/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/15089/merge#BCU1XR#0 |
Visualization tests for WebGPU (Experimental) |
WebGL2 visualization test reporter: |
As you say, this exists extensively in the framework. I like this solution more than the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both work for me.
Ok, it sounds like overall their is a slight preference for the |
This is in response to this forum post: https://forum.babylonjs.com/t/root-node-not-shown-in-inspector-but-transformnodes-are/50432
When a
Node
is created directly (not a subclass ofNode
), it does not get added to therootNodes
of theScene
. However, if you set theparent
on thatNode
and then set it back tonull
, then it does get added torootNodes
. From what I can tell, this is just wrong behavior and is a bug. My proposed fix is to add an optional parameter to theNode
constructor that controls whether it gets added to therootNodes
. This is the same pattern that already existed for the same purpose withTransformNode
and it's derived classes (e.g.AbstratMesh
). That said, I personally don't love this pattern because as far as I can tell theisPure
idea is meant to be an implementation detail to deal with the subclassing, but is publicly exposed (I know there is already a lot of this across the API). An alternative would be to just add this to theNode
constructor and not change any of the subclasses:This would just be saying "if a
Node
is directly constructed, add it to the scene's rootNodes, otherwise it must be a subclass, and the subclass is responsible for deciding how to add it to the rootNodes." Thoughts @deltakosh or anyone else?