mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Tidy the vessels layer on the draw port: shared pose key, lazy pose, frame reasons, sprite order
The camera pose key moves to render/camera/poseSignature.js, Cesium-free, and iconOrientation's cameraPoseSignature builds the same key through it. The vessels frame hook reads the pose only when a pass runs or a moved camera could still need its trailing pass, and the unused focus scratch point goes. The draw port takes the frame port's requestRender, so a GPU icon set's own frames (its images packed into the atlas) are asked for under the reason icons:<set id> in the frame diagnostics, where the vessels layer's own ais-vessels-icons reason used to be. Other draw requests are unchanged. A host with no registerSpriteSet still draws the ships and warns once. The vessels draw test now checks the sprite order finds the set's host, and that a torn-down layer draws a new set registered in the old one's place. The new motion, icon book and pose key tests join the format check.
This commit is contained in:
1 parent
7a9c7b4d96
commit
1c8cf240c4
14 files changed
+334
-76
No files matched your search
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @module render/camera/poseSignature
|
||||
* @description A cheap "did the camera move" key for gating passes that
|
||||
* depend on the view: the eye's ECEF position to 10 m and its heading, pitch
|
||||
* and roll (radians) to a milliradian. It takes a camera port pose or any
|
||||
* `{position, heading, pitch, roll}`, so a renderer's own camera reads the
|
||||
* same key.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {{position: {x: number, y: number, z: number}, heading: number,
|
||||
* pitch: number, roll: number}} pose
|
||||
* @returns {string}
|
||||
*/
|
||||
export function poseSignature(pose) {
|
||||
const p = pose.position;
|
||||
return (
|
||||
`${Math.round(p.x / 10)}:${Math.round(p.y / 10)}:${Math.round(p.z / 10)}:` +
|
||||
`${pose.heading.toFixed(3)}:${pose.pitch.toFixed(3)}:${pose.roll.toFixed(3)}`
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import test from 'node:test';
|
||||
import { cameraPoseSignature } from '../../data/iconOrientation.js';
|
||||
import { poseSignature } from './poseSignature.js';
|
||||
|
||||
const pose = {
|
||||
position: { x: 3_975_123.4, y: 289_456.7, z: 4_998_765.1 },
|
||||
heading: 1.23456,
|
||||
pitch: -0.7071,
|
||||
roll: 0.0004,
|
||||
};
|
||||
|
||||
test('the pose key holds the eye to 10 m and its angles to a milliradian', () => {
|
||||
assert.equal(poseSignature(pose), '397512:28946:499877:1.235:-0.707:0.000');
|
||||
const near = {
|
||||
...pose,
|
||||
position: { ...pose.position, x: pose.position.x + 1 },
|
||||
heading: pose.heading + 0.0003,
|
||||
};
|
||||
assert.equal(poseSignature(near), poseSignature(pose), 'too small to move');
|
||||
assert.notEqual(
|
||||
poseSignature({ ...pose, pitch: pose.pitch + 0.002 }),
|
||||
poseSignature(pose),
|
||||
);
|
||||
});
|
||||
|
||||
test('a Cesium camera keys the same as the pose it reads', () => {
|
||||
const camera = {
|
||||
positionWC: pose.position,
|
||||
heading: pose.heading,
|
||||
pitch: pose.pitch,
|
||||
roll: pose.roll,
|
||||
};
|
||||
assert.equal(cameraPoseSignature(camera), poseSignature(pose));
|
||||
});
|
||||
|
||||
test('the pose key imports no renderer', () => {
|
||||
const source = readFileSync(
|
||||
new URL('./poseSignature.js', import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
assert.doesNotMatch(source, /from 'cesium'/);
|
||||
});
|
||||
Reference in new issue
Block a user