From 0d1e27b1678b930684cb081540ab30c49b459ef3 Mon Sep 17 00:00:00 2001 From: Rune Harlyk Date: Thu, 25 Dec 2025 20:04:00 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Fix=20camera=20on=20robot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/lib/components/Visualization.svelte | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/lib/components/Visualization.svelte b/app/src/lib/components/Visualization.svelte index a53d65f..1ad30cd 100644 --- a/app/src/lib/components/Visualization.svelte +++ b/app/src/lib/components/Visualization.svelte @@ -72,6 +72,7 @@ [ModesEnum.Walk]: new BezierState() } let lastTick = performance.now() + let lastRobotPosition = new Vector3() const dir = [1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1] const THREEJS_SCALE = 10 @@ -99,7 +100,6 @@ 'Trace feet': debug, 'Target position': false, 'Trace points': 30, - 'Fix camera on robot': true, 'Smooth motion': true, omega: 0, phi: 0, @@ -264,8 +264,10 @@ } const update_camera = (robot: URDFRobot) => { - if (!settings['Fix camera on robot']) return - sceneManager.orbit.target = robot.position.clone() + const delta = robot.position.clone().sub(lastRobotPosition) + sceneManager.orbit.target.add(delta) + sceneManager.camera.position.add(delta) + lastRobotPosition.copy(robot.position) } const smooth = (start: number, end: number, amount: number) => {