Merge origin/main into the renderer seam

Brings in main up to f24abfc88: cockpit subject providers, the render
failure notice, aircraft drawn in their own mesh colours, airport ground
vehicles, and an aircraft with no ground track facing its true heading.

Under the seam:
- The render failure notice lives in the Cesium adapter
  (src/render/cesium/renderFailure.js) and is the application hook
  renderFailureNotice({allowReload, store}); its private Cesium fields
  (Event's raise queue, the widget's render loop flag) are read through
  internals.js. The inline panel's timer waits while the frame port reports
  the loop stopped, and goes on after a Retry.
- Ordinary aircraft models draw white with the 'highlight' colour blend
  through the draw port; tracked and emergency colours tint the mesh.
- Held trains and transit vehicles hide their route set and markers through
  the draw port; the fleet model test fakes answer loads through the fake
  draw port instead of Cesium's glTF loader.
- The Cockpit's subject view follows and places the camera through the
  camera port.
This commit is contained in:
Sameh Khamis committed 2026-11-14 09:59:55 -08:00
commit 866a9816f2
142 files changed
+9067 -308

No files matched your search

+161 -4
View File
@@ -23,6 +23,8 @@ import {
import {
cockpitAnchorCorrectionStep,
cockpitGroundSafeHeight,
easeCockpitLift,
cockpitSubjectStepSec,
cockpitSurfaceWaitExpired,
cockpitUiUpdateDue,
slewHeading,
@@ -36,6 +38,7 @@ import {
waterlineProbePoints,
} from '../cockpitSubjects.js';
import { easeLook } from '../cockpitLook.js';
import { cockpitSubjectFrame } from '../cockpitSubjectProviders.js';
import {
COCKPIT_HEADING_SLEW_DPS,
COCKPIT_FORWARD_OFFSET_M,
@@ -84,6 +87,10 @@ export function update() {
}
const nowMs = performance.now();
if (this.subjectProvider) {
updateSubject.call(this, nowMs);
return;
}
if (this.subjectKind === 'vessel') {
updateVessel.call(this, nowMs);
return;
@@ -323,9 +330,122 @@ function updateVessel(nowMs) {
);
}
/**
* Drive the camera from an application provider's subject: read its frame,
* stand the eye `eye.upM` above `heightM` (the shared floor where the frame
* gives none) and slew toward its heading. A frame that is null, malformed or
* for another subject ends the view, as an aircraft tracked meanwhile does.
* The update runs on the provider's `cameraIntervalMs` (0: every frame), and
* its rates advance by the time that interval spans (cockpitSubjectStepSec).
*/
function updateSubject(nowMs) {
const provider = this.subjectProvider;
if (isFollowing(this.viewer)) {
this.exit({ restoreTracking: false });
return;
}
const intervalMs = provider.cameraIntervalMs ?? COCKPIT_CAMERA_UPDATE_MS;
if (!cockpitUiUpdateDue(nowMs, this.lastCameraUpdateMs, intervalMs)) return;
this.lastCameraUpdateMs = nowMs;
const frame = cockpitSubjectFrame(
this.callSubject(provider, 'read', [nowMs, this.subjectContext()], null),
this.subjectId,
);
if (!frame) {
this.exit({ restoreTracking: false });
return;
}
this.lastSubjectFrame = frame;
let heightM = frame.heightM;
if (heightM === null) {
this.services.warmGroundFloor?.([
{ lat: frame.latitude, lon: frame.longitude },
]);
const floorM = this.services.cachedGroundFloor?.(
frame.latitude,
frame.longitude,
);
// A frame with no height stands on the shared floor; while that is cold
// it keeps the height it last stood at.
heightM = Number.isFinite(floorM) ? floorM : this.subjectHeightM;
}
if (!Number.isFinite(heightM)) {
// Nothing to stand on yet, from the first frame: the camera stays where
// it is while the floor is acquired, its HUD saying so, rather than
// standing on the ellipsoid (kilometres underground on a plateau). The
// wait is bounded as the built-in views' is. Unlike a parked aircraft,
// whose fallback is its own reported altitude, such a subject has no
// height at all to fall back to: any number would be a guess, so the
// view ends and the provider gets its subject back.
if (!this.surfaceWaitStartedMs) this.surfaceWaitStartedMs = nowMs;
if (
cockpitSurfaceWaitExpired(
nowMs,
this.surfaceWaitStartedMs,
COCKPIT_GROUND_WAIT_TIMEOUT_MS,
)
) {
this.exit({ restoreTracking: false });
return;
}
this.surfaceAcquiring = true;
if (
cockpitUiUpdateDue(nowMs, this.lastHudUpdateMs, COCKPIT_HUD_UPDATE_MS)
) {
this.lastHudUpdateMs = nowMs;
this.updateHud(this.subjectInfo(frame), nowMs);
}
return;
}
this.surfaceWaitStartedMs = 0;
this.surfaceAcquiring = false;
this.subjectHeightM = heightM;
const target = fromDegrees(frame.longitude, frame.latitude, heightM);
const dtSec = cockpitSubjectStepSec(nowMs - this.lastFrameMs, intervalMs);
this.lastFrameMs = nowMs;
if (frame.headingDeg !== null) {
const rate = provider.headingSlewDps ?? COCKPIT_HEADING_SLEW_DPS;
this.heading =
rate === Infinity
? frame.headingDeg
: slewHeading(
this.heading ?? frame.headingDeg,
frame.headingDeg,
rate * dtSec,
);
}
let look = null;
if (provider.look) {
this.lookView = easeLook(
this.lookView,
this.lookTarget,
nowMs - (this.lookLastMs || nowMs),
);
this.lookLastMs = nowMs;
look = this.lookView;
}
placeCamera.call(
this,
target,
this.subjectInfo(frame),
nowMs,
dtSec,
{
forwardM: frame.eye.forwardM,
upM: frame.eye.upM,
pitchDeg: frame.eye.pitchDeg,
minClearanceM: frame.eye.minClearanceM,
},
look,
);
}
/**
* Place the camera for one update: advance the inertial anchor, clamp it and
* the eye against the rendered surface, and look along the slewed heading.
* A subject with `anchor: 'exact'` keeps the anchor on its target (its layer
* already moves it smoothly), and one with `groundClamp: false` (inside a
* structure, say) is never pushed up to the floor: a lift it had eases out.
* @param {{x: number, y: number, z: number}} target Authoritative subject position.
* @param {object} info Subject info; `motionCourse` (when present) is the
* direction the subject moves, otherwise it moves where it faces.
@@ -342,6 +462,7 @@ function placeCamera(target, info, nowMs, dtSec, profile, look = null) {
if (!this.cockpitAnchorValid) {
this.cockpitAnchor = clone(target);
this.cockpitAnchorValid = true;
this.subjectLiftM = null;
}
// First-person motion cannot use the delayed feed correction as a raw
@@ -363,7 +484,8 @@ function placeCamera(target, info, nowMs, dtSec, profile, look = null) {
? Math.max(0, info.velocityMps)
: 0;
if (info.stale) {
const groundClamp = info.groundClamp !== false;
if (info.stale || info.anchor === 'exact') {
// A feed backoff has no authoritative velocity epoch to advance from.
// Hold the cockpit on the exact layer-rendered position so the camera
// cannot coast away while the icon correctly remains fixed.
@@ -381,10 +503,13 @@ function placeCamera(target, info, nowMs, dtSec, profile, look = null) {
);
const correction = sub(target, this.cockpitAnchor);
const correctionDistanceM = magnitude(correction);
// An application subject's step is already bounded by its own update
// interval (cockpitSubjectStepSec); the built-in views keep the 0.1 s.
const correctionStepM = cockpitAnchorCorrectionStep(
correctionDistanceM,
speedMps,
dtSec,
info.generic === true ? dtSec : undefined,
);
if (correctionStepM > 0 && correctionDistanceM > 0) {
this.cockpitAnchor = add(
@@ -488,7 +613,14 @@ function placeCamera(target, info, nowMs, dtSec, profile, look = null) {
cockpitFloorM =
targetCartographic.height - this.services.GROUND_FLOOR_LIFT_M;
}
if (anchorCartographic && Number.isFinite(cockpitFloorM)) {
// An application subject's anchor is where its provider puts it; only its
// eye is kept out of the floor, below.
if (
groundClamp &&
info.generic !== true &&
anchorCartographic &&
Number.isFinite(cockpitFloorM)
) {
const minimumAnchorHeightM = cockpitGroundSafeHeight(
anchorCartographic.height,
cockpitFloorM,
@@ -536,7 +668,7 @@ function placeCamera(target, info, nowMs, dtSec, profile, look = null) {
// Recheck at the final forward-offset camera coordinate because a taxiing
// aircraft can cross into an adjacent coarse floor cell between updates.
const cameraCartographic = toCartographicRadians(eye);
if (cameraCartographic) {
if (groundClamp && cameraCartographic) {
const cameraLat = toDegrees(cameraCartographic.lat);
const cameraLon = toDegrees(cameraCartographic.lon);
const cameraFloorM = this.services.cachedGroundFloor(cameraLat, cameraLon);
@@ -546,11 +678,26 @@ function placeCamera(target, info, nowMs, dtSec, profile, look = null) {
cameraFloorM,
);
}
const safeHeightM = cockpitGroundSafeHeight(
let safeHeightM = cockpitGroundSafeHeight(
cameraCartographic.height,
cockpitFloorM,
profile.minClearanceM,
);
// An application subject's eye rides its provider's smoothed height:
// the clearance over the coarse, refining floor eases in and out
// rather than jumping at each cell (easeCockpitLift).
if (info.generic === true) {
const hardM =
cockpitGroundSafeHeight(cameraCartographic.height, cockpitFloorM, 0) -
cameraCartographic.height;
this.subjectLiftM = easeCockpitLift(
this.subjectLiftM,
safeHeightM - cameraCartographic.height,
hardM,
dtSec,
);
safeHeightM = cameraCartographic.height + this.subjectLiftM;
}
if (safeHeightM !== cameraCartographic.height) {
eye = fromRadians(
cameraCartographic.lon,
@@ -558,6 +705,16 @@ function placeCamera(target, info, nowMs, dtSec, profile, look = null) {
safeHeightM,
);
}
} else if (info.generic === true) {
// Inside a structure the floor holds the eye up no more: the lift it gave
// goes at the rate it came (easeCockpitLift), never at once.
this.subjectLiftM = easeCockpitLift(this.subjectLiftM, 0, 0, dtSec);
if (cameraCartographic && this.subjectLiftM > 0)
eye = fromRadians(
cameraCartographic.lon,
cameraCartographic.lat,
cameraCartographic.height + this.subjectLiftM,
);
}
cameraOf(this.viewer).setView({