Giving Types to Shapes

Hi Babylonians. I’m new here and trying to dig in deep. How can I cast shapes as different types? So, in my use case it would be (Walls, Windows, Doors, Cabinets, etc). Obviously, multiple meshes/shapes would be constructed to create a casement “window” for example. How can I wrap those elements in an object called “window” so I could tell if I am clicking on a door/window/or whatever? Or if a “window” is being dropped into a “wall”. Sorry if my explanation is rough

You could us a TransformNode to group primitive parts together into an assembly. Depending on the complexity of your assemblies you could also merge meshes to ensure optimal performance.

You can also extend Mesh or TransformNode and create your own fully parametric meshes.

1 Like

Exactly what @inteja said :slight_smile: and you may find this helpful: Parents and Children | Babylon.js Documentation

You guys are awesome. Let me make sure I understand this correctly.

var CoT = new BABYLON.TransformNode("root");

In the code above. The “type” defined would be called “root” correct?

so if I did

scene.pick()

it would return “root” as the mesh picked?

No “root” is not a mesh so is can not be picked but any of its children meshes can :slight_smile:

@sebavan so then what is the purpose of “root”?

1 Like

You can walk up the hierarchy after picking the mesh to see that the parent is of a particular group. Another approach maybe is to use tags and tag the meshes with a specific string to categorize them.

1 Like