// get the position of the avatar const avatarWorldPosition = new Vector3(); avatarPos.getWorldPosition(avatarWorldPosition); // get the position of the camera const cameraWorldPos = new Vector3(); camera.getWorldPosition(cameraWorldPos); // get the direction vector from the camera to the avatar const pos = cameraWorldPos.clone().sub(avatarWorldPosition).normalize(); // get the distance from the camera to the avatar const distance = cameraWorldPos.distanceTo(avatarWorldPosition); // move the camera along the direction vector with lerping camera.translateOnAxis(pos, lerp(0, distance, delta));
I am using this code to move camera to object. However, this causes camera to move opposite direction of the object. Can anyone explain where i am wrong ? Thank you.
NOTE: I am having trouble to cover projections matrixes etc. Is there a proper content that i can read or watch. Thanks again.