ZoomTo call resets position of the model

Hello,

To replicate: SolarPorts , move the model out of the center and change the zoom factor.

You will see that the model moves back to center. Is this a bug or an intended behavior?

If not a bug … how can I stop it doing that?

Thanks!

The zoomTo() call in the API indeed recenters the object in the scene, it is the main use of this function.
Now I think I understand what you are trying to do and I think using the zoomFactor is not the best way to do so. What are you trying to achieve with this function that the user cannot do themself by zooming in and out using their mouse?

The client doesn’t have a mouse with a scroll and he wanted better granularity for the zoomFactor so I had to make it controllable by code.

The whole purpose of the tool above is to be able to add a model on top of an existing image to simulate how it will look in real life.

What is left now is to, using an html5 canvas, let the user erase parts of the model to simulate that the model is partially behind a car (or other objects). But this is easy to do (3 layers): the original background image, the model in a transparent background and an eraser layer.

Thanks!

Sorin

The scroll button of the mouse just moves the camera position closer or further from the camera target. If you want to simulate that using a slider, you could just compute the distance between the camera position and target and update the position in the same direction. Don’t forget to call viewer.render() after updating viewer.camera.position.

1 Like

Thank you for the tips.