Reset Camera Position

Hello,
I am working with window.threekit.player and window.threekit.player.snapshotAsync() this renders me a snapshot of the current view of the player, right?
I’m wondering right now if there’s a way to reset the camera position to it default option so all the configurations keeps but camera.
I guess I am able to do with this:

play.camera.getPosition
(t=new r.Vector3)=>e.getCameraPosition(t)
play.camera.getQuaternion
(t=new r.Quaternion)=>e.getCameraQuaternion(t)

and this:

play.camera.setPosition
play.camera.setQuaternion

So my question is, what is the parameter that setPosition and setQuaternion should have to reset it to default camera angle?

CM.

Hi Carlos - would you prefer to work programmatically?

You can always create cameras in your asset and switch between them by creating a rule that changes the active camera.

I am not allowed to do that (I should do it something more like)

camera.position.set( 0, 0, 0 ); OR camera.position.set( reset );

So when the button triggers it resets to default and then takes the snapshot with defaults.

Can I ask what you mean by not being allowed to do that? Theoretically, the result should be the same if you did something like:

    window.threekit.configurator.setConfiguration({"Camera":"Side"});
    d["Side"]
    await window.threekit.api.snapshotAsync();

If this still is not a viable option I will look into a solution for targeting the camera directly.

I must add this instruction too?

d["Side"]

@Will
Mr. Will, Also it didn’t work, I ran the instruction but isn’t resetting to it’s default.
I am not allowed because we have like 20 o 30 products so I must modify all the products at threekit platform and it will take too much time.
I guess it’s easier this way.
what do you think?

The snippet I sent was just an example, sorry for any confusion. Here is a thread that should be helpful:

I believe the relevant snippet here should achieve what you are looking for:

When the player loads, store the camera’s initial position:

let [pos, quat] = [player.camera.getPosition(), player.camera.getQuaternion()];

When you need to reset the camera, you can call the following:

player.camera.setPosition(pos); 
player.camera.setQuaternion(quat);
1 Like

This approach seems what I am looking for, haven’t tested because I am researching on how to handle after player loads so I can capture it. any ideas?

Threekit has built in phases you can listen for:

Hello @Will I ended my problem by using some states handling after load and all renders, so some semaphores helped me to approach and final one the setPosition and setQuaternion.

Thanks again I really appreciate your knowledge.

1 Like