when I click on ground, camera should move to clicked position, which I am achieving with animation
var animateToPoint = function(start, finish) {
isAnimating = true;
var end = finish.clone();
var animating = BABYLON.Animation.CreateAndStartAnimation('cam', root, 'position', 120, 120, start, end, BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT);
animating.onAnimationEnd = () => {
isAnimating = false;
impact.isVisible = false;
};
}
The issue is when clicked on ground, camera doesn’t move to the exact location where it is clicked, instead it moves camera to centre of clicked mesh position.
any help? Thanks
thanks @Cedric pickResult.pickedMesh.position and pickResult.pickedPoint provides same result, camera doesn’t move to exact location on ground where mouse was clicked.
I think I understand. That’s because of your root transform. The camera position is relative to that root. so you need to set camera local position to 0 in order to get no difference with the root position.
not sure if understood correctly, here I updated root position with camera, root.position = new BABYLON.Vector3(0, 5, -10);
but it has same issue, doesn’t go to clicked position