Read a moving icon's position and course through one shared evaluator

render/motion/iconMotion evaluates a draw item's motion segment and course
glide at a time on the set's motion clock, without a renderer: where the
item is drawn, the course it is drawn with, and when its motion ends. The app
can now read a moving icon back (to follow it, label it, judge a pick or
its horizon) the way the renderer draws it.

The stub renderer evaluates its segments with it, in place of its own copy,
and so now steps a lerp with no span 1 ms after t0, as the Cesium renderer
does. The Cesium GPU icon sets read the course shown before a write, a
blend's target and when rows stop moving through it, from copies of what
they wrote, and write each glide with the offset it computes, so an exact
half turn goes the way the app reads it.

norm360/norm180 and Position-to-ECEF move to geo for both to share.
Conformance gains a check that icons are drawn where the evaluator puts
them.
This commit is contained in:
Sameh Khamis committed 2026-11-07 02:36:39 -08:00
1 parent b774bd84c8
commit 0349941b71
14 files changed
+703 -105

No files matched your search

+1 -1
View File
@@ -13,7 +13,7 @@ import { horizonFrom } from '../../geo/horizon.js';
import { createInputRouter } from '../input/router.js';
import { CAPABILITIES, CONTRACT_VERSION } from '../contract/index.js';
import { createStubCamera } from './camera.js';
import { motionPosition } from './motion.js';
import { motionPosition } from '../motion/iconMotion.js';
import { orbitPosition } from './orbits.js';
import { computeViewRectangle } from './viewRectangle.js';
import {
+1 -7
View File
@@ -14,8 +14,6 @@ import {
clamp,
equalsEpsilon,
negate,
clone,
fromDegrees,
rotate,
scale,
vec,
@@ -25,11 +23,7 @@ import {
export * from '../../geo/index.js';
/** A contract `Position` (`Ecef` or `LonLatH`, degrees), as ECEF. */
export function toEcef(position) {
if ('lon' in position && 'lat' in position)
return fromDegrees(position.lon, position.lat, position.height ?? 0);
return clone(position);
}
export { positionToEcef as toEcef } from '../../geo/ellipsoid.js';
const EPSILON3 = 1e-3;
const EPSILON10 = 1e-10;
-57
View File
@@ -1,57 +0,0 @@
/**
* @module render/stub/motion
* @description Where a motion segment puts an icon at a time, exactly as
* the contract's `MotionSegment` describes it.
*/
import { add, eastNorthUp, scale, sub } from './math.js';
const STRAIGHT_RAD_PER_S = 1e-4;
/**
* @param {import('../contract/draw').MotionSegment} segment
* @param {{x: number, y: number, z: number}} pos The item's own position (for `hold`).
* @param {number} t Epoch ms on the set's motion clock.
* @returns {{x: number, y: number, z: number}}
*/
export function motionPosition(segment, pos, t) {
switch (segment.kind) {
case 'hold':
return pos;
case 'lerp': {
const span = segment.t1 - segment.t0;
const s =
span > 0
? Math.min(1, Math.max(0, (t - segment.t0) / span))
: t >= segment.t1
? 1
: 0;
return add(segment.from, scale(sub(segment.to, segment.from), s));
}
case 'arc': {
const dt = Math.min(
segment.maxDtS,
Math.max(segment.minDtS, (t - segment.t0) / 1000),
);
const track = (segment.trackDeg * Math.PI) / 180;
const w = (segment.turnRateDps * Math.PI) / 180;
const v = segment.speedMps;
let east;
let north;
if (Math.abs(w) < STRAIGHT_RAD_PER_S) {
east = v * dt * Math.sin(track);
north = v * dt * Math.cos(track);
} else {
east = (v / w) * (Math.cos(track) - Math.cos(track + w * dt));
north = (v / w) * (Math.sin(track + w * dt) - Math.sin(track));
}
const up = (segment.climbMps ?? 0) * dt;
const enu = eastNorthUp(segment.fix);
return add(
segment.fix,
add(add(scale(enu.x, east), scale(enu.y, north)), scale(enu.z, up)),
);
}
default:
throw new Error(`unknown motion segment ${segment.kind}`);
}
}