Orbit Controls overwriting PerspectriveCamera

Hello, I want to set the rotation of my perspective camera. But when I have orbit controls enabled, the rotation={} from the perspective camera is not working at all. It works when I delete the Orbit controls. I’m pretty sure it overwrites it and I have no clue how to fix it. Any ideas? Thanks in advance

yes, OrbitControls takes control of the camera.
If you want to set the camera rotation, you can do it through OrbitControls
E.g.,
<OrbitControls target={[3, 2, 1]} />

Above example will point the camera from its current position, to look at x:3, y:2, z:1.

You decide the numbers.

See official docs for all the settings.
https://threejs.org/docs/#examples/en/controls/OrbitControls

1 Like

It works fine to set the starting target. But then the orbit controls " The focus point of the controls, the [.object] orbits around this. It can be updated manually at any point to change the focus of the controls."

My question now is, can I set the default orbit controls to target={[3, 2, 1]} and then remove it and set it to [0,0,0]?

I would like my center of the page to be the 0,0,0

you can change the camera position and orbit controls target any time you wish.
if you change camera rotation outside of the OrbitControls methods, then call OrbitControls update so that the OrbitControls uses the new camera matrix.

See this below example where I use the perspective camera and OrbitControls together and change the properties several different ways. I.e., buttons and double click on the scene to lerp target and position while still allowing OrbitControls to control.

image

1 Like

I’ve spent the last 2 hours, looking at the code and understanding how it works. It really added the last touch to my project. I’m really grateful!