huggingface / gsplat.js

JavaScript Gaussian Splatting library.
MIT License
1.26k stars 78 forks source link

How do you set up initial camera position? #23

Closed reconlabs-chris closed 7 months ago

reconlabs-chris commented 7 months ago

When loading a splat file, I'd like to set the initial camera position to a specific location. How can this be achieved?

dylanebert commented 7 months ago

Some options:

reconlabs-chris commented 7 months ago

Thank you for your response. However,

1.While moving the entire scene works, it's not very intuitive, as I have to calculate the camera's position relative to the entire scene. 2.Once I set those values for orbitalControls upon its initialization, it seems that I cannot achieve the desired camera position due to the constant min/max zoom settings. 3.I attempted to manually set the camera's position and rotation upon initiation. However, it appears that these values are being overridden in orbitalControls, as I can't manually change its "desiredTarget" value (this is my assumption).

Once again thanks for the great work and It would be great if you can help me.

dylanebert commented 7 months ago

It makes sense that you should be able to change the initial target position of the orbit controls, I will work on an update so that you can change that.

reconlabs-chris commented 7 months ago

Thanks a lot!

reconlabs-chris commented 7 months ago

Also It would also be nice if we could modify the camera not only during initialization but also at any time while the scene is active. There are situations where I need to programmatically control the camera.

krawek commented 7 months ago

+1 this feature would be very nice.

Would also be really nice to be able and set XYZ for the object, currently some of my tests end up with the object leaning and generally just not upright, which destroys the orbit camera functionality.

dylanebert commented 7 months ago

+1 this feature would be very nice.

Would also be really nice to be able and set XYZ for the object, currently some of my tests end up with the object leaning and generally just not upright, which destroys the orbit camera functionality.

In that case you can call scene.translate() and scene.rotate(). Or, there is this tool that can help you reorient scenes: https://github.com/playcanvas/super-splat

krawek commented 7 months ago

+1 this feature would be very nice. Would also be really nice to be able and set XYZ for the object, currently some of my tests end up with the object leaning and generally just not upright, which destroys the orbit camera functionality.

In that case you can call scene.translate() and scene.rotate(). Or, there is this tool that can help you reorient scenes: https://github.com/playcanvas/super-splat

That's perfect, thanks for the suggestion.

dylanebert commented 7 months ago

This issue has now been addressed in the latest patch :) You can pass a target to the OrbitControls, and orbit controls will listen for explicit position/rotation sets on the camera and adjust accordingly.

spark323 commented 7 months ago

It appears that OrbitControls cannot detect changes in the camera's position made using camera.position.set(x, y, z). It can only detect changes when the camera's position is completely replaced with a Vector3, which can be somewhat confusing.

dylanebert commented 7 months ago

Thanks, I'll open an issue and fix that

dylanebert commented 7 months ago

For now I removed the math setters and made properties immutable to fix that issue while keeping the math classes as simple as possible