Why new Mesh will be added to the scene immediately

1638927570(1)

I want to control to join the scene by myself

See Creating a Mesh without adding to the scene

1 Like


Same.

var scenelessBox = new BABYLON.VertexData.CreateBox({width: 2, height: 1, depth: 3});

Vertex data only,not mesh

If you want something you call a mesh not to be added to the scene immediately this implies you want to create a structure that has all the data of a mesh but is not added to the scene yet.

The VertexData is such a mesh data structure before it is added to a scene

You could write

var mesh = new BABYLON.VertexData.CreateBox({width: 2, height: 1, depth: 3});

As an alternative you could create the mesh in the usual way, i.e.

var box = BABYLON.MeshBuilder.CreateBox({width: 2, height: 1, depth: 3});

then use

box.setEnabled(false);

to remove it from the scene and then

box.setEnabled(true);

to add it back.

I get it, thanks for your answer

1 Like