Entities, graphNodes and models

I’m trying to understand the relationship between these three things. I have a box primitive in my scene. I look at in the console and see that it is an Entity. It has a model property (my box mesh, essentially). That model property has a graphNode property. All this makes sense to me.

But I know that you can reparent a graphNode onto some other node. What would that do exactly? Would the model somehow get reparented too, even though it appears to be the parent of the graphNode?

Hi @Michael_McCrickard,

So those two classes of objects are related, pc.Entity inherits from pc.GraphNode. They can be both used as the translation node for a mesh instance (that is the parts of a model rendered in space).

The difference is pc.GraphNode has limited functionality apart from holding and doing translations in world and local space. pc.Entity can hold in addition components that great expand its purpose in a scene.

Right now in the editor hierarchy only pc.Entity objects are being shown. You can ofcourse reparent a pc.GraphNode, much like you would do with an entity. Then that model will follow the translation of its parent in world space.

That’s a common trick when attaching objects to an animated model, we add the items as children to the nodes of the animation bones.

Hope I’ve been of help!

1 Like

So you can re-parent entities as well as graphNodes? Can you clone nodes like you can entities?

Yes, you can, you can check all the available pc.GraphNode methods here:

https://developer.playcanvas.com/en/api/pc.GraphNode.html

Interesting, clone() is not mentioned on that page. But it does appear to be working for me.

You are correct, it’s available in the engine source code, @yaustar any idea why it’s not documented? Is it considered private API?

I don’t have an answer for that one :sweat_smile: Maybe it was always consider that people would be using pc.Entity than pc.GraphNode directly.

2 Likes