Skip to content
Back to skills

Coordinate Frames

ASecurity

Use when a rover, camera, terrain tile, trajectory, planet, or link jitters, moves in the wrong direction, changes altitude while stationary, loses its orientation after a view switch, or when adding a new orbital/body-fixed reference frame. Also use for BigSpace, CellCoord, FloatingOrigin, ActivePhysicsFrame, or frame-conversion work.

  • 112 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 7, 2026
developmentrustgoshellangularspringapifrontendbackend

Works with

  • cursor
  • cli
  • api

Security analysis

A100/100

Scanned November 25, 2026

npx -y skills add LunCoSim/lunco-sim --skill coordinate-frames --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Coordinate Frames?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Coordinate Frames
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/luncosim-coordinate-frames/badge)](https://www.skillsdirectory.com/skills/luncosim-coordinate-frames)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: coordinate-frames
description: >
  Use when a rover, camera, terrain tile, trajectory, planet, or link jitters,
  moves in the wrong direction, changes altitude while stationary, loses its
  orientation after a view switch, or when adding a new orbital/body-fixed
  reference frame. Also use for BigSpace, CellCoord, FloatingOrigin,
  ActivePhysicsFrame, or frame-conversion work.
---

# Coordinate frames and BigSpace

Use this runbook for coordinate changes. The concise design contract is
[`docs/architecture/45-big-space-correct-usage.md`](../../docs/architecture/45-big-space-correct-usage.md).

## Find the semantic owner first

Every astronomical or surface pose has a semantic `ReferenceFrame`:

- `World` for the persistent scene frame;
- `EclipticJ2000 { center }` for non-rotating body-centred work;
- `BodyFixed { body }` for a rotating surface frame.

Resolve it through `ReferenceFrameIndex`. Never select the first `Grid`, walk
an arbitrary parent, or add a second frame marker to a precision sub-grid.
Missing and duplicate declarations must remain errors (`None`).

## Use the existing conversion path

1. Read the authoritative f64 pose from USD, ephemeris, Modelica, or Avian.
2. Convert source → target semantic frame with the existing f64 frame helpers.
3. Resolve the target `Grid` from `ReferenceFrameIndex`.
4. Split once with `Grid::translation_to_grid`.
5. Attach/migrate atomically with `lunco_core::attach::migrate_to_grid`.

`CellCoord`, `Transform`, and `GlobalTransform` are private projection state.
They never cross a user/API/network/model boundary and never become the
authoritative source of an astronomical or physics value.

Authored body-local physical mounts use `lunco_core::DTransform` through
`lunco_usd_bevy_stage::transform_in_body_frame`. Keep translations, rotations
and actuator directions in f64 through mass reduction and Modelica allocator
generation. Subtract body/world translations before any native conversion.
Narrow only at the checked native solver or presentation boundary; widening a
native vector must never supply canonical generated-model geometry.
At point-force application, use the physics backend's shared range check for
the force, relative lever arm and resulting torque before Avian narrows them.
An excessive native moment must produce a diagnostic and hold integration.

For immutable high-precision presentation entities, use BigSpace's existing
`Stationary` marker. Streamed globe/terrain visual tiles may use it because
their placement is fixed until the entity is replaced; never use it on a
camera, avatar, physics tile, or any entity that can mutate `CellCoord`,
`Transform`, or `ChildOf`. Remove `Stationary` before relocating an entity, as
required by BigSpace.

Application schedule gates may skip BigSpace work only from authoritative
spatial invalidations. `LocalFloatingOrigin::is_local_origin_unchanged` reports
the result of its most recent computation; after an origin changes, admit one
follow-up local-origin computation to settle that flag. Do not treat a retained
`false` as a permanent high-precision invalidation. Verify an origin shift, its
settle pass, then stable frames with propagation closed. Track the pending
settle between admitted passes rather than scanning every grid in an idle gate.

For a camera, compose the selected camera's authoritative f64 pose into the
persistent `WorldGrid` and update the grid-direct `OriginAnchor`'s
`(CellCoord, Transform)` split. `OriginAnchor` is the sole owner of
`FloatingOrigin`; cameras never receive or transfer that marker. For a
navigation precision check, use `RenderPrecisionQuery` and the anchor's typed
`RenderOriginController` lease. Certify future native rebasing as well as the
current transform; camera travel alone cannot bound an origin-cell jump. Include
nested grid remainder narrowing and GPU arithmetic in the declared camera skin
budget, and verify against actual native propagation across a cell boundary.
For a
site-anchored scene, celestial placement mounts only the authored site root.
The root becomes the nested site `Grid` and `ActivePhysicsFrame` as soon as its
`SiteAnchor` is projected, then is atomically migrated beneath the matching
body-fixed surface Grid when that hierarchy is ready without changing the
active frame. The anchor establishes frame intent only: `GeodeticAnchor.body`
must match a composed `CelestialBody.ephemeris_id` before placement and
body-derived gravity can bind. It does not load a body or its gravity provider.
Terrain and rover/lander roots are sibling top-level children of that scene
Grid; a rover is never parented to terrain. Each such top-level prim carries
its own `CellCoord`, while visual and collision descendants remain
ordinary children rooted in `LowPrecisionRoot`. Celestial placement does not
query or migrate an avatar/camera. If the site Grid is reparented, the physics
bridge reseeds bodies from the new site-local hierarchy. An unstepped body
retains its authored local linear/angular velocity; integrated state is
transported from the previous frame. A frame switch without reparenting
transports the existing physics pose and velocity. Verify the
`authored_initial_velocity` production scene gate rather than adding a delayed
velocity write or a direction correction. The avatar subsystem captures a loader-relative local-camera pose
after USD projection has committed and applies it at the explicit scene-handoff
boundary. All explicit camera frame changes stay with the camera subsystem
through the same atomic migration helper. For a physical entity, keep it under
`ActivePhysicsFrame` and let
`BigSpacePhysicsBridgePlugin` own the Avian f64 pose exchange. The shared
`SimulationPoseQuery` (or immutable `SimulationPoseReadState` for API readers)
uses the physics gate's World-owned query metadata. Borrow a short API
`try_new(world)` lease, call `pose(entity)` or `position(entity)`, then release
it before any World mutation or nested pose query. A missing or busy lease
is unavailable and must retain the caller's diagnostic boundary. No sampled
poses are cached. The shared reader
composes mounts from their nearest seeded rigid body's native pose. Reuse that
boundary for physical consumers, including mounted probes; do not compose
through the body's presentation `Transform`. An unseeded parent makes a mount
unavailable. A cached mounted field must also invalidate on ancestor native
motion, hierarchy edits and pose-readiness withdrawal, even when its own local
transform is unchanged. Analytical providers use `PrescribedSimulationPose` in
the active frame, stamped with the admitted cycle tick; pending, stale, invalid
or mixed native/prescribed ownership must stay unavailable. Directions and
physical solar visibility use this same reader for probe and provider poses.
The shared
`lunco-physics::avian_backend` contract owns numeric backend admission; the
force transaction uses typed `lunco-spatial::coords::GridPos` contact points and
keeps body-local forces local through native substeps. Its read/admit/apply
boundary checks actual mass/inertia-scaled native accumulation before mutation.
The
bridge owns lifecycle admission and raises the runtime fault when changed poses
or collider AABBs are invalid. It gates the nested physics phases before Avian
grows AABBs or runs a query; `GridSpatialQuery` reuses the same point check
after conversion. Keep the evidence layers separate: malformed composed USD
transforms fail during projection, mutable runtime pose/AABB failures raise
`RuntimeFaults` plus `PhysicsHolds::SAFETY_FAILURE`, and invalid public query
origins return no hit without becoming a simulation fault. Use the existing
bridge and scene-teardown tests for the first two, and a production Rhai scene
test for the public query contract; do not add a second per-producer filter.
Collider insertion preserves constructor geometry; `GlobalTransform` cannot
choose physical scale. Rootless collider propagation runs in native fixed
preparation before scale cooking and mass reduction, so the first solver step
and later scale edits consume the current geometry and COM together.
For planetary flight, a projected `SiteAnchor` declares an
`UnboundedPhysicsDomain` on the active grid: resident terrain bounds must not
become a flight ceiling. BigSpace already recenters Grid-direct entities;
verify the bridge preserves native pose, velocity and joints across that split.
Use atomic grid migration only for actual frame changes. The body-demanded
globe contact cover is independent of camera residency and shares the f64
globe/collar geometry and datum with rendering. Before off-crop contact,
`globe-collision-ready` must clear with native support admitted. Never enable
the celestial picking sphere as terrain or add a second ground clamp. Run the
authored `planetary_flight_surface` and bounded `escape_containment` gates.
For a line joining two frames, convert both endpoints into one semantic frame
before generating cell-local geometry. For authored motion directly beneath a
BigSpace `Grid`, use standard USD `double3 xformOp:translate` samples and split
the f64 position with `Grid::translation_to_grid` before writing the local
`Transform`. Unbound samples use `SimulationPresentationTime`, which stays
between completed physical ticks and holds while transport is paused. The same
snapshot drives physical easing before camera follow. Compare native motion,
rendered motion and that sample when diagnosing jitter: readiness transitions
must not rewind the presentation cursor. Celestial physical providers still
read their exact tick clock; celestial rendering keeps its separate scaled
`CelestialTime` sample. Do not
introduce a mission-specific trajectory component or independent clock for
motion already represented by USD animation.

Celestial body ephemerides are not ordinary USD animation: body frames,
rotation, irradiance, shadows and the sky readout use the same celestial
affine child of the tick root. Physical providers evaluate
`CelestialClock::epoch_at_tick` at interval start before integration and at
endpoint after native writeback; initialization uses the current boundary.
Rendering consumes the `CelestialTime` snapshot under its angular error budget.
The domain can be rate-scaled up to 100,000× without changing Avian's fixed
physics cadence. Never let a presentation solve gate choose Modelica inputs.
From a lunar surface, Earth stays near one sky position because the Moon is
tidally locked; expect libration, while Earth's single body-fixed grid
continues to rotate for the day/night cycle. At 100,000×, a lunar month takes
about 24 seconds. Test both the parent-relative `CellCoord`/`Transform` and the
BigSpace-propagated `GlobalTransform`; local transform checks alone do not
prove a rendered pose reached its consumer. The celestial cadence commits the
`CelestialTime` sample it gated, and advances body position and spin together.

UTC text input requires a complete ISO 8601 date and time, for example
`2026-10-24T12:30:00.000Z`. `lunco-time` delegates parsing, leap-second checks,
time-scale conversion and formatting to native Celestial. Propagate conversion
errors to the clock UI or scene-time policy; never substitute another scale's
Julian date. An authored scene epoch remains usable when the computer-clock
candidate is unavailable. Run `test_hook_policies.rhai` for both candidate and
error paths, and `authored_initial_velocity` for site-frame admission.

For the local kinematic avatar, use the existing Avian `MoveAndSlide` query in
`ActivePhysicsFrame`: convert the source Grid pose, displacement, and up vector
with `grid_transform_between_grids`, perform one shape move, and convert the
solved pose back before `Grid::translation_to_grid`. The avatar is a camera
embodiment, so do not invent a USD body schema or read `GlobalTransform` as its
collision authority. This path preserves the fixed solver/substep contract.

For orbital camera views, keep presentation state on the avatar in
`OrbitViewHistory`, keyed by the stable celestial ephemeris id. Capture a
user-controlled `OrbitCamera` pose before switching focus targets and restore
it only for an explicit focus change to that same body. Every surface-to-orbit
scroll entry derives its arrival from the live camera position after resolving
the target's inertial BigSpace grid. Do not use saved history for scroll transit,
a fixed world-axis/Sun-facing arrival, a scene-wide pose cache, or a second
transform writer. Clear this transient history with active-Twin teardown and
avatar demotion.

Orbital pointer response is a generic camera setting. The camera runtime scales
angular input from clearance above `CelestialBody.radius_m`, using the persisted
`orbit_surface_min_scale`, `orbit_look_altitude_curve_exponent`, and
`orbit_look_full_speed_altitude_m` values. Tune them through `SetCameraInput`
or Rhai's `set_camera_input(...)`; keep the continuous height curve in the
camera runtime rather than adding body-specific policy. Returning to the saved
local camera view uses `orbit_return_transition_duration_s` and a smooth
render-clock arc through the saved grid; the transition owns the pose until it
restores the saved camera behavior at the destination.

When an orbital view must frame a mission site, publish the scene's valid
`SiteAnchor` position transformed into the body's inertial grid as a typed f64
vector. This location belongs to the scene frame and does not depend on a
possessed vehicle. Show the mission-site action as its own HUI card, apart from
the mode selector. Rhai computes the orbit angles, reads the persisted
`CameraInputSettings.orbit_direction_animation_duration_s` property, and sends
the generic `AnimateOrbitCameraDirection` command. The camera transition moves
along the current orbit without changing its radius or vertical offset; the
orbit writer commits each BigSpace pose and refreshes the orbital pin. Direct
user look input cancels the transition. Surface/orbit transitions use the
persisted `CameraInputSettings.surface_mode_engage_altitude_m` property as the
shared engage altitude and orbital zoom floor (1,000 m by default). Clearance
uses sampled local DEM terrain where the active terrain covers the camera and
the body's reference radius outside that coverage. Its companion
`surface_mode_disengage_altitude_m` property provides hysteresis and defaults
to 2,000 m under the same rule.

For transform gizmos, use `transform-gizmo-bevy` only as a render-space
frontend on an unparented proxy. Capture through `SimulationPoseQuery`, keep
the proposed pose in the explicit `ActivePhysicsFrame`, convert the complete
pose back with the canonical render/grid and parent-local helpers, and commit
through one `TransformEntity` scene command. Never apply render deltas to a
parent-local `Transform`, read `GlobalTransform` as physics authority, or write
Avian `Position`/`Rotation` from editor code. Reproject from the active-frame
transaction pose after BigSpace origin/cell changes. Because the frontend writes
its final proxy pose in `Last` after the normal interaction transfer in
`PostUpdate`, snapshot that final pose in `Last` before release cleanup. USD
preview scale is authored through `UsdOp::SetScale`; live scale remains outside
the physics contract.

For USD geometry, `xformOpOrder` is the authoritative ordered transform stack.
Read the complete composed local transform through the shared USD transform
decoder, including scale; do not inspect individual `xformOp:*` attributes in a
second path.

For a new top-level scene or runtime spawn, convert the semantic f64 pose into
the scene root's parent-local representation with
`pose_in_grid_to_parent_storage`. The direct Grid child receives the returned
`CellCoord` and local `Transform`; do not attach the rover under a terrain
mesh or write a large parent-local f32 value with a zero cell.

For Rhai scene tools, use the shared pointer coordinate contract. Rust converts
the picking backend's `RenderPos` exactly once through the admitted
`ActivePhysicsFrame`; the context exposes `world_position` as a tagged
`point3` in `active_physics` and `render_position` as a tagged `render` point.
Use the prelude helpers `point3`, `world_point`, `point_values`, `point_frame`,
`point_delta`, `point_distance`, `point_offset`, and `pointer_point`. Never
author from the render point, subtract raw arrays from points in another frame,
or silently use the persistent world grid when the active nested site frame is
unavailable. `pointer_point` is the user-facing failure boundary: it returns an
explicit error for a missing hit or frame rather than an identity/floating-origin
fallback. This keeps all screen tools—terrain, route, gizmo, and future tools—on
one conversion owner. Scene-tool behavior must consume the generic
`context.pointer_intents`/`pointer_intent(context, name)` surface from the
shared input settings; do not encode Alt, Shift, Ctrl, or mouse-button meaning
inside a route or terrain tool. This keeps remapping a settings change while
the coordinate conversion remains owned by the Rust frame adapter.

For waypoint labels, author `lunco:billboard*` on the waypoint and let the
generic billboard renderer consume its propagated `GlobalTransform`. The
renderer uses the shared BigSpace world-pose machinery for the camera/subject
range check; route projection does not add another distance or coordinate
conversion owner. The terrain-grid/BigSpace hierarchy and the existing
billboard path already own that conversion. The shared overlay wraps labels to a
bounded width, clamps their backdrop inside the active viewport, and gives
nearer labels first choice of non-overlapping camera-facing slots. A label with
no safe slot is omitted for that frame rather than covering another marker.
Editor-created waypoints use the canonical USD billboard authoring helper;
runtime-only waypoints attach the same `UsdBillboard` data plus the generic
`BillboardIndex` fact to the shared marker root. Keep both paths on this one
renderer; do not overwrite `Name` or add a waypoint-specific overlay.

For physics and co-simulation, resolve a demanded direction target from its
simulation pose into each `EnvironmentProbe` frame through the shared
`SimulationPoseQuery`. Normalize the displacement once into `UnitDirection3`;
frame rotations preserve that unit vector. The USD wire selects the source id,
while the consumer model uses a generic target-direction input. `SunState`
contains solar irradiance only. A static `DistantLight` contributes a framed
ray through the same resolver only after composed-root celestial-source
classification confirms that no finite celestial target owns `sun`. Celestial
roots use their finite body target exclusively, and a prior static ray is
withdrawn before probe resolution. Do not add per-body conversion systems,
another coordinate cache, or a local solar clock.
Invalid input bindings may withhold the optional observer camera, but cannot
block creation of celestial targets used by the direction resolver.

Publish `SunRenderState` from the finalized scene-sun `GlobalTransform` after
`BigSpaceSystems::PropagateLowPrecision`. Any conversion of that render
direction through a terrain `GlobalTransform` belongs after that phase in `PostUpdate`:
static material wiring, horizon-cache validity/bake decisions, and
streamed-tile shadow intent binding all consume that finalized frame. Put
streamed-tile binding in the public `TerrainSurfaceSet::RenderShadowBinding`
phase so it cannot observe a previous-frame terrain transform. Do not repair a
stale projection with an offset or another per-frame transform writer. The
projection is change-gated by the selected source revision and changed BigSpace
ancestor chains, so stable frames do not rebuild f64 poses.

Native directional cascades take their sampling frame from the receiving
view’s BigSpace grid. The camera’s selected Graphics profile controls edge
filtering. Compare fractional shadow coordinates at a fixed physical receiver
across a celestial seek to measure drift. Compare a diagonal shadow edge at a
fixed epoch to evaluate spatial filtering. See
`docs/architecture/render-decoupling.md#directional-shadow-reference-frames`.

## Do not patch symptoms

Do not add a per-frame position correction, a fallback frame, a guessed parent,
an epoch-specific offset, a raw f32 absolute position, or a second transform
writer. Those hide the ownership error and will reappear at a grid boundary or
view transition.

## Required tests

Add the smallest real regression at the owning boundary:

- frame index rejects missing and duplicate semantic grids;
- f64 pose conversion round-trips position and rotation;
- atomic migration preserves the pose across a cell boundary;
- the Avian bridge is invariant to BigSpace re-splitting and celestial-parent
  rotation;
- surface ↔ inertial camera transfer preserves target pose and up direction;
- per-avatar orbital history restores independent body poses and clears with
  active-Twin teardown;
- the selected camera projects through the persistent `WorldGrid` into the sole
  `OriginAnchor`, while duplicate or missing world-shell entities fail closed.
- a standard render camera receives the selected Graphics filter at admission;
  fast mode remains unlit and does not attach it.

Run focused checks first:

```sh
scripts/run_rust_tests.sh -p lunco-core --lib -j 4
scripts/run_rust_tests.sh -p lunco-celestial -j 4
scripts/run_rust_tests.sh -p lunco-usd-avian -j 4
RUSTC_WRAPPER= cargo build -p lunco-luncosim --bin luncosim -j 4
```

For visual acceptance, launch the built production binary head-full with an
explicit free API port, inspect surface and inertial views, then send the API
`Exit` command and verify the process and port are gone. Use `--no-ui` only for
headless deterministic checks.

## Vessel follow policies and live tuning

Use `SetCameraFollow` to tune an existing local spring arm atomically; it does
not rebind possession. `camera.follow` exposes subject identity, authored follow
mode, grid-frame orientation, body-frame motion, rig settings and obstruction
facts to a Twin-scoped Rhai policy. Return presentation decisions, including
interpolation weights, rather than writing private spatial state. Rust retains
frame conversion and collision ownership. The spring arm checks both scene
colliders and the analytic DEM in the active physics frame, since the collider
ring does not cover a long boom. A policy can choose offsets and easing
per vessel without a Rust vessel-type dispatch. See
[the camera follow contract](../../docs/architecture/camera-follow-policy.md).

Free-flight movement, scroll transit and follow booms sweep a lens-centred sphere
against the full composed terrain in the active physics frame and shape-cast
native props. Borrow the vessel filter for follow casts and check native DEM
membership on each broad-phase candidate through the terrain query. Cast the
physical radius and apply skin as a directional contact pullback. An enlarged
collision shell can block clear tangent departure. Recast every
projected slide against all sources and props. Source-safe travel also checks the retained presented mesh, stitch and
morph context. Pending geometry holds the pose and requests refinement; invalid
geometry or exhausted capacity rejects motion visibly. Lateral input adds no
automatic upward step; contact-plane sliding follows actual source/prop contacts.
The Twin's explicit through-soil opt-out retains its
existing owner. Read the reflected `CameraCollisionEnvelope` to measure clearance.

Verify changes with physics held: live distance/height/angle/mode updates,
invalid-batch rejection without partial mutation, policy fault/diagnostic/recovery,
and unchanged simulation tick. Exercise the native switch-mode intent (default V)
and any vehicle key that previously conflicted (C is not reserved by cameras).
Inspect crest and flight captures; a passing driving verdict does not establish
camera visibility or camera-frustum clearance.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.