Why this.entity.model.model.graph and not this.entity.model.graph

Why is the entity’s model root graphNode is located in
and not

Would like the rationale of this…

this.entity.model is the model component the ‘raw’ data about the model is stored in the object variable model of the component. It is not the best naming scheme but its a bit difficult to change it now.

1 Like

This is a characteristic of the engine I’m not too happy with. To be honest, the graph of a model should just be child entities of the entity with the model component.

The original rationale was that the engine has three layers:

  1. The graphics layer: This defines a low level abstraction of WebGL defining things like shaders, textures, vertex buffers and so on.
  2. The scene layer: This defines higher level constructs for building 3D scenes, defining things like materials, lights, cameras, models, scenes.
  3. The framework layer: This defines a high level application framework for creating and managing applications, defining things like applications, entities, components and so on.

You were supposed to be able to use just layer 1, or layer 1 + layer 2, or layer 1 + layer 2 + layer 3.

These days, the separation is way less important, because, to be honest, you’d be crazy not to use all 3 layers. But the split is still quite nice for keeping the engine modular. You can see these layers in the GitHub repo:

  1. Graphics layer
  2. Scene layer
  3. Framework layer

But since pc.Model and pc.ModelComponent exist in different layers, there’s need to do this.entity.model.model.graph.

We could just make a property on the model component that allows you to do this.entity.model.graph. We did that for the meshInstances property. However, I suspect that we’ll probably going to do the following in the next year:

  • Alias pc.GraphNode as a pc.Entity.
  • Make models expandable in the Editor hierarchy.
1 Like

By that do you mean presenting the model’s MeshInstances in the Editor hierarchy?

I mean, displaying the model hierarchy as entities in the Hierarchy panel. Entities that have meshInstances attached will have maybe a new component type called something like pc.MeshComponent, which will have an array of pc.MeshInstances.