Camera Position

(DDC) #1

I am working on project in which I would need to put 2 different camera views. One that shows interior view and other for the exterior view.

Do you have any API tutorial regarding the usage of cameras and custom views? I found this link article but it is still empty. https://support.shapediver.com/hc/en-us/articles/360021881752-Managing-the-camera
I have also realized that there is a camera revert button in viewer settings but if enabled, it always move camera on starting position, so something doesn’t work there.

Thanks in advanced,

(Mathieu Huard) #2

The article about camera updates will be completed soon. In the meantime, you can check the API functions that are available in the API reference.

As a quick introduction, a camera object in the api is a JSON object containing a position and a target:

let cameraObject = {position: {x: 10, y: 10, z: 10}, target: {x: 0, y: 0, z: 0}}

You can always get the current camera object by calling:
api.scene.camera.get()

After you’ve defined camera positions (interior and exterior views for example), you can update the camera with:
api.scene.camera.updateAsync(cameraObject);

Another useful function is api.scene.camera.zoomAsync(), which will make sure the scene is centered and optimally fills the screen. This corresponds to the “Camera Adjust” parameter of the viewer settings.

The article will include more details about the functions and their various options. I’ll post it here when it becomes available.


Regarding the “Camera Revert” setting, it is meant to always move back the model in its default position, as you described. What behaviour did you expect this setting to have instead?

(DDC) #3

Thank you for the quick introduction to camera setting. Regarding the “Camera Revert”: I think that this tool will be more functional if you include “camera revert” button. For example, looking some object from different point of view and than if you want, you can to revert it to default position with this button .
Right now, I think that it doesn’t have so much sense, because if you are end user and want to see some object by 3d orbiting view, you should probably want to spend some time looking an object from some new point of view. However it is impossible with automatic revert that send you immediately to start position. Simply, I can’t see in which situation this option automatic revert might be useful

(Mathieu Huard) #4

The automatic revert was found useful in e-commerce applications, in particular for end users who don’t have much experience interacting with 3d scenes.
The behaviour you want also exists in the viewer, with a perfectible interface I’ll admit. Using the camera button on the top right of the viewer window, a single click will center and zoom on the scene contents, while a double click will revert the camera position to its default position.
image