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
@@ -8,29 +8,40 @@ import { bindRenderer } from '../render/rendererOf.js';
|
||||
import { fakeDrawPort } from '../testSupport/fakeDrawPort.mjs';
|
||||
import { createWorldAnnotationRenderer } from './worldAnnotationRenderer.js';
|
||||
|
||||
/** A viewer with a fake draw port, frame and query bound. */
|
||||
/**
|
||||
* A viewer with a fake draw port, frame, camera and query bound. The camera
|
||||
* stands at `camera.height`; `preRender()` runs the frame's preRender
|
||||
* listeners, `emit()` its postRender ones.
|
||||
*/
|
||||
function viewer(t, { heights = () => null } = {}) {
|
||||
const draw = fakeDrawPort();
|
||||
const frames = new Set();
|
||||
const before = new Set();
|
||||
const v = { requests: 0 };
|
||||
const frame = {
|
||||
on(phase, cb) {
|
||||
if (phase !== 'postRender') return () => {};
|
||||
frames.add(cb);
|
||||
return () => frames.delete(cb);
|
||||
const listeners =
|
||||
phase === 'postRender' ? frames : phase === 'preRender' ? before : null;
|
||||
if (!listeners) return () => {};
|
||||
listeners.add(cb);
|
||||
return () => listeners.delete(cb);
|
||||
},
|
||||
requestRender() {
|
||||
v.requests += 1;
|
||||
},
|
||||
};
|
||||
const camera = { height: 2000, pose: () => ({ height: camera.height }) };
|
||||
const query = { sampleHeightNow: (point) => heights(point) };
|
||||
const unbind = bindRenderer(v, { draw, frame, query });
|
||||
const unbind = bindRenderer(v, { draw, frame, query, camera });
|
||||
t.after(unbind);
|
||||
return {
|
||||
v,
|
||||
draw,
|
||||
frames,
|
||||
before,
|
||||
camera,
|
||||
emit: () => [...frames].forEach((cb) => cb()),
|
||||
preRender: () => [...before].forEach((cb) => cb()),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -213,9 +224,7 @@ test('every kind draws as it did: draped on terrain and tiles alike, rings by ca
|
||||
);
|
||||
|
||||
const [ring] = items(pin, 'shapes');
|
||||
assert.deepEqual(ring.geometry.semiMajor, {
|
||||
byCameraHeight: { factor: 0.03, min: 14, max: 170 },
|
||||
});
|
||||
assert.equal(ring.geometry.semiMajor, 60, '3% of the camera height');
|
||||
assert.equal(ring.geometry.semiMinor, ring.geometry.semiMajor);
|
||||
const [marker] = items(pin, 'points');
|
||||
assert.deepEqual(
|
||||
@@ -232,6 +241,67 @@ test('every kind draws as it did: draped on terrain and tiles alike, rings by ca
|
||||
renderer.destroy();
|
||||
});
|
||||
|
||||
test('target rings follow the camera height, sent again only when the radius changes, and catch up once shown', (t) => {
|
||||
const { v, draw, camera, preRender, before } = viewer(t);
|
||||
const renderer = createWorldAnnotationRenderer(v);
|
||||
const [, , pin] = marks();
|
||||
const other = { ...pin, id: 'pin2', anchor: { lat: 0.03, lon: 0.03 } };
|
||||
renderer.add(pin);
|
||||
renderer.add(other);
|
||||
const ringOf = (anno) =>
|
||||
setsOf(draw, anno)
|
||||
.find((r) => r.kind === 'shapes')
|
||||
.items.get('ring');
|
||||
// Writes to the rings' sets since they were drawn.
|
||||
const shapeSets = [pin, other].map((anno) =>
|
||||
setsOf(draw, anno).find((r) => r.kind === 'shapes'),
|
||||
);
|
||||
const upserts = {
|
||||
get length() {
|
||||
return shapeSets.reduce((n, record) => n + record.writes - 1, 0);
|
||||
},
|
||||
};
|
||||
assert.equal(ringOf(pin).geometry.semiMajor, 60);
|
||||
assert.equal(before.size, 1, 'one listener for every ring');
|
||||
// The camera has not moved: nothing is sent.
|
||||
preRender();
|
||||
assert.equal(upserts.length, 0);
|
||||
// It climbs: both rings are sent at the new radius, once.
|
||||
camera.height = 4000;
|
||||
preRender();
|
||||
preRender();
|
||||
assert.equal(upserts.length, 2);
|
||||
assert.equal(ringOf(pin).geometry.semiMajor, 120);
|
||||
assert.equal(ringOf(pin).geometry.semiMinor, 120);
|
||||
assert.equal(ringOf(other).geometry.semiMajor, 120);
|
||||
// A change under 0.1% sends nothing.
|
||||
camera.height = 4002;
|
||||
preRender();
|
||||
assert.equal(upserts.length, 2);
|
||||
// Held within 14 m and 170 m.
|
||||
camera.height = 1e6;
|
||||
preRender();
|
||||
assert.equal(ringOf(pin).geometry.semiMajor, 170);
|
||||
camera.height = 10;
|
||||
preRender();
|
||||
assert.equal(ringOf(pin).geometry.semiMajor, 14);
|
||||
// A hidden mark waits, and catches up when shown.
|
||||
other.hidden = true;
|
||||
renderer.sync();
|
||||
camera.height = 3000;
|
||||
preRender();
|
||||
assert.equal(ringOf(pin).geometry.semiMajor, 90);
|
||||
assert.equal(ringOf(other).geometry.semiMajor, 14, 'hidden: not sent');
|
||||
other.hidden = false;
|
||||
renderer.sync();
|
||||
assert.equal(ringOf(other).geometry.semiMajor, 90, 'shown: caught up');
|
||||
// The last ring gone, the listener goes with it.
|
||||
renderer.remove(pin);
|
||||
renderer.remove(other);
|
||||
assert.equal(before.size, 0);
|
||||
renderer.destroy();
|
||||
});
|
||||
|
||||
test('a building waits for its ground probes, then draws a pulsing column, a cage and a draped base', async (t) => {
|
||||
const { v, draw, emit, frames } = viewer(t, { heights: () => 150 });
|
||||
const renderer = createWorldAnnotationRenderer(v);
|
||||
|
||||
Reference in new issue
Block a user