Is this still the case? It feels unintuitive to do it like this.
Could it not also cause side effects having meshes being part of the scene for a short time?
I don’t understand why I have to give the scene as a parameter in the first place, since leaving it out or setting it to null has the same effect as using “scene”.
Also with this approach my IDE complains that my variables (for example plate) are not used in the code.
i have way for make geometry without any webgl dependency and you quickly can use
and attach the mesh when you want in the any scene is that what you want?
Does that mean that using MeshBuilder I cannot prevent rendering the mesh? I want to use the mesh as template and clone it. To hide and completely remove it from the screen, I have a workaround right now by making it invisible by setting mesh.isVisible = false and set a very large value for coordinate: mesh.position.x = 9999
I have tried to use setEnabled as well, but seems like it will still be considered by the physic engine. Should I set the PhysicImpostor for all the clone instead of the original one(but I would prefer setting it once for the original one)?
You didn’t mention that you were using physics. Is there an issue with using the original plus clones rather than all clones? Perhaps @Cedric can help.
If you don’t create a physics impostor for a mesh, it won’t be physicalized.
So, I would suggest to clone a mesh, then create its impostor. Then, call setEnabled(false); to remove it from rendering… or dispose it if you won’t have to spawn any new clone.
This seems to no longer be the solution as the method you’re calling is marked as deprecated.
The deprecated method says to use CreateBoxVertexData:
var scenelessBox = new BABYLON.BoxBuidler.CreateBoxVertexData({width: 2, height: 1, depth: 3});
var box = new BABYLON.Mesh("box");
scenelessBox.applyToMesh(box);
Is this correct? Also, how do you then retroactively add a mesh to the scene? There doesn’t seem to be a scene.addChild method. Is it mesh.addParent(scene) ?
This mesh API doesn’t really make sense. Instantiating an object should not mutate the scene.
The accepted answer seems not valid anymore : VertexData is deprecated, documentation explains we just have to call CreateBox directly. But when we do that, the playground does not work anymore : the box is added on the scene.
From a lambda user’s point of view, since the scene is an optional parameter, we expect something simple : the mesh is added to the scene only if the scene is given. I don’t really understand why it has to be more complicated.