Update parameters after initialization

Is there a way to update the config-params after the initialization of the viewer?

I have set autospin to 1 and want to disable it after the first ‘camerastart’-Event (user has moved the camera).

var cameraHasMoved = false;
api.addEventListener('camerastart', () => {
   if (!cameraHasMoved ) {
     cameraHasMoved  = true
    // TODO: disable autospin here
   }
})

I don’t believe that is possible. The camera constraints are available in the viewer API, but the autospin isn’t.
You could create your own autospin however. Here’s an example: https://codepen.io/klaasnienhuis/pen/KKRKmbR?editors=0010
You’d then have to detect a user interaction and stop the autospin, similar to your code.

:+1:
Im going to set up my own autospin like suggested.
Thank you for the example.

1 Like

@james I had a quick thought while creating this code example. I’ve created an autospin with the help of requestAnimationFrame and setCameraLookAt. To end this autospin I’d like to detect whether the user manually orbits the model. There’s a cameraStart event to do just that. However, the cameraStart event also reacts to the setCameraLookAt function. I don’t see a way to differentiate between a manual camera movement (user orbits the model) and an API camera movement (with setCameraLookAt)
Do you know how to work around this? Or would you consider adding such a thing to the API?

1 Like