Skip to content

[Patch] Fix getCameraEye returning a stale position after WASD movement - #1438

Merged
untoldengine merged 1 commit into
developfrom
issue/1437
Dec 3, 2026
Merged

untoldengine merged 1 commit into
developfrom
issue/1437

Conversation

@untoldengine

Copy link
Copy Markdown
Owner

Summary

Fixes #1437. getCameraEye(entityId:) returned CameraComponent.eye, a field only ever written by cameraLookAt (orbit/pan/zoom/look-style camera code). The WASD fly-camera path (moveCameraWithInput → moveCameraBy/moveCameraTo → translateBy/translateTo) correctly updates the camera's real rendered position (LocalTransformComponent.position, mirrored into CameraComponent.localPosition/.viewSpace via syncCameraTransformIfNeeded) but never touched .eye — so getCameraEye kept returning the pre-move position indefinitely, even though the camera had visually moved.

Any caller using getCameraEye as a picking-ray origin (raycast selection, ground-plane picks) would silently miss everything after the camera had ever been moved by WASD-style input. Reproduced in this repo's Sandbox demo and in a sibling app's Gaussian-splat viewport picking.

getCameraEye now returns cameraComponent.localPosition — the same ground truth getCameraPosition already uses — so it can never diverge from the camera's actual position regardless of which movement path moved it.

Test plan

  • Added testGetCameraEyeTracksPositionAfterWASDMovement to CameraTest.swift: calls cameraLookAt then moveCameraWithInput, asserts getCameraEye tracks the camera's real position instead of freezing at the pre-move value.
  • swift test --filter UntoldEngineTests — 1837 tests, 0 failures, no regressions.
  • Manually verified in the Sandbox demo: selected a Gaussian-splat entity, moved the camera with WASD, dragged its gizmo handles — tracking now holds correctly across camera movement/position.

getCameraEye read CameraComponent.eye, a field only ever written by
cameraLookAt (orbit/pan/zoom/look). moveCameraWithInput/moveCameraBy/
moveCameraTo (the WASD fly path, built on translateBy/translateTo)
correctly update the camera's real position but never touched .eye,
so getCameraEye kept returning the pre-move position indefinitely —
wrong for any caller using it as a picking-ray origin, even though
the camera had visually moved.

getCameraEye now reads localPosition, the same ground truth
getCameraPosition already uses, so it never diverges from the
camera's actual position regardless of which movement path moved it.

Fixes #1437
@untoldengine
untoldengine merged commit db2a921 into develop Dec 3, 2026
4 checks passed
@untoldengine
untoldengine deleted the issue/1437 branch December 3, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getCameraEye returns a stale position after WASD-style camera movement

1 participant