Skip to content

Gaussian splats drift/float in iOS AR as camera moves (UntoldEngineAR never syncs CameraComponent.localPosition) #1441

Backlog

Description

@untoldengine

Summary

When a Gaussian splat (.untoldgs) entity is placed on a detected AR plane and the device camera moves, the splat appears to float / not stay anchored, while mesh geometry placed the same way stays correctly anchored.

Root cause

Sources/UntoldEngineAR/UntoldEngineAR.swift (draw(in:)) feeds ARKit's live view matrix into UntoldRenderer.renderXR(viewMatrix:...) each frame, which correctly updates CameraComponent.viewSpace — this is why mesh rendering (which only consumes the view matrix for its model-view-projection) stays rock-solid as the camera moves.

However, CameraComponent.localPosition — the camera's world position, tracked separately in the ECS — is never synced to the live ARKit pose. The only call that keeps this field in sync for a device-driven camera is UntoldRenderer.setXRCameraWorldPosition(_:) (Sources/UntoldEngine/Renderer/UntoldEngine.swift:871), which Sources/UntoldEngineXR/UntoldEngineXR.swift (visionOS) calls every frame from syncStreamingCameraPosition() using the device anchor position. UntoldEngineAR.swift (iOS ARKit) has no equivalent call, so this field stays frozen at whatever it was last set to (origin, or the last explicit camera-move API call) regardless of how far the physical device moves.

Sources/UntoldEngine/Systems/GaussianSystem.swift (GaussianEntityFrameMatrices.init, ~line 223) reads cameraComponent.localPosition through SceneRootTransform.shared.effectiveCameraPosition(...) and feeds the result into the chunk cull/LOD/budget distance math (cameraPositionWorld in gaussianChunkCullConstants, used by the distance-prioritized chunk budget solve from #1439). Because this camera-position input is stale while the actual ARKit camera is moving, chunk/LOD prioritization desyncs from the true viewpoint — visually reading as the splat floating/drifting relative to the correctly-anchored mesh.

Per SceneRootTransform.swift's own doc comment, this same stale field is also read directly by TextureStreamingSystem and LODSystem, and (via WorldTransformComponent.space) by GeometryStreamingSystem/StreamingRegionManager — so any mesh streaming/LOD/geometry-streaming behavior gated on camera distance is likely also silently wrong in iOS AR mode, just less visually obvious than the Gaussian case.

Suggested fix

In UntoldEngineAR.swift's draw(in:), before/alongside computing currentARCamera, extract the ARKit camera's world position (currentFrame.camera.transform.columns.3) and call renderer.setXRCameraWorldPosition(...) each frame, mirroring UntoldEngineXR.swift's syncStreamingCameraPosition().

Repro

  1. Place a Gaussian splat entity on a horizontal AR plane (via pickRealSurfacePosition or similar hit-test placement).
  2. Move the device camera around the splat.
  3. Observe: the splat appears to float/drift relative to the real-world plane, while a mesh placed the same way stays anchored.

Files involved

  • Sources/UntoldEngineAR/UntoldEngineAR.swift (missing camera-position sync)
  • Sources/UntoldEngine/Renderer/UntoldEngine.swift (setXRCameraWorldPosition, renderXR)
  • Sources/UntoldEngine/Systems/GaussianSystem.swift (GaussianEntityFrameMatrices, chunk cull distance math)
  • Sources/UntoldEngine/Systems/SceneRootTransform.swift (doc comment listing other consumers of cameraComponent.localPosition)
  • Sources/UntoldEngineXR/UntoldEngineXR.swift (syncStreamingCameraPosition, the working visionOS reference pattern)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions