Hello there !
I want to load some meshes (*.gltf) and I want to move them !
I used this code :
BABYLON.SceneLoader.ImportMesh(“”, “”, “Soucoupe.gltf”, scene, function(newMeshes) {
newMeshes[0].position = new BABYLON.Vector3(0, 2, 0);
newMeshes[0].rotation.y = Math.PI/4;
}
The problem is : the mesh position is updates but not the rotation …
Can you help me ? I think I’ve not understood it very well !
Models imported as gltf come in with their rotation encoded in mesh.rotationQuaternion, not mesh.rotation. Once rotationQuaternion is set, all adjustments to rotation are ignored. If you want to use rotation, use these lines to convert the quaternion to angles and null out the quaternion.
Although the above answer is correct, may I just add that you can also reset it by passing a new vector3 in ‘rotation’, which in turn will null the rotation quartenion, such as described here