5 minutes
TL;DR — Adds
WorldOriginAnchorto thePlayer. It is an empty marker. It names the ship as the point the rendered world re-centres on. Its system sends the ship's position to the renderer each frame. New here: the floating-origin subject marker. This is the last structural piece, so the assembled scene now matches the canonical one. For now it only records the offset. The flight looks the same until the rebase that reads it lands.
Catching up?
Dropping in at this lesson? One command reinstalls the library components the build uses so far and writes the scene as it stood at the end of the previous lesson to public/scenes/WingmanFlight1-lesson-8/scene.json:
Copy that scene.json over your src/scenes/wingman.json and you are caught up to the start of this lesson.
Point the falcon at empty space and hold the throttle. For a while, the view looks clean. Then you fly far out, tens of thousands of units from the start. The picture starts to break up. The hull shimmers. The motion picks up a small jitter. Distant edges crawl. Your code did not change. The problem is precision. It ran thin.
A single-precision float holds about seven significant digits. Near the origin, that gives you sub-millimeter positioning. At ninety thousand units, five of those digits go to the integer part. Only two digits are left for the rest. So the ship can only sit on a coarse grid. Every frame, its position snaps to the nearest step on that grid. That snapping is the jitter you see. A far plane of 200,000 spreads the same thin precision across the depth buffer. The shimmer comes from the same cause.
The fix is to stop the ship from drifting so far from zero. Keep the rendered world centred on the ship. This is called a floating origin. You offset everything else by the ship's position. The last structural piece is marking which entity the origin tracks.
Continue reading
Unlock the Full Course
Every lesson, the runnable examples, and the finished build — yours to keep.