Being new to working with threejs
, I am struggling to set limits on the camera position within my scene. When using OrbitControls
, I noticed that there are no restrictions on how far I can zoom in or out, which I would like to change. Ideally, I want the camera to stop when camera.position.z = 5
and resume restriction when it reaches approximately camera.position.z = 10
. I seek to confine the range of camera.position.z
between these values. To better understand my goal, you can view the limited camera movement on this website:
My attempted solution:
if (camera.position.z <= 5) {
camera.position.z = 5;
}
else if (camera.position.z >=10)
{
camera.position.z = 10;
}