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

+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;