🎨 Fix camera on robot

This commit is contained in:
Rune Harlyk
2025-12-25 20:04:00 +01:00
parent e1dad10a87
commit 0d1e27b167
+5 -3
View File
@@ -72,6 +72,7 @@
[ModesEnum.Walk]: new BezierState() [ModesEnum.Walk]: new BezierState()
} }
let lastTick = performance.now() let lastTick = performance.now()
let lastRobotPosition = new Vector3()
const dir = [1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1] const dir = [1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1]
const THREEJS_SCALE = 10 const THREEJS_SCALE = 10
@@ -99,7 +100,6 @@
'Trace feet': debug, 'Trace feet': debug,
'Target position': false, 'Target position': false,
'Trace points': 30, 'Trace points': 30,
'Fix camera on robot': true,
'Smooth motion': true, 'Smooth motion': true,
omega: 0, omega: 0,
phi: 0, phi: 0,
@@ -264,8 +264,10 @@
} }
const update_camera = (robot: URDFRobot) => { const update_camera = (robot: URDFRobot) => {
if (!settings['Fix camera on robot']) return const delta = robot.position.clone().sub(lastRobotPosition)
sceneManager.orbit.target = robot.position.clone() sceneManager.orbit.target.add(delta)
sceneManager.camera.position.add(delta)
lastRobotPosition.copy(robot.position)
} }
const smooth = (start: number, end: number, amount: number) => { const smooth = (start: number, end: number, amount: number) => {