Kathyer
Kathyer

Reputation: 21

Camera rotation lost when i use orbitcontrols three.js

I am developing a web application that uses 3d buildings as models. I want to create a button that places the camera so that the model is in a suitable position, however when I rotate the camera manually the mouse control resets it again.

Sample here:Link

If I enable //controls.update() the rotation doesn't work. With //controls.update() disabled the camera rotate fine but when I use the mouse, the camera is reset.

¿What can I do? Thanks!

Upvotes: 0

Views: 1839

Answers (1)

inet123
inet123

Reputation: 774

You shouldn't directly change the rotation of the camera, instead you should change the position+target.

When you call controls.update() the rotation of the camera will be calculated based on the position of the camera (the location of the camera) and the target of the controls (the location of focus).

For example you can do:

controls.target.set(0,0,1);
camera.position.set(-0.041, 1.9, -1.21);
controls.update();

Upvotes: 1

Related Questions