diff --git a/nicegui/elements/scene.js b/nicegui/elements/scene.js index 96e58525c..2e4e4dc29 100644 --- a/nicegui/elements/scene.js +++ b/nicegui/elements/scene.js @@ -401,6 +401,7 @@ export default { }, move_camera(x, y, z, look_at_x, look_at_y, look_at_z, up_x, up_y, up_z, duration) { if (this.camera_tween) this.camera_tween.stop(); + const camera_up_changed = up_x !== null || up_y !== null || up_z !== null; this.camera_tween = new TWEEN.Tween([ this.camera.position.x, this.camera.position.y, @@ -433,6 +434,12 @@ export default { this.camera.lookAt(p[6], p[7], p[8]); this.controls.target.set(p[6], p[7], p[8]); }) + .onComplete(() => { + if (camera_up_changed) { + this.controls.dispose(); + this.controls = new OrbitControls(this.camera, this.renderer.domElement); + } + }) .start(); }, get_camera() {