Keep shape radii, rim gradients, depth-fail looks, sweep cadence and step camera moves out of the renderer contract

Shapes take their radii in metres; the world annotation ring follows the
camera height itself (ringRadiusAt), resizing on preRender. The radial rim
preset and depthBias go: the launch pad zone draws a canvas image fill made
by the layer. Solid and dashed lines take one depthFail look (solid or
dash) in place of depthFailColor and depthFailDash. sonarCadenceHz goes from
the quality settings: nothing set it, and the sweep moves every 80 ms.

Camera move, look, rotateAround and zoom leave the camera port: the app's pans,
in-place turns, globe turns and zooms are setView views summed over the pose
(geo/eyeMoves), and the Cesium port places a view by direction and up
exactly rather than through heading, pitch and roll. The conformance driver
runs those script steps through setView; the lookAt script turns in place
where it turned about the frame-local axis, and its reference is recorded
again.
This commit is contained in:
Sameh Khamis committed 2026-11-10 04:08:41 -08:00
1 parent 7a376ebefc
commit c8346c9fda
44 files changed
+810 -799

No files matched your search

+4 -2
View File
@@ -32,7 +32,9 @@ function lineItemOf(handle) {
style: handle.dashed
? { kind: 'dash', color, length: 16, pattern16: 255 }
: { kind: 'solid', color },
depthFailColor: handle.depthFailColor ?? null,
depthFail: handle.depthFailColor
? { kind: 'solid', color: handle.depthFailColor }
: null,
meta: { cameraId: handle.cameraId },
show: handle.show !== false,
};
@@ -45,7 +47,7 @@ const lineKey = (item) =>
item.widthPx,
item.style.kind,
item.style.color.join(','),
item.depthFailColor ? item.depthFailColor.join(',') : '',
item.depthFail ? item.depthFail.color.join(',') : '',
item.show,
].join('|');
+2 -2
View File
@@ -39,7 +39,7 @@ test('lines are written as they change, and drawn as their handles say', () => {
widthPx: 1.2,
mode: 'geodesic',
style: { kind: 'solid', color: a.color },
depthFailColor: null,
depthFail: null,
meta: { cameraId: 'cam' },
show: true,
});
@@ -58,7 +58,7 @@ test('lines are written as they change, and drawn as their handles say', () => {
length: 16,
pattern16: 255,
});
assert.deepEqual(cap.depthFailColor, [1, 1, 1, 0.2]);
assert.deepEqual(cap.depthFail, { kind: 'solid', color: [1, 1, 1, 0.2] });
assert.equal(drawSets.roleOfSet(coverage.spec.id), 'coverage');
assert.equal(drawSets.roleOfSet('other:1:lines'), null);
+67 -11
View File
@@ -10,11 +10,69 @@ const ZONE_FILL_ALPHA = 0.105;
const ZONE_RIM_ALPHA = 0.72;
/** The rim's width, a fraction of the zone's radius. */
const ZONE_RIM_WIDTH = 0.033;
/** Where the zone's soft edge starts, a fraction of its radius. */
const ZONE_EDGE = 0.985;
/** How much brighter the rim glows than its colour. */
const ZONE_RIM_GLOW = 0.35;
/** The zone image's side, pixels. */
const ZONE_IMAGE_PX = 512;
const smoothstep = (edge0, edge1, x) => {
const t = Math.min(1, Math.max(0, (x - edge0) / (edge1 - edge0)));
return t * t * (3 - 2 * t);
};
/**
* Pulled toward the eye, metres, so the zone is not buried by the pad's
* mesh at oblique angles, without a height that would float it.
* The zone's colour and alpha at `r`, a fraction of its radius from its
* centre: the fill's colour, easing into the rim's (which glows a little)
* over `ZONE_RIM_WIDTH` just inside a soft edge, nothing past it.
* @param {number} r
* @returns {[number, number, number, number]} `r, g, b, a`, 0..1.
*/
const ZONE_DEPTH_BIAS_M = 1;
export function launchPadZoneColour(r) {
const [red, green, blue] = hexColor(ZONE_COLOR, 1);
const inside = 1 - smoothstep(ZONE_EDGE, 1, r);
const rim = smoothstep(ZONE_EDGE - ZONE_RIM_WIDTH, ZONE_EDGE, r) * inside;
const glow = 1 + ZONE_RIM_GLOW * rim;
return [
Math.min(1, red * glow),
Math.min(1, green * glow),
Math.min(1, blue * glow),
inside * (ZONE_FILL_ALPHA + (ZONE_RIM_ALPHA - ZONE_FILL_ALPHA) * rim),
];
}
/** The zone's image, made on first use; null where there is no 2D canvas. */
let zoneImage;
/**
* The zone as an image fill: `launchPadZoneColour` across a square canvas,
* its centre at the middle and its edge at the sides.
* @param {() => HTMLCanvasElement} [createCanvas]
* @returns {?{canvas: HTMLCanvasElement, key: string}}
*/
export function launchPadZoneImage(
createCanvas = () => globalThis.document?.createElement('canvas'),
) {
if (zoneImage !== undefined) return zoneImage;
const canvas = createCanvas();
const context = canvas?.getContext?.('2d');
if (!context) return (zoneImage = null);
canvas.width = ZONE_IMAGE_PX;
canvas.height = ZONE_IMAGE_PX;
const image = context.createImageData(ZONE_IMAGE_PX, ZONE_IMAGE_PX);
const half = ZONE_IMAGE_PX / 2;
for (let y = 0; y < ZONE_IMAGE_PX; y++)
for (let x = 0; x < ZONE_IMAGE_PX; x++) {
const r = Math.hypot(x + 0.5 - half, y + 0.5 - half) / half;
const colour = launchPadZoneColour(r);
const at = (y * ZONE_IMAGE_PX + x) * 4;
for (let k = 0; k < 4; k++)
image.data[at + k] = Math.round(colour[k] * 255);
}
context.putImageData(image, 0, 0);
return (zoneImage = { canvas, key: 'launch-pad-zone' });
}
export function createLaunchPad({
state: layerState,
@@ -39,9 +97,13 @@ export function createLaunchPad({
layerState._launchPadZoneLaunchId = null;
}
/** The zone drawn around a launch's pad, draped on the ground. */
/**
* The zone drawn around a launch's pad, draped on the ground (and on the
* pad's mesh); a plain fill where there is no canvas to draw it with.
*/
function createLaunchPadZonePrimitive(launch) {
removeLaunchPadZonePrimitive();
const image = launchPadZoneImage();
const item = {
id: `rocket-pad-zone:${launch.id}`,
geometry: {
@@ -50,15 +112,9 @@ export function createLaunchPad({
semiMajor: LAUNCH_PAD_ZONE_RADIUS_M,
semiMinor: LAUNCH_PAD_ZONE_RADIUS_M,
},
fill: {
preset: 'radialRim',
color: hexColor(ZONE_COLOR, ZONE_FILL_ALPHA),
rimColor: hexColor(ZONE_COLOR, ZONE_RIM_ALPHA),
rimWidth: ZONE_RIM_WIDTH,
},
fill: image ? { image } : hexColor(ZONE_COLOR, ZONE_FILL_ALPHA),
height: 'clampGround',
clampTo: 'both',
depthBias: ZONE_DEPTH_BIAS_M,
show: true,
};
layerState._launchPadZoneItem = item;
+2 -2
View File
@@ -477,8 +477,8 @@ test('the trail head runs from the last fix to the marker every frame, dimmed be
color: hexColor('#ff4fd8', 0.9),
});
assert.deepEqual(
head.depthFailColor,
hexColor('#ff4fd8', 0.45),
head.depthFail,
{ kind: 'solid', color: hexColor('#ff4fd8', 0.45) },
'dimmed, not hidden, behind the surface',
);
assert.equal(head.positions.length, 2);
@@ -481,7 +481,10 @@ test('tracking without a Cockpit subject keeps its marks', async (t) => {
/** A ring's drawn colour and behind-the-globe colour. */
function ringColors(f, id) {
const item = f.ring(id);
return { color: [...item.style.color], depthFail: [...item.depthFailColor] };
return {
color: [...item.style.color],
depthFail: [...item.depthFail.color],
};
}
test('a Cockpit subject dims every other orbit ring and restores it exactly', async (t) => {
@@ -506,7 +509,11 @@ test('a Cockpit subject dims every other orbit ring and restores it exactly', as
);
assert.equal(f.ring(ISS_NORAD).show, true, 'other rings stay visible');
assert.equal(f.ring(GPS).show, false, 'the ridden ring stays hidden');
assert.deepEqual(ringColors(f, GPS), gpsBuilt, 'the ridden ring is not dimmed');
assert.deepEqual(
ringColors(f, GPS),
gpsBuilt,
'the ridden ring is not dimmed',
);
// Other satellites' points stay as they are.
assert.equal(f.state._points.get(COMPANION).show, true);
+1 -1
View File
@@ -251,7 +251,7 @@ test('the rendering part draws the dots, the tracked dot and the rings through t
assert.equal(rings.spec.pickable, false, 'ring clicks fall through');
const ring = rings.items.get('25544');
assert.deepEqual(ring.style, { kind: 'solid', color: [1, 1, 0, 0.6] });
assert.deepEqual(ring.depthFailColor, [1, 1, 0, 0.35]);
assert.deepEqual(ring.depthFail, { kind: 'solid', color: [1, 1, 0, 0.35] });
assert.equal(ring.widthPx, 2.5, 'the ISS ring is wider');
assert.equal(ring.mode, 'geodesic');
assert.deepEqual([...ring.positions.slice(0, 3)], [7e6, 0, 0]);
+10 -7
View File
@@ -229,10 +229,10 @@ export function createRendering({
kind: 'solid',
color: withAlpha(path.color, RING_ALPHA * factor),
};
path.item.depthFailColor = withAlpha(
path.color,
RING_BEHIND_ALPHA * factor,
);
path.item.depthFail = {
kind: 'solid',
color: withAlpha(path.color, RING_BEHIND_ALPHA * factor),
};
sets?.rings.upsert([path.item]);
return true;
}
@@ -460,7 +460,7 @@ export function createRendering({
/**
* Show orbital path for a satellite: the ring over one orbit, baked once
* in ECEF at the current GMST, bright in front of the globe and dimmed
* behind it (`depthFailColor`), and turned with the Earth each
* behind it (`depthFail`), and turned with the Earth each
* `RING_ROTATION_MS` (`_updateOrbitPathRotations`).
*/
@@ -494,7 +494,10 @@ export function createRendering({
// Along the ellipsoid between samples, as the ring always ran.
mode: 'geodesic',
style: { kind: 'solid', color: withAlpha(pathColor, RING_ALPHA) },
depthFailColor: withAlpha(pathColor, RING_BEHIND_ALPHA),
depthFail: {
kind: 'solid',
color: withAlpha(pathColor, RING_BEHIND_ALPHA),
},
show: true,
};
layerState._orbitPaths.set(noradId, path);
@@ -521,7 +524,7 @@ export function createRendering({
*
* No SGP4 here: WGS84 is rotationally symmetric about Z, so rotating the
* baked curve rigidly equals rebaking from rotated points. A ring with a
* `depthFailColor` is built at once where it now runs, so it never blinks.
* `depthFail` style is built at once where it now runs, so it never blinks.
* @param {Date} nowDate Epoch used for current GMST.
*/