Skip to content
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

app.root is not the root entity in a Scene #162

Closed
willeastcott opened this issue Feb 18, 2015 · 6 comments
Closed

app.root is not the root entity in a Scene #162

willeastcott opened this issue Feb 18, 2015 · 6 comments
Labels
area: graphics Graphics related issue feature request

Comments

@willeastcott
Copy link
Contributor

It's natural for a developer to assume that the root entity in the hierarchy in the editor is what is returned by app.root. Currently, this is not the case. Instead, there is actually a 'phantom' parent to the hierarchy's root that is not visible to the user.

Moreover, app.root should become app.scene.root. I think that makes more sense. We can maintain the old root property but just leave it undocumented.

@daredevildave
Copy link
Contributor

Currently app.root and app.scene.root are different.

It is possible to load multiple scene hierarchies into the application. Each one gets added to app.root

  • root
    • scene 1 root
    • scene 2 root

I concede that it is natural to assume app.root is the root of the scene, but only if you are working with a single scene. My feeling is this should remain as is.

@WarWithinMe
Copy link
Contributor

However, application.render() will try to render the default scene for all cameras, which defeats the purpose of multiple scenes.

I think it's good to support multiple scenes, but app.root shouldn't be a generic Entity object. Instead, app.root should be a specific type of object ( might be AppRoot? ) that its children can only be Scene object ( not the scene.root object ).
Then it would be very clear that

   var scene1 = new pc.Scene();
   var scene2 = new pc.Scene();

   app.root.scenes = [ scene1, scene2 ];
   // or
   app.scenes = [ scene1, scene2 ];  // which remove app.root entirely and more compact

   scene1.root.addChild( cameraEntity1 );
   scene2.root.addChild( cameraEntity2 ); // In current version of PlayCanvas, a camera can be add to app.root !

Notice that the Scene is not subclass of Entity, thus its parent ( a.k.a app.root ) should not be subclass of Entity too.

@Maksims
Copy link
Contributor

Maksims commented Dec 22, 2015

Most common use of app root, is easy way to find entity by name in script components. Do users write: app.root.findByName("foo"); which is very easy to remember. Introducing scenes interface how that will look like?
I think personally, that scene should.be always represented by its root node. And app.root should point to root node of running scene. All scenes that leaded on demand, are added as child to other nodes, usually to root of pimary scene. This is rather simple, and does not introduces new abstraction on the way of hierarchy, and eliminates weird root node.

@WarWithinMe
Copy link
Contributor

@Maksims Your idea totally makes sense. The only problem left might be "Is multiple running scenes necessary?" I actually don't think of practical use cases for multiple scenes ( perhaps it's because I'm relatively new to 3D development ).

@willeastcott willeastcott added the area: graphics Graphics related issue label Apr 15, 2020
@mvaligursky
Copy link
Contributor

I'd vote for this to be closed as Won't Do. Any objections @willeastcott ?

@willeastcott
Copy link
Contributor Author

No, it's fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue feature request
6 participants