I use the instantiateModelsToScene() function inside the assetsManager loading function, everything works as it should, e { rootNodes: Array(1), skeletons: Array(1), animationGroups: Array(3) }, but when I clone the mesh by clicking on the button, the mesh is like this: e { rootNodes: Array(0), skeletons: Array(1), animationGroups: Array(3) }
rootNodes no. Why is that? I did everything according to the examples in other topics, but there was no example with online cloning anywhere
Hello and welcome!
Here is the simple example - Babylon.js Playground
Seems that rootNodes are there where they should be.
@labris
Good, thank you.
But, how to rotate rotation mesh instantiateModelsToScene? I change the rotation value, but it changes in the viewport
Since the original mesh is GLB model, it has rotationQuaternion values for rotation.
You may either use root.rotationQuaternion = new Quaternion(x, y, z, w)
or null it and use usual mesh.rotation
like in this example - https://playground.babylonjs.com/#518D3X#1
More info in the Docs - Babylon.js docs
@labris
Thanks you, really thanks you
@labris
One last question
I have a soldier model in a container. I use it when I need it. There are three meshes: one is the character mesh itself, the second is the weapon mesh, the third mesh is the bullet, which has a weapon as a parent. And this is how I get access to the bullet mesh object:
soldat.getChildren()[0].getChildren()[2];
But for some reason, I can’t hide or delete this mesh, I can get access to the weapon soldat.getChildren()[0].getChildren()[1] and, for example, apply setEnabled(false), and then the bullet will hide along with the weapon. Is there a solution to this problem? I would like to hide the bullet mesh and show visibility during the gameplay, i.e. shooting.
I can’t attach the playground, since it is very large and connected to the server. If the question is unclear, I can try to make a PG later. Thank you very much in advance for your help
I believe you need just unparent your bullet.
bulletMesh.parent = null