Set camera position and target when initiating model

How can I update a model’s camera position before it’s shown (showSceneMode: 1 and scene.show is false). Using camera.updateAsync(newPositionObject, {duration: 0}) after updateSettingAsync(“scene.show”) works but, I don’t like the blur on load.

Can I update the camera’s default position (via the API)? Does updateSettingAsync(“scene.show”, true) always load the default position (i.e. digging into Three.js isn’t going to solve this)?

I’m currently using camera.updateAsync(newPositionObject, {duration: 0}) and delaying the visibility via CSS to achieve the desired effect.

You can disable the blur with

api.updateSettingAsync('blurSceneWhenBusy', false),

see details in the API reference.

Updating camera works with api.scene.camera.updateAsync() and if you want to update the default position without re-uploading just go to model edit page, paste the call with new camera position in the console and then hit the Apply Settings button.

1 Like

Thanks Pavol.

Calling updateSettingAsync(‘blurSceneWhenBusy’, false) before camera.updateAsync(…) enabled me to shorten the CSS transition effect by 0.5s.

It’s not very elegant but this has accomplished what I was looking to do:
await api.updateSettingAsync(‘blurSceneWhenBusy’, false);
await api.updateSettingAsync(“scene.show”, true);
await api.scene.camera.updateAsync(newPositionObject, {duration: 0});
await api.updateSettingAsync(‘blurSceneWhenBusy’, true);

Updating the default camera via the model edit page is not what I’m looking to do as I want to define the camera position at runtime as it’s shown.

This code shows how to update any settings before loading the model:

Thanks! Your code pen enabled me to figure out how to do it:

 await api.updateSettingsAsync({
     scene: {
         camera: {
             cameraTypes: {
                perspective: {
                    default: newPositionObject
                }
            }
        }
    }
});

Hello,
It’s working well in API V2, but how to do it in API V3 please? Cannot find ‘updateSettingsAsync’ here.

Version 3 works differently and it might take a little time to adapt to it, but we believe overall it will make developers life much easier. Have you had a look at our migration guide yet? Please let me know if you have follow up questions that this article does not answer.

Hi Mathieu,
I’ve already reviewed the migration guide, i’m working with API-V3 for weeks now, doing customization on the fly and getting outputs correctly.
The migration guide does not include applying ‘settings’ like camera moves… Could you guide me please ?
Looking into the camera section of the documentation, i’ve to use: ‘set’ or ‘animate’ methods.
But the following isn’t working :warning::

await viewer.camera.set({
        position: {
            x: 0,
            y: 0,
            z: 1.5
        },
        target: {
            x: 0,
            y: 1,
            z: 1.8
        }
      })

Error: Camera(standard).set: Input could not be validated. [object Object] is not of type vec3.

How to include multiple camera settings and how to format ‘vec3’ data ?

Bingo! Resolved =)

position = [0, 1, 0]
target = [0, 1, 0]
await viewer.camera.set(position, target)
1 Like