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.
Will
November 8, 2021, 4:56pm
2
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.
Will
November 8, 2021, 5:51pm
4
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?
Will
November 8, 2021, 6:30pm
7
The snippet I sent was just an example, sorry for any confusion. Here is a thread that should be helpful:
I’m trying to store the player’s camera view and reset it in case it’s needed, this “seems” to work fine with the below steps (please let me know if there’s a better way)
let [pos, quat] = [player.camera.getPosition(), player.camera.getQuaternion()];
play with the camera view on the player, reset the camera view
player.camera.setPosition(pos); player.camera.setQuaternion(quat);
it works, but the zoom doesn’t have any restrictions any more, if I zoom in or zoom out, it goes beyond of what it …
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?
Will
November 8, 2021, 7:25pm
9
Threekit has built in phases you can listen for:
Which Threekit environment are you working in? You can un-initialize the Threekit player with window.player.unload() in preview & admin-fts environments.
Here is some code examples for executing code at different phases, I hope this is helpful:
const player = await window.threekitPlayer({
assetId,
authToken,
el,
});
window.player = player;
// Avoid typos by referencing the phase constants
const { PRELOADED, LOADED, RENDERED } = player.scene.PHASES;
player.on(PRELOADED, () => {
conso…
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