Search code examples
javascriptbabylonjs

Babylon.js setting rotations of imported model rotates model


var Game = {player:null};
BABYLON.SceneLoader.ImportMesh("","model/","scene.gltf",scene,function(model){
model[0].position = new BABYLON.Vector3(0,0,0);
model[0].scaling=new BABYLON.Vector3(0.005,0.005,0.005);
Game.player = model[0];
});

engine.runRenderLoop(function(){
scene.render();
Update();
});

function Update(){
Game.player.rotation.y=1;
}

I intended to set rotation of Imported model. I though I did wrong and tested with camera, but it worked great.

Is this just bug of babylon.js or did I just do something wrong?


Solution

  • Hello maybe your model has a rotation set with rotationQuaternion (which in this case will overwrite the rotation property)

    This should work then:

    Game.player.rotationQuaternion = null;
    Game.player.rotation.y=1;