hunts Posted February 2, 2017 Share Posted February 2, 2017 hy guys, i used a lookAt function for my model on a pickedPoint, but the problem here is i want the model to rotate clockwise or anticlockwise, i don't want it to rotate up and down http://playground.babylonjs.com/#OK5PN#1 Quote Link to comment Share on other sites More sharing options...
getzel Posted February 2, 2017 Share Posted February 2, 2017 Hello ! Use this function : function mousemovef(){ var pickResult = scene.pick(scene.pointerX, scene.pointerY); if (pickResult.hit) { var diffX = pickResult.pickedPoint.x - box.position.x; var diffY = pickResult.pickedPoint.z - box.position.z; box.rotation.y = Math.atan2(diffX,diffY); } } This is trigonometry (arctangeant2). http://playground.babylonjs.com/#KNE0O#4 This will be soon in the tutorials. hunts 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.