render: Cesium draws wind-streamline fields; the wind layer's flow uses the draw port

The Cesium draw port now implements draw.field for the windStreamlines
kind (src/render/cesium/drawStreamlines.js). It carries the flow shader,
the 30-degree cells, horizon and frustum culling and the path tracing over
from the wind layer. It moves the highlight on the page's own frames, at
most every 32 ms, and only while the field shows, is unpaused, has alpha
and some cell is in view on a visible page. A grid no path runs through,
or one short of the whole globe, is refused. A rebuild that fails draws
nothing and is never told drawn.

The wind layer's GPU flow (src/layers/wind/gpuRendering.js) now builds the
spec, fades it by camera height and pauses it through the draw, camera and
frame ports, and no longer reaches Cesium, so it leaves the Cesium allow
list. The layer runs no animation loop of its own while the renderer draws
the flow; the canvas fallback is unchanged and still takes over wherever
the field is refused. A new conformance check covers the field's 'drawn'
events.
This commit is contained in:
Sameh Khamis committed 2026-11-09 07:38:06 -08:00
1 parent 50cb7bd5f4
commit fcd1c09565
12 files changed
+1414 -701

No files matched your search

+29 -74
View File
@@ -453,11 +453,11 @@ test('scalar imagery builds once, survives pause, replaces cleanly, and releases
for (const overlay of ['speed', 'pressure', 'temperature']) {
test(`${overlay} imagery fades with log camera height and resumes from idle`, () => {
let camera = null;
const gpu = {
supported: () => true,
setField: () => true,
updateVisibility: (camera) => camera.positionCartographic.height > 15000,
tick() {},
updateVisibility: () => camera.positionCartographic.height > 15000,
setOptions() {},
clear() {},
destroy() {},
@@ -465,7 +465,7 @@ for (const overlay of ['speed', 'pressure', 'temperature']) {
getDiagnostics: () => ({ ready: true }),
};
const h = harness({ createGpuRendering: () => gpu });
const camera = h.viewer.scene.camera;
camera = h.viewer.scene.camera;
const baseAlpha = overlay === 'temperature' ? 1 : 0.85;
const snapshot = {
grid: FIELD,
@@ -673,11 +673,11 @@ test('world-anchored wind glyphs remain readable at low FPS without accelerating
h.rendering.destroy();
});
test('GPU flow uses one scheduler, rebuilds only across viewport budgets, and pauses cleanly', () => {
test('GPU flow leaves animation to the renderer, rebuilds only across viewport budgets, and pauses cleanly', () => {
let builds = 0,
ticks = 0,
cleared = 0,
destroyed = 0;
const options = [];
const gpu = {
supported: () => true,
updateVisibility: () => true,
@@ -686,10 +686,9 @@ test('GPU flow uses one scheduler, rebuilds only across viewport budgets, and pa
builds++;
return true;
},
tick() {
ticks++;
setOptions(value) {
options.push(value.paused);
},
setOptions() {},
clear() {
cleared++;
},
@@ -700,16 +699,12 @@ test('GPU flow uses one scheduler, rebuilds only across viewport budgets, and pa
getDiagnostics: () => ({ ready: true, pathCount: 1 }),
};
const h = harness({ createGpuRendering: () => gpu });
let renders = 0;
h.viewer.scene.requestRender = () => {
renders++;
};
h.rendering.attach();
h.rendering.setField({ grid: FIELD, u: FIELD.u, v: FIELD.v });
h.rendering.start();
h.callbacks.shift()(16);
assert.equal(h.rendering.getDiagnostics().renderMode, 'gpu-streamlines');
assert.ok(ticks > 0 && renders > 0);
assert.equal(h.pending.size, 0, 'the renderer moves the highlight');
assert.equal(options.at(-1), false);
assert.equal(h.strokes.length, 0);
h.viewer.scene.camera.positionWC.x = 10;
h.preRender.emit();
@@ -719,7 +714,7 @@ test('GPU flow uses one scheduler, rebuilds only across viewport budgets, and pa
'camera changes project geometry without rebuilding paths',
);
h.rendering.setOptions({ paused: true });
assert.equal(h.pending.size, 0);
assert.equal(options.at(-1), true, 'the pause reaches the renderer');
h.canvas.clientWidth = 390;
h.preRender.emit();
assert.equal(builds, 2, 'crossing the narrow viewport boundary rebakes once');
@@ -744,7 +739,6 @@ for (const paused of [false, true]) {
ready = false;
return true;
},
tick() {},
setOptions() {},
clear() {},
destroy() {},
@@ -796,9 +790,8 @@ for (const paused of [false, true]) {
});
}
test('scalar snapshots retain identical GPU wind geometry and animation phase', () => {
test('scalar snapshots retain identical GPU wind geometry, and so its animation phase', () => {
let builds = 0;
const times = [];
const gpu = {
supported: () => true,
updateVisibility: () => true,
@@ -806,9 +799,6 @@ test('scalar snapshots retain identical GPU wind geometry and animation phase',
builds++;
return true;
},
tick(time) {
times.push(time);
},
setOptions() {},
clear() {},
destroy() {},
@@ -833,9 +823,6 @@ test('scalar snapshots retain identical GPU wind geometry and animation phase',
h.rendering.attach();
h.rendering.setField(snapshot());
h.rendering.start();
h.callbacks.shift()(16);
h.callbacks.shift()(1016);
const phase = times.at(-1);
h.rendering.setOptions({ overlay: 'temperature' });
h.rendering.setField(
snapshot({
@@ -852,11 +839,6 @@ test('scalar snapshots retain identical GPU wind geometry and animation phase',
'freshly decoded equal arrays reuse the worker-built primitive',
);
assert.equal(h.imagery.length, 1, 'new scalar field is still installed');
h.callbacks.shift()(1032);
assert.ok(
times.at(-1) >= phase,
'scalar acquisition does not reset travelling highlights',
);
h.rendering.setField(
snapshot({
scalar: {
@@ -899,7 +881,6 @@ for (const [label, change] of Object.entries({
builds++;
return true;
},
tick() {},
setOptions() {},
clear() {},
destroy() {},
@@ -927,25 +908,25 @@ for (const [label, change] of Object.entries({
}
for (const eventName of ['preRender', 'moveEnd']) {
test(`GPU height suspension resumes from camera ${eventName} without preRender`, () => {
const times = [];
test(`GPU height fade follows camera ${eventName} with no frames of its own`, () => {
let visible = false;
let inFrustum = true;
let fades = 0;
const options = [];
const gpu = {
supported: () => true,
setField: () => true,
updateVisibility(camera) {
visible = camera.positionCartographic.height > 15000 && inFrustum;
updateVisibility() {
fades++;
visible = camera.positionCartographic.height > 15000;
return visible;
},
tick(time) {
times.push(time);
setOptions(value) {
options.push(value.paused);
},
setOptions() {},
clear() {},
destroy() {},
getParticleCount: () => 1,
getDiagnostics: () => ({ ready: true, visibleCells: Number(visible) }),
getDiagnostics: () => ({ ready: true }),
};
const h = harness({ createGpuRendering: () => gpu });
const camera = h.viewer.scene.camera;
@@ -958,52 +939,27 @@ for (const eventName of ['preRender', 'moveEnd']) {
h.preRender.emit();
assert.equal(h.pending.size, 0);
assert.equal(renders, 0);
assert.equal(times.length, 0);
assert.equal(visible, false);
assert.equal(camera.percentageChanged, 0.5);
assert.equal(camera.changed.size, 0);
camera.positionCartographic.height = 60000;
const before = fades;
(eventName === 'preRender' ? h.preRender : camera.moveEnd).emit();
assert.ok(fades > before, 'the fade follows the camera');
assert.equal(visible, true);
assert.equal(
renders,
eventName === 'preRender' ? 0 : 1,
'moveEnd wakes the parked scene',
);
assert.equal(h.pending.size, 1);
h.callbacks.shift()(16);
assert.equal(times.length, 1);
const phase = times.at(-1);
const queued = h.callbacks.shift();
camera.positionCartographic.height = 15000;
h.preRender.emit();
const parkedRenders = renders;
queued(100000);
assert.equal(h.pending.size, 0);
assert.equal(renders, parkedRenders);
assert.equal(times.length, 1, 'parked draw cannot tick or advance phase');
camera.positionCartographic.height = 60000;
(eventName === 'preRender' ? h.preRender : camera.moveEnd).emit();
h.callbacks.shift()(200000);
assert.ok(
times.at(-1) - phase < 0.1,
'idle time does not jump animation phase',
);
inFrustum = false;
h.preRender.emit();
assert.equal(h.pending.size, 0, 'frustum-hidden cells also park');
inFrustum = true;
assert.equal(h.pending.size, 0, 'the renderer animates, not the layer');
h.rendering.setOptions({ paused: true });
(eventName === 'preRender' ? h.preRender : camera.moveEnd).emit();
assert.equal(h.pending.size, 0, 'camera events respect pause');
assert.equal(options.at(-1), true);
h.rendering.setOptions({ paused: false });
globalThis.document.hidden = true;
h.visibility.emit();
(eventName === 'preRender' ? h.preRender : camera.moveEnd).emit();
assert.equal(h.pending.size, 0, 'camera events respect hidden documents');
globalThis.document.hidden = false;
h.visibility.emit();
assert.equal(h.pending.size, 1);
assert.equal(options.at(-1), false);
h.rendering.stop();
assert.equal(options.at(-1), true, 'a stopped layer holds the flow still');
h.rendering.destroy();
assert.equal(h.pending.size, 0);
assert.equal(camera.changed.size, 0);
@@ -1107,7 +1063,6 @@ for (const overlay of ['speed', 'temperature', 'pressure']) {
supported: () => true,
setField: () => true,
updateVisibility: () => true,
tick() {},
setOptions() {},
clear() {},
destroy() {},