Hello guys, I’m having some trouble in my initial project with Babylon.js.
I have imported my model 3D at the project, as I show bellow:
tank = BABYLON.SceneLoader.ImportMesh("","",“Models/model003.babylon”,
scene,function(newMeshes) {
newMeshes.forEach(function(mesh){
mesh.rotation = new BABYLON.Vector3(BABYLON.Tools.ToRadians(
10),0,0);
} );
});
So far so good but now I want to add buttons in order to translate the object.
I’ve tried this:
scene.registerBeforeRender(function(){
if (bla==1){
var posX = Math.sin(tank.rotation.y);
var posZ = Math.cos(tank.rotation.y);
console.log(posX,posZ);
tank.position.x += posX;
tank.position.z += posZ;
}
if(bla == 2){
tank.rotation.y = tank.rotation.y + 0.1;
}
if(bla == 3){
tank.rotation.y = tank.rotation.y - 0.1;
}
});
But the console shows the error “0: Unable to get property ‘y’ of undefined or null reference” so… what should I do ?