this.camera.position.set(position.x, position.y, position.z);
this.controls.target.set(center.x, center.y, center.z);
this.controls.update();
After doing this, the zoom and pan starts to go very slow and I can’t zoom to infinity
this.camera.position.set(position.x, position.y, position.z);
this.controls.target.set(center.x, center.y, center.z);
this.controls.update();
After doing this, the zoom and pan starts to go very slow and I can’t zoom to infinity
your position that you pass into the camera, and your center that you pass into the target are most likely very close together or the same coordinate.
Thanks for the reply. What I am trying to do is save the camera state and then get it back and the only option I have found is this. Since I’m using ControlOrbits I always kept the target, that’s why I modify it. Is there a better way to save and retrieve camera state (serialization)?
Thank you!
you only need the current camera.position
in the scene,
eg,
{x:2, y:1, z:5}
and the current orbitcontrols controls.target
eg,
{x:0.25, y:0.5, z:1}
they are both THREE.Vector3
then after you retrieve your values from however you stored them, do something like
camera.position.set(2, 1, 5)
controls.target.set(0.25, 0.5, 1)
controls.update()
of course, you can create and use THREE.Vector3()'s instead of hard coding like in my suggestion
see this example where I do similar. I read from a json file, and then also use tween when the annotation is clicked.
Thank you so much for your answer.
This is precisely what I am doing. But when setting the controls.target both the pan and the zoom (mouse wheel) start to go super slow and also I can’t get close to the elements.
It happens exactly when I do this
this.controls.target.set (center.x, center.y, center.z);
because if I comment this code it points to 0,0,0 and it no longer happens to me
Thanks a lot!
These would be the values that I am serializing and setting
Posición (camara.position) { 6.120767184308619 10.363199383713926 12.431459496880588}
Centro (controls.target) { 6.120767184308619 10.36320124324003 10.572635 }