mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
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:
1 parent
7a376ebefc
commit
c8346c9fda
44 files changed
+810
-799
No files matched your search
@@ -6,6 +6,12 @@
|
||||
* reference recorder's own.
|
||||
*/
|
||||
import { wheelLines } from '../input/wheel.js';
|
||||
import {
|
||||
eyeMoved,
|
||||
eyeRotatedAbout,
|
||||
eyeTurned,
|
||||
eyeZoomed,
|
||||
} from '../../geo/eyeMoves.js';
|
||||
|
||||
const NO_MODIFIERS = Object.freeze({
|
||||
shift: false,
|
||||
@@ -187,6 +193,18 @@ function resolveArgs(driver, name, args) {
|
||||
return args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Script steps that are the app's own sums over the pose, not port verbs: the
|
||||
* contract driver turns them into `setView`, where the reference recorder
|
||||
* runs Cesium's matching camera functions.
|
||||
*/
|
||||
const EYE_STEPS = {
|
||||
move: eyeMoved,
|
||||
look: eyeTurned,
|
||||
rotateAround: eyeRotatedAbout,
|
||||
zoom: eyeZoomed,
|
||||
};
|
||||
|
||||
/**
|
||||
* A driver over a renderer, through the contract only.
|
||||
* @param {import('../contract/renderer').Renderer} renderer
|
||||
@@ -200,6 +218,8 @@ export function contractDriver(renderer, hooks) {
|
||||
const camera = renderer.camera;
|
||||
return {
|
||||
command(name, args) {
|
||||
if (Object.hasOwn(EYE_STEPS, name))
|
||||
return camera.setView(EYE_STEPS[name](camera.pose(), ...args));
|
||||
return camera[name](...args);
|
||||
},
|
||||
frame: hooks.frame,
|
||||
|
||||
@@ -253,7 +253,7 @@ export const CAMERA_SCRIPTS = Object.freeze([
|
||||
},
|
||||
{ do: 'move', args: ['forward', 500] },
|
||||
{ record: 'pose' },
|
||||
{ do: 'rotateAround', args: [{ x: 0, y: 0, z: 1 }, 0.4] },
|
||||
{ do: 'look', args: ['left', 0.4] },
|
||||
{ record: 'pose' },
|
||||
{ do: 'zoom', args: [-1000] },
|
||||
{ record: 'pose' },
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
} from '../cameraScripts.js';
|
||||
import { contractDriver, runCameraScript } from '../cameraRunner.js';
|
||||
import { deepEqual, equal, near, nearAngle, nearVec, ok } from '../expect.js';
|
||||
import { eyeMoved } from '../../../geo/eyeMoves.js';
|
||||
|
||||
const lonLatToEcef = (h) => h.toEcef;
|
||||
|
||||
@@ -389,7 +390,7 @@ export function cameraChecks() {
|
||||
r.camera.on('moveEnd', () => events.push(['end', h.now(r)]));
|
||||
await h.frame(r);
|
||||
const movingAt = h.now(r);
|
||||
r.camera.move('forward', 1000);
|
||||
r.camera.setView(eyeMoved(r.camera.pose(), 'forward', 1000));
|
||||
await h.frame(r);
|
||||
equal(events[0]?.[0], 'start', 'moveStart after the move');
|
||||
const movedAt = h.now(r);
|
||||
|
||||
@@ -1714,7 +1714,7 @@ export function portChecks() {
|
||||
},
|
||||
),
|
||||
check(
|
||||
'draw.lines.depthFailDash',
|
||||
'draw.lines.depthFail',
|
||||
'a line dashed behind the surface draws, moves in place and changes back to solid',
|
||||
async (h, r) => {
|
||||
await overAustin(h, r);
|
||||
@@ -1727,8 +1727,7 @@ export function portChecks() {
|
||||
widthPx: 3,
|
||||
mode: 'geodesic',
|
||||
style: { kind: 'dash', color: [1, 1, 0, 0.9], length: 16 },
|
||||
depthFailColor: [0, 1, 1, 0.35],
|
||||
depthFailDash: { length: 16 },
|
||||
depthFail: { kind: 'dash', color: [0, 1, 1, 0.35], length: 16 },
|
||||
...extra,
|
||||
});
|
||||
lines.set([band(-200)]);
|
||||
@@ -1737,7 +1736,9 @@ export function portChecks() {
|
||||
lines.upsert([band(-100)]);
|
||||
await drawn(h, r);
|
||||
equal(lines.size(), 1, 'moved in place, not added');
|
||||
lines.upsert([band(-100, { depthFailDash: undefined })]);
|
||||
lines.upsert([
|
||||
band(-100, { depthFail: { kind: 'solid', color: [0, 1, 1, 0.35] } }),
|
||||
]);
|
||||
await drawn(h, r);
|
||||
equal(lines.size(), 1, 'solid behind the surface again');
|
||||
lines.dispose();
|
||||
@@ -1877,24 +1878,21 @@ export function portChecks() {
|
||||
},
|
||||
),
|
||||
check(
|
||||
'draw.shapes.radiusByCameraHeight',
|
||||
'a clamped ellipse with radii by camera height draws at the radius the camera height gives, held within its bounds, and follows the camera',
|
||||
'draw.shapes.resize',
|
||||
'a clamped ellipse whose radius alone is upserted draws at the new radius, growing and shrinking',
|
||||
async (h, r) => {
|
||||
const shapes = r.draw.shapes({ id: 'conf:rings' });
|
||||
const radius = { byCameraHeight: { factor: 0.1, min: 50, max: 600 } };
|
||||
shapes.set([
|
||||
{
|
||||
id: 'ring',
|
||||
geometry: {
|
||||
kind: 'ellipse',
|
||||
center: { lon: AUSTIN.lon, lat: AUSTIN.lat },
|
||||
semiMajor: radius,
|
||||
semiMinor: radius,
|
||||
},
|
||||
fill: [0.5, 0.9, 1, 0.6],
|
||||
height: 'clampGround',
|
||||
const ring = (radius) => ({
|
||||
id: 'ring',
|
||||
geometry: {
|
||||
kind: 'ellipse',
|
||||
center: { lon: AUSTIN.lon, lat: AUSTIN.lat },
|
||||
semiMajor: radius,
|
||||
semiMinor: radius,
|
||||
},
|
||||
]);
|
||||
fill: [0.5, 0.9, 1, 0.6],
|
||||
height: 'clampGround',
|
||||
});
|
||||
// Metres east of the centre, at its latitude.
|
||||
const east = (m) =>
|
||||
h.toEcef({
|
||||
@@ -1919,22 +1917,19 @@ export function portChecks() {
|
||||
}
|
||||
return false;
|
||||
};
|
||||
// 2000 m up: 200 m across its centre.
|
||||
await overAustin(h, r, 2000);
|
||||
ok(await until(() => covers(150)), 'at 2000 m it reaches 150 m');
|
||||
ok(!covers(260), 'and not 260 m');
|
||||
// 4000 m up: 400 m.
|
||||
await overAustin(h, r, 4000);
|
||||
shapes.set([ring(200)]);
|
||||
ok(
|
||||
await until(() => covers(150) && !covers(260)),
|
||||
'at 200 m it reaches 150 m, not 260 m',
|
||||
);
|
||||
shapes.upsert([ring(400)]);
|
||||
ok(
|
||||
await until(() => covers(300) && !covers(460)),
|
||||
'at 4000 m it reaches 300 m, not 460 m',
|
||||
);
|
||||
// 20 km up: held at 600 m.
|
||||
await overAustin(h, r, 20000);
|
||||
ok(
|
||||
await until(() => covers(550) && !covers(700)),
|
||||
'held at its largest',
|
||||
'at 400 m it reaches 300 m, not 460 m',
|
||||
);
|
||||
shapes.upsert([ring(200)]);
|
||||
ok(await until(() => covers(150) && !covers(260)), 'back at 200 m');
|
||||
shapes.dispose();
|
||||
await drawn(h, r);
|
||||
ok(!covers(0), 'gone with its set');
|
||||
@@ -1961,7 +1956,7 @@ export function portChecks() {
|
||||
widthPx: 3,
|
||||
mode: '3d',
|
||||
style: { kind: 'solid', color: '#ff00ff' },
|
||||
depthFailColor: [1, 0, 1, 0.45],
|
||||
depthFail: { kind: 'solid', color: [1, 0, 1, 0.45] },
|
||||
});
|
||||
lines.set([
|
||||
{
|
||||
|
||||
@@ -1117,29 +1117,29 @@
|
||||
"kind": "pose",
|
||||
"value": {
|
||||
"position": {
|
||||
"x": -744971.9139187913,
|
||||
"y": -5464375.678277303,
|
||||
"z": 3195735.7092693974
|
||||
"x": -744481.3426810508,
|
||||
"y": -5464789.733339174,
|
||||
"z": 3195145.9335938734
|
||||
},
|
||||
"direction": {
|
||||
"x": 0.8577979868850266,
|
||||
"y": 0.50373228948861,
|
||||
"z": 0.10215867179324013
|
||||
"x": 0.3312543721140628,
|
||||
"y": 0.7819390858650948,
|
||||
"z": 0.5280547385941896
|
||||
},
|
||||
"up": {
|
||||
"x": 0.33601932677210566,
|
||||
"y": -0.6999992672201266,
|
||||
"z": 0.6301523926217426
|
||||
"x": 0.22881921132251012,
|
||||
"y": -0.6095195427272047,
|
||||
"z": 0.7590307606173572
|
||||
},
|
||||
"right": {
|
||||
"x": 0.38893910285752537,
|
||||
"y": -0.5062161657018166,
|
||||
"z": -0.7697217470297525
|
||||
"x": 0.915375501903488,
|
||||
"y": -0.13060318920332545,
|
||||
"z": -0.38082869834724636
|
||||
},
|
||||
"heading": 1.099821436536688,
|
||||
"pitch": -0.5003437292588502,
|
||||
"roll": 6.283185070682873,
|
||||
"height": 1198.9411841126202,
|
||||
"heading": 0.25083973344668564,
|
||||
"pitch": -0.45766939657173955,
|
||||
"roll": 0.20978125179289364,
|
||||
"height": 1198.941902759726,
|
||||
"frameIsIdentity": false
|
||||
}
|
||||
},
|
||||
@@ -1148,29 +1148,29 @@
|
||||
"kind": "pose",
|
||||
"value": {
|
||||
"position": {
|
||||
"x": -745829.7119056764,
|
||||
"y": -5464879.410566793,
|
||||
"z": 3195633.5505976044
|
||||
"x": -744812.5970531654,
|
||||
"y": -5465571.672425042,
|
||||
"z": 3194617.878855279
|
||||
},
|
||||
"direction": {
|
||||
"x": 0.8577979868850265,
|
||||
"y": 0.5037322894886102,
|
||||
"z": 0.10215867179324012
|
||||
"x": 0.33125437211406306,
|
||||
"y": 0.7819390858650948,
|
||||
"z": 0.5280547385941895
|
||||
},
|
||||
"up": {
|
||||
"x": 0.33601932677210533,
|
||||
"y": -0.6999992672201268,
|
||||
"z": 0.6301523926217425
|
||||
"x": 0.22881921132251018,
|
||||
"y": -0.6095195427272047,
|
||||
"z": 0.7590307606173573
|
||||
},
|
||||
"right": {
|
||||
"x": 0.3889391028575255,
|
||||
"y": -0.5062161657018166,
|
||||
"z": -0.7697217470297526
|
||||
"x": 0.9153755019034878,
|
||||
"y": -0.1306031892033257,
|
||||
"z": -0.38082869834724653
|
||||
},
|
||||
"heading": 1.0997500524431754,
|
||||
"pitch": -0.5004811848386681,
|
||||
"roll": 6.283184976084162,
|
||||
"height": 1678.7289113419563,
|
||||
"heading": 0.2508194571959139,
|
||||
"pitch": -0.45781035725623687,
|
||||
"roll": 0.20978111856887782,
|
||||
"height": 1640.8642564622487,
|
||||
"frameIsIdentity": false
|
||||
}
|
||||
},
|
||||
@@ -1179,29 +1179,29 @@
|
||||
"kind": "pose",
|
||||
"value": {
|
||||
"position": {
|
||||
"x": -745829.7119056764,
|
||||
"y": -5464879.410566793,
|
||||
"z": 3195633.5505976044
|
||||
"x": -744812.5970531654,
|
||||
"y": -5465571.672425042,
|
||||
"z": 3194617.878855279
|
||||
},
|
||||
"direction": {
|
||||
"x": 0.8577979868850266,
|
||||
"y": 0.5037322894886103,
|
||||
"z": 0.1021586717932402
|
||||
"x": 0.3312543721140633,
|
||||
"y": 0.7819390858650948,
|
||||
"z": 0.5280547385941896
|
||||
},
|
||||
"up": {
|
||||
"x": 0.33601932677210533,
|
||||
"y": -0.6999992672201268,
|
||||
"z": 0.6301523926217425
|
||||
"x": 0.22881921132251018,
|
||||
"y": -0.6095195427272047,
|
||||
"z": 0.7590307606173573
|
||||
},
|
||||
"right": {
|
||||
"x": 0.3889391028575255,
|
||||
"y": -0.5062161657018165,
|
||||
"z": -0.7697217470297525
|
||||
"x": 0.9153755019034878,
|
||||
"y": -0.13060318920332578,
|
||||
"z": -0.3808286983472466
|
||||
},
|
||||
"heading": 1.0997500524431754,
|
||||
"pitch": -0.5004811848386681,
|
||||
"roll": 6.283184976084162,
|
||||
"height": 1678.7289113419563,
|
||||
"heading": 0.2508194571959148,
|
||||
"pitch": -0.4578103572562373,
|
||||
"roll": 0.20978111856887693,
|
||||
"height": 1640.8642564622487,
|
||||
"frameIsIdentity": true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user