Skip to content

Commit

Permalink
introduce get_camera method to get current camera parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Aug 9, 2024
1 parent fca2b55 commit 0430d9f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions nicegui/elements/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,23 @@ export default {
})
.start();
},
get_camera() {
return {
position: this.camera.position,
up: this.camera.up,
rotation: this.camera.rotation,
quaternion: this.camera.quaternion,
type: this.camera.type,
fov: this.camera.fov,
aspect: this.camera.aspect,
near: this.camera.near,
far: this.camera.far,
left: this.camera.left,
right: this.camera.right,
top: this.camera.top,
bottom: this.camera.bottom,
};
},
resize() {
const { clientWidth, clientHeight } = this.$el;
this.renderer.setSize(clientWidth, clientHeight);
Expand Down
8 changes: 8 additions & 0 deletions nicegui/elements/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,14 @@ def move_camera(self,
self.camera.look_at_x, self.camera.look_at_y, self.camera.look_at_z,
self.camera.up_x, self.camera.up_y, self.camera.up_z, duration)

async def get_camera(self) -> Dict[str, Any]:
"""Get the current camera parameters.
In contrast to the `camera` property,
the result of this method includes the current camera pose caused by the user navigating the scene in the browser.
"""
return await self.run_method('get_camera')

def _handle_delete(self) -> None:
binding.remove(list(self.objects.values()))
super()._handle_delete()
Expand Down

0 comments on commit 0430d9f

Please sign in to comment.