My current setup involves using orbit controls to rotate the camera in my three.js project.
const controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.dampingFactor = 0.07;
controls.rotateSpeed = 0.07;
controls.enableZoom = false;
controls.screenSpacePanning = false;
controls.minDistance = 250;
controls.maxDistance = 350;
controls.minPolarAngle = 1.2;
controls.maxPolarAngle = 1.2;
In addition, I have set a fixed position for the camera as follows -
camera.position.x = 308;
camera.position.y = 135;
camera.position.z = 130;
Everything works smoothly when I use left-click mouse movement to navigate around my object. However, I encounter an issue when I try to use right-click mouse movement as it unexpectedly moves the camera away from the object. I have attempted to disable this functionality by utilizing event listeners on the document, but have not been successful in finding a solution yet.
document.addEventListener("mousedown", function(event){
console.log(event.button);
if(event.button == 2){
rightmousemove = true;
return false;
}
});
document.addEventListener("mousemove", function(event){
if(rightmousemove === true){
event.preventDefault();
event.stopPropagation();
}
});