Renderer contract: model nodes behind a modelNodes capability, with a conformance check

ModelItem.nodes had no conformance check. A renderer that poses a model's
named glTF nodes now lists modelNodes (the Cesium port does); one without it
draws the model as authored. The check draw.models.nodes moves the harness
model's node off the screen's centre through nodes, live, ignores a name the
model lacks, and gives the node its authored pose back when it leaves the
map; it runs on the Cesium harness (141 passed, 0 failed) and on the stub,
whose model is one node named after its file. Each harness names its model's
node (assets.modelNode).
This commit is contained in:
Denis Groshev committed 2026-11-17 16:45:53 +01:00
1 parent 808941d973
commit 2c9a268694
12 files changed
+137 -4

No files matched your search

+42
View File
@@ -10,6 +10,7 @@
* loop on a virtual clock, one frame at a time, in the contract's order.
*/
import { horizonFrom } from '../../geo/horizon.js';
import { headingPitchRollFrame } from '../../geo/quaternion.js';
import { alongLength } from '../../geo/polyline.js';
import { clusterScreenPoints } from '../../geo/screenCluster.js';
import { createInputRouter } from '../input/router.js';
@@ -808,6 +809,7 @@ export function createStubRenderer(options = {}) {
function itemPosition(set, item, aheadMs = 0) {
if (!item.pos) return null;
const base = toEcef(item.pos);
if (set.kind === 'models') return posedModelPosition(item, base);
const p =
set.kind === 'icons' && item.motion && capabilities.has('motionSegments')
? motionPosition(item.motion, base, motionTime(set) + aheadMs)
@@ -821,6 +823,46 @@ export function createStubRenderer(options = {}) {
: p;
}
/**
* Where the stub draws a model. A stub model is one node, named after its
* file (`/models/c172.glb` is `c172`, `stub:model.glb` is `model`): with
* `modelNodes`, an item's
* `nodes` entry for that name moves it by the matrix's translation, on the
* model's axes and at its scale; any other name is one the model lacks.
*/
function posedModelPosition(item, base) {
if (!capabilities.has('modelNodes') || !item.nodes) return base;
const file = String(item.url ?? '')
.split(/[?#]/)[0]
.split(/[/:]/)
.pop();
const name = file.replace(/\.[^.]*$/, '');
const m = name ? item.nodes[name] : null;
if (!m || m.length < 16) return base;
const k = item.scale ?? 1;
const frame = headingPitchRollFrame(base, {
heading: item.orientation?.heading ?? 0,
pitch: item.orientation?.pitch ?? 0,
roll: item.orientation?.roll ?? 0,
});
const along = (axis, t) => ({
x: axis.x * t * k,
y: axis.y * t * k,
z: axis.z * t * k,
});
let p = base;
for (const [axis, t] of [
[frame.x, m[12]],
[frame.y, m[13]],
[frame.z, m[14]],
])
if (t) {
const d = along(axis, t);
p = { x: p.x + d.x, y: p.y + d.y, z: p.z + d.z };
}
return p;
}
/**
* The shown models as the stub draws them: a square as wide as a pick
* takes (at most `maxPixelSize`, at least `minPixelSize`), far