Camera Rotation Doesn't Work

camera
orbit-controls

#1

Hi,

So I have a scene setup with a Perspective Camera and orbit controls. When I zoom into the subject it zooms into the bottom portion and I want the camera to zoom into the upper half of the subject instead. I first tried to change my camera’s rotation and no rotations (rotation.x, rotation.y, rotation.x) seem to have an effect on the scene.

I then tried to change the orbitControl target, but I ran into the same problem where it shifted the view of the entire frame and the subject wasn’t centered in the viewport anymore.

Ideally I think I would be able to change the rotation of the camera so that I could angle it at the top half of my subject but I have no idea why its not working. I would really appreciate your help!

–Edit: In other words, I’m asking if there’s a way to zoom in to your subject such that it doesn’t zoom into the center of the canvas, instead it zooms towards like the top of the canvas.


#2

Did you add requestAnimationFrame looping ?
this.renderer.render(this.scene, this.camera);

window.requestAnimationFrame(() => {
  this.animate();
});

#3

Yes. Im using react js for the project and have an animate function that serves the same function as what you mentioned before.


#4

Try this :

componentDidMount() {
window.addEventListener(“mousemove”, this.onMouseMove, false);
window.addEventListener(“mousedown”, this.onMouseDown, false);
var animate = function () {
requestAnimationFrame(animate);
renderer.render(scene, camera);
};
animate();
}

#5

Sorry I think I phrased my question poorly previously.

I’m looking for a solution that either:

  1. let’s me zoom into a position off center in orbit controls. (ie. instead of zooming into the center of the canvas, zoom into the top of the canvas)
  2. let’s me change the rotation of the camera. So far, I’ve tried rotating it using rotation.x, rotation.y, rotation.z, and none of these seem to work

I appreciate the help!


#6

Camera Rotation for First-Person Controls not correctly Check this example