Currently, I am playing around with threeJS and have managed to position the camera to look at the origin point of a scene (0,0,0). My goal is to rotate the camera in a circular path around the y axis at a specific distance (radius) while keeping its focus on the origin. However, I am unsure about how to formulate the equation for this movement. Currently, I am simply rotating the object itself, but I would prefer to rotate the camera instead. Below is the code snippet I am using to move the mesh:
function checkRotation(){
if (keyboard.pressed("left")){
mesh.rotation.y += .05;
}
if (keyboard.pressed("right")){
mesh.rotation.y -= .05;
}
}
Here is an example of how I envision moving the camera:
camera.position.x = ??? (an equation for adjusting its x position) camera.position.z = ??? (an equation for adjusting its z position) camera.lookAt(mesh.position);
Any assistance or guidance on this matter would be greatly appreciated. Thank you!