zauberzeug / nicegui

Create web-based user interfaces with Python. The nice way.
https://nicegui.io
MIT License
10.16k stars 605 forks source link

Fix camera looking back to the origin after calling `move_camera()` #3920

Closed falkoschindler closed 4 weeks ago

falkoschindler commented 4 weeks ago

This PR fixes a problem introduced by PR #3544: The camera kept looking at the origin when calling move_camera() with given look_at_* coordinates.

The fix can be verified with the following snippet. Moving back and forth between the spheres should not point the camera back to the origin, an the orbit controls should orbit around the sphere which is currently looked at:

with ui.scene() as scene:
    scene.sphere().move(1, 2, 0).material('blue')
    scene.sphere().move(4, 5, 0).material('red')

ui.button('blue', on_click=lambda: scene.move_camera(*(1, 2, 3), *(1, 2, 0), *(0, 1, 0), duration=1))
ui.button('red', on_click=lambda: scene.move_camera(*(4, 5, 6), *(4, 5, 0), *(0, 1, 0), duration=0))