mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Cyber contact sweep goes through the effects port, off the Cesium allow-list
The cyber sonar scene now sets a screenModulation sector each tick that draws and at the renderer's sonar cadence, and clears it outside the Cyber map theme. A renderer without the capability, or one that stops listing the pass, leaves markers native and reports the contact GPU unavailable, while the HUD sweep keeps its clock. The old Cesium command wrapper is removed; cyberSonarGpu.js and cyberSonarScene.js leave the allow-list.
This commit is contained in:
1 parent
85a04b1367
commit
cf72c7857d
7 files changed
+416
-1090
No files matched your search
+282
-240
@@ -1,19 +1,16 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import * as Cesium from 'cesium';
|
||||
import {
|
||||
CYBER_SONAR_RENDER_INTERVAL_MS,
|
||||
applyCyberSonarSettings,
|
||||
createCyberSonarSampler,
|
||||
cyberSonarIntensityAtScreenPoint,
|
||||
applyCyberSonarPrimitive,
|
||||
applyCyberSonarSettings,
|
||||
cyberSonarSector,
|
||||
isCyberContactSonarActive,
|
||||
isCyberSonarActive,
|
||||
} from './cyberSonar.js';
|
||||
import {
|
||||
createCyberSonarScene,
|
||||
visitCyberSonarModels,
|
||||
getCyberSonarSceneDiagnostics,
|
||||
} from './cyberSonarScene.js';
|
||||
import { createCyberSonarScene } from './cyberSonarScene.js';
|
||||
import { bindRenderer } from './render/rendererOf.js';
|
||||
|
||||
test('frame sampler matches reference without per-contact settings access', () => {
|
||||
let reads = 0;
|
||||
@@ -47,44 +44,7 @@ test('frame sampler matches reference without per-contact settings access', () =
|
||||
);
|
||||
});
|
||||
|
||||
test('model walk never enumerates native contact or EntityCluster records', () => {
|
||||
const root = new Cesium.PrimitiveCollection();
|
||||
const points = root.add(new Cesium.PointPrimitiveCollection());
|
||||
points.add();
|
||||
points.get = () => {
|
||||
throw new Error('must not enumerate contacts');
|
||||
};
|
||||
const cluster = root.add(new Cesium.EntityCluster());
|
||||
Object.defineProperty(cluster, '_billboardCollection', {
|
||||
get() {
|
||||
throw new Error('must not access cluster internals');
|
||||
},
|
||||
configurable: true,
|
||||
});
|
||||
const seen = [];
|
||||
visitCyberSonarModels(root, (...v) => seen.push(v));
|
||||
assert.equal(seen.length, 0);
|
||||
delete cluster._billboardCollection;
|
||||
root.destroy();
|
||||
});
|
||||
|
||||
test('models retain render-pass alpha and owner refresh survives teardown', () => {
|
||||
const frame = createCyberSonarSampler(1000, 800, 0);
|
||||
const model = { color: new Cesium.Color(1, 0.5, 0.2, 1) };
|
||||
applyCyberSonarPrimitive(model, 0.5, true, frame, 'color', true);
|
||||
assert.equal(model.color.alpha, 1);
|
||||
assert.ok(model.color.red < 1);
|
||||
const owner = new Cesium.Color(0.2, 0.3, 0.4, 0.7);
|
||||
model.color = owner;
|
||||
applyCyberSonarPrimitive(model, 1, false);
|
||||
assert.equal(model.color, owner);
|
||||
const unset = {};
|
||||
applyCyberSonarPrimitive(unset, 0.5, true, frame, 'color', true);
|
||||
applyCyberSonarPrimitive(unset, 1, false);
|
||||
assert.equal(unset.color, undefined);
|
||||
});
|
||||
|
||||
test('removed CSS mode cannot disable GPU contacts; unsupported adapters fail closed', () => {
|
||||
test('removed CSS mode cannot disable GPU contacts; unsupported renderers fail closed', () => {
|
||||
const root = { dataset: { uiTheme: 'cyber' }, style: { setProperty() {} } };
|
||||
const options = {
|
||||
root,
|
||||
@@ -106,209 +66,291 @@ test('removed CSS mode cannot disable GPU contacts; unsupported adapters fail cl
|
||||
assert.equal(isCyberContactSonarActive(options), false);
|
||||
});
|
||||
|
||||
test('native owner colors remain untouched and scene teardown releases listeners', () => {
|
||||
const previous = globalThis.document;
|
||||
test('the sector is the sweep the HUD shows, in CSS pixels and radians', () => {
|
||||
const root = {
|
||||
dataset: {
|
||||
cyberSonarOpacity: '62',
|
||||
cyberSonarSector: '40',
|
||||
cyberSonarRange: '110',
|
||||
},
|
||||
};
|
||||
const s = cyberSonarSector(1000, 800, 1300, { root });
|
||||
assert.deepEqual(s.center, { x: 500, y: 400 });
|
||||
assert.ok(Math.abs(s.angle - Math.PI / 2) < 1e-9, 'a quarter period');
|
||||
assert.ok(Math.abs(s.width - (40 * Math.PI) / 180) < 1e-12);
|
||||
assert.ok(Math.abs(s.radius - 440) < 1e-9);
|
||||
assert.equal(s.floor, 0.62);
|
||||
assert.equal(s.strength, 0.72);
|
||||
assert.equal(s.color, '#ffd6d6');
|
||||
const rest = cyberSonarSector(1000, 800, 1300, { root, sweeping: false });
|
||||
assert.equal(rest.radius, 0);
|
||||
assert.ok(Math.abs(rest.floor - (0.62 + 0.38 * 0.46)) < 1e-12);
|
||||
});
|
||||
|
||||
/**
|
||||
* A document with the Cyber HUD shown, and a renderer fake bound to a
|
||||
* viewer: its frame's preUpdate is ticked by hand and its effects record
|
||||
* each sector.
|
||||
*/
|
||||
function fixture({ modulation = true, lists = true, cadenceHz } = {}) {
|
||||
const previous = {
|
||||
document: globalThis.document,
|
||||
matchMedia: globalThis.matchMedia,
|
||||
};
|
||||
const root = { dataset: { uiTheme: 'cyber', cyberSonar: 'on' } };
|
||||
let cockpit = false;
|
||||
const status = { textContent: '' };
|
||||
const state = { cockpit: false, reducedMotion: false };
|
||||
globalThis.document = {
|
||||
documentElement: root,
|
||||
body: { classList: { contains: () => cockpit } },
|
||||
getElementById: () => ({ classList: { contains: () => true } }),
|
||||
body: { classList: { contains: () => state.cockpit } },
|
||||
getElementById: (id) =>
|
||||
id === 'cyber-sonar-status'
|
||||
? status
|
||||
: { classList: { contains: () => true } },
|
||||
};
|
||||
const primitives = new Cesium.PrimitiveCollection();
|
||||
const points = primitives.add(new Cesium.PointPrimitiveCollection());
|
||||
const point = points.add({ color: new Cesium.Color(0.3, 0.7, 0.5, 0.8) });
|
||||
const original = primitives.update;
|
||||
const scene = {
|
||||
primitives,
|
||||
postUpdate: new Cesium.Event(),
|
||||
preRender: new Cesium.Event(),
|
||||
postRender: new Cesium.Event(),
|
||||
canvas: { clientWidth: 1000, clientHeight: 800 },
|
||||
camera: {
|
||||
frustum: { projectionMatrix: Cesium.Matrix4.IDENTITY },
|
||||
viewMatrix: Cesium.Matrix4.IDENTITY,
|
||||
globalThis.matchMedia = () => ({ matches: state.reducedMotion });
|
||||
const ticks = new Set();
|
||||
const changes = new Set();
|
||||
const sets = [];
|
||||
const requests = [];
|
||||
let drawing = null;
|
||||
const effects = {
|
||||
diagnostics: () => ({
|
||||
style: null,
|
||||
passes: drawing && lists ? ['screenModulation'] : [],
|
||||
}),
|
||||
on(event, cb) {
|
||||
changes.add(cb);
|
||||
return () => changes.delete(cb);
|
||||
},
|
||||
requestRender() {},
|
||||
};
|
||||
const viewer = { scene };
|
||||
const dispose = createCyberSonarScene(viewer);
|
||||
try {
|
||||
for (const enabled of ['on', 'off', 'on']) {
|
||||
root.dataset.cyberSonar = enabled;
|
||||
for (const opacity of [35, 84, 100]) {
|
||||
root.dataset.cyberSonarOpacity = String(opacity);
|
||||
point.color = new Cesium.Color(0.6, 0.4, 0.2, 0.7);
|
||||
scene.postUpdate.raiseEvent();
|
||||
scene.preRender.raiseEvent();
|
||||
assert.equal(point.color.alpha, 0.7);
|
||||
assert.equal(point.color.red, 0.6);
|
||||
}
|
||||
}
|
||||
const previousTimeout = globalThis.setTimeout;
|
||||
const previousClear = globalThis.clearTimeout;
|
||||
let timers = 0;
|
||||
globalThis.setTimeout = () => {
|
||||
timers++;
|
||||
return 1;
|
||||
if (modulation)
|
||||
effects.screenModulation = (sector) => {
|
||||
const was = effects.diagnostics().passes.length;
|
||||
drawing = sector;
|
||||
sets.push(sector);
|
||||
if (effects.diagnostics().passes.length !== was)
|
||||
for (const cb of [...changes]) cb(effects.diagnostics());
|
||||
};
|
||||
globalThis.clearTimeout = () => {};
|
||||
try {
|
||||
const gpu = getCyberSonarSceneDiagnostics(viewer).gpu;
|
||||
gpu.commands = 6;
|
||||
gpu.visibleCommands = 0;
|
||||
scene.postRender.raiseEvent();
|
||||
assert.equal(timers, 0, 'culled batches must not schedule a sonar draw');
|
||||
gpu.visibleCommands = 1;
|
||||
scene.postRender.raiseEvent();
|
||||
assert.equal(timers, 1, 'a visible batch keeps the sweep moving');
|
||||
root.dataset.cyberSonar = 'off';
|
||||
scene.postRender.raiseEvent();
|
||||
assert.equal(timers, 1, 'OFF does not schedule contact draws');
|
||||
} finally {
|
||||
globalThis.setTimeout = previousTimeout;
|
||||
globalThis.clearTimeout = previousClear;
|
||||
}
|
||||
cockpit = true;
|
||||
scene.postUpdate.raiseEvent();
|
||||
scene.preRender.raiseEvent();
|
||||
root.dataset.uiTheme = 'tactical';
|
||||
scene.postUpdate.raiseEvent();
|
||||
scene.preRender.raiseEvent();
|
||||
const canvas = { clientWidth: 1000, clientHeight: 800 };
|
||||
const viewer = {};
|
||||
const unbind = bindRenderer(viewer, {
|
||||
canvas,
|
||||
effects,
|
||||
quality: { get: () => (cadenceHz ? { sonarCadenceHz: cadenceHz } : {}) },
|
||||
frame: {
|
||||
on(phase, cb) {
|
||||
assert.equal(phase, 'preUpdate');
|
||||
ticks.add(cb);
|
||||
return () => ticks.delete(cb);
|
||||
},
|
||||
requestRender: (reason) => requests.push(reason),
|
||||
},
|
||||
});
|
||||
return {
|
||||
root,
|
||||
status,
|
||||
state,
|
||||
sets,
|
||||
requests,
|
||||
canvas,
|
||||
viewer,
|
||||
ticks,
|
||||
changes,
|
||||
effects,
|
||||
tick(rendering = false) {
|
||||
for (const cb of [...ticks]) cb({ rendering });
|
||||
},
|
||||
restore() {
|
||||
unbind();
|
||||
globalThis.document = previous.document;
|
||||
globalThis.matchMedia = previous.matchMedia;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
test('a renderer without the capability leaves markers alone and says so', () => {
|
||||
const f = fixture({ modulation: false });
|
||||
try {
|
||||
const dispose = createCyberSonarScene(f.viewer);
|
||||
assert.equal(f.root.dataset.cyberSonarGpu, 'unsupported');
|
||||
assert.match(f.status.textContent, /Native contacts remain visible/);
|
||||
f.tick(true);
|
||||
assert.equal(f.changes.size, 0);
|
||||
dispose();
|
||||
dispose();
|
||||
assert.equal(primitives.update, original);
|
||||
assert.equal(scene.postUpdate.numberOfListeners, 0);
|
||||
assert.equal(scene.preRender.numberOfListeners, 0);
|
||||
assert.equal(scene.postRender.numberOfListeners, 0);
|
||||
assert.equal(root.dataset.cyberSonarGpu, undefined);
|
||||
assert.equal(f.ticks.size, 0);
|
||||
assert.equal(f.root.dataset.cyberSonarGpu, undefined);
|
||||
} finally {
|
||||
dispose();
|
||||
primitives.destroy();
|
||||
globalThis.document = previous;
|
||||
f.restore();
|
||||
}
|
||||
});
|
||||
|
||||
for (const reducedMotion of [false, true]) {
|
||||
test(`shader failure requests one parked restoration draw with ${reducedMotion ? 'reduced motion' : 'Sonar OFF'}`, () => {
|
||||
const previousDocument = globalThis.document;
|
||||
const previousMatchMedia = globalThis.matchMedia;
|
||||
const previousTimeout = globalThis.setTimeout;
|
||||
const previousClear = globalThis.clearTimeout;
|
||||
const root = {
|
||||
dataset: { uiTheme: 'cyber', cyberSonar: reducedMotion ? 'on' : 'off' },
|
||||
};
|
||||
const status = { textContent: '' };
|
||||
globalThis.document = {
|
||||
documentElement: root,
|
||||
body: { classList: { contains: () => false } },
|
||||
getElementById: (id) =>
|
||||
id === 'cyber-sonar-status'
|
||||
? status
|
||||
: { classList: { contains: () => true } },
|
||||
};
|
||||
globalThis.matchMedia = () => ({ matches: reducedMotion });
|
||||
let scheduled = 0;
|
||||
globalThis.setTimeout = () => {
|
||||
scheduled++;
|
||||
return 1;
|
||||
};
|
||||
globalThis.clearTimeout = () => {};
|
||||
// A model-shaped fixture exercises the actual scene walk without loading a
|
||||
// glTF or allocating a WebGL context. Rendering remains the browser gate.
|
||||
const nativeColor = new Cesium.Color(0.2, 0.4, 0.8, 1);
|
||||
const model = Object.create(Cesium.Model.prototype, {
|
||||
ready: { value: true },
|
||||
show: { value: true },
|
||||
color: { value: nativeColor.clone(), writable: true },
|
||||
modelMatrix: { value: Cesium.Matrix4.IDENTITY },
|
||||
});
|
||||
const primitives = new Cesium.PrimitiveCollection({
|
||||
destroyPrimitives: false,
|
||||
});
|
||||
primitives.add(model);
|
||||
const points = new Cesium.PointPrimitiveCollection();
|
||||
const nativeCommand = {
|
||||
owner: points,
|
||||
uniformMap: {},
|
||||
shaderProgram: {
|
||||
vertexShaderSource: new Cesium.ShaderSource({
|
||||
sources: ['void main() {}'],
|
||||
}),
|
||||
},
|
||||
};
|
||||
primitives.update = (frame) => frame.commandList.push(nativeCommand);
|
||||
let requests = 0;
|
||||
const scene = {
|
||||
primitives,
|
||||
postUpdate: new Cesium.Event(),
|
||||
preRender: new Cesium.Event(),
|
||||
postRender: new Cesium.Event(),
|
||||
canvas: { clientWidth: 1000, clientHeight: 800 },
|
||||
drawingBufferWidth: 1000,
|
||||
drawingBufferHeight: 800,
|
||||
camera: {
|
||||
frustum: { projectionMatrix: Cesium.Matrix4.IDENTITY },
|
||||
viewMatrix: Cesium.Matrix4.IDENTITY,
|
||||
},
|
||||
requestRender() {
|
||||
requests++;
|
||||
},
|
||||
};
|
||||
const viewer = { scene };
|
||||
const dispose = createCyberSonarScene(viewer);
|
||||
try {
|
||||
scene.postUpdate.raiseEvent();
|
||||
scene.preRender.raiseEvent();
|
||||
assert.notDeepEqual(
|
||||
model.color,
|
||||
nativeColor,
|
||||
'Cyber neutral treatment precedes shader compilation',
|
||||
);
|
||||
const frame = { commandList: [], passes: { render: true } };
|
||||
primitives.update(frame);
|
||||
assert.equal(getCyberSonarSceneDiagnostics(viewer).gpu.supported, false);
|
||||
assert.equal(frame.commandList[0], nativeCommand);
|
||||
scene.postRender.raiseEvent();
|
||||
assert.equal(
|
||||
scheduled,
|
||||
0,
|
||||
'inactive sweep has no timer to perform recovery',
|
||||
);
|
||||
scene.postUpdate.raiseEvent();
|
||||
assert.equal(root.dataset.cyberSonarGpu, 'unsupported');
|
||||
assert.match(status.textContent, /Native contacts remain visible/);
|
||||
assert.equal(
|
||||
requests,
|
||||
1,
|
||||
'support loss explicitly wakes the parked scene',
|
||||
);
|
||||
scene.preRender.raiseEvent();
|
||||
assert.deepEqual(
|
||||
model.color,
|
||||
nativeColor,
|
||||
'the requested draw restores native model color',
|
||||
);
|
||||
assert.equal(getCyberSonarSceneDiagnostics(viewer).contacts, 0);
|
||||
scene.postRender.raiseEvent();
|
||||
for (let i = 0; i < 3; i++) scene.postUpdate.raiseEvent();
|
||||
assert.equal(
|
||||
requests,
|
||||
1,
|
||||
'unsupported idle ticks do not create a render loop',
|
||||
);
|
||||
assert.equal(scheduled, 0);
|
||||
dispose();
|
||||
scene.postUpdate.raiseEvent();
|
||||
assert.equal(requests, 1, 'disposed callbacks cannot wake the scene');
|
||||
} finally {
|
||||
dispose();
|
||||
points.destroy();
|
||||
primitives.destroy();
|
||||
globalThis.document = previousDocument;
|
||||
globalThis.matchMedia = previousMatchMedia;
|
||||
globalThis.setTimeout = previousTimeout;
|
||||
globalThis.clearTimeout = previousClear;
|
||||
}
|
||||
});
|
||||
}
|
||||
test('the HUD sweep keeps its clock while markers cannot be shaded', () => {
|
||||
const f = fixture({ modulation: false });
|
||||
const animation = {
|
||||
animationName: 'cyber-sonar-sweep',
|
||||
playState: 'running',
|
||||
startTime: 500,
|
||||
effect: { updateTiming() {} },
|
||||
};
|
||||
f.root.querySelector = (selector) =>
|
||||
selector === '.hud-sonar'
|
||||
? { isConnected: true, getAnimations: () => [animation] }
|
||||
: null;
|
||||
try {
|
||||
const dispose = createCyberSonarScene(f.viewer);
|
||||
f.tick(false);
|
||||
assert.equal(animation.startTime, 0);
|
||||
assert.equal(f.root.dataset.cyberSonarGpu, 'unsupported');
|
||||
dispose();
|
||||
} finally {
|
||||
f.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('the sweep sets its sector on drawing ticks and at the cadence, and changes at once', () => {
|
||||
const f = fixture();
|
||||
const now = performance.now;
|
||||
let clock = 1000;
|
||||
performance.now = () => clock;
|
||||
try {
|
||||
const dispose = createCyberSonarScene(f.viewer);
|
||||
assert.equal(f.root.dataset.cyberSonarGpu, 'supported');
|
||||
assert.equal(f.status.textContent, '');
|
||||
f.tick();
|
||||
assert.equal(f.sets.length, 1, 'the theme sets a sector');
|
||||
assert.deepEqual(f.sets[0], cyberSonarSector(1000, 800, 1000));
|
||||
clock += 10;
|
||||
f.tick(false);
|
||||
assert.equal(f.sets.length, 1, 'an idle tick before the cadence sets none');
|
||||
f.tick(true);
|
||||
assert.equal(f.sets.length, 2, 'a tick that draws moves the angle');
|
||||
assert.deepEqual(f.sets[1], cyberSonarSector(1000, 800, 1010));
|
||||
clock += CYBER_SONAR_RENDER_INTERVAL_MS;
|
||||
f.tick(false);
|
||||
assert.equal(f.sets.length, 3, 'the cadence moves it on an idle tick');
|
||||
f.canvas.clientWidth = 600;
|
||||
f.tick(false);
|
||||
assert.equal(f.sets.length, 4, 'a resize sets it at once');
|
||||
assert.deepEqual(f.sets[3].center, { x: 300, y: 400 });
|
||||
f.root.dataset.cyberSonar = 'off';
|
||||
f.tick(false);
|
||||
assert.equal(f.sets[4].radius, 0, 'Sonar OFF rests every contact');
|
||||
clock += 1000;
|
||||
f.tick(true);
|
||||
f.tick(false);
|
||||
assert.equal(f.sets.length, 5, 'at rest only changes set it');
|
||||
f.root.dataset.cyberSonarOpacity = '50';
|
||||
f.tick(false);
|
||||
assert.equal(f.sets.length, 6);
|
||||
assert.equal(f.sets[5].floor, 0.5 + 0.5 * 0.46);
|
||||
f.state.cockpit = true;
|
||||
f.tick(false);
|
||||
assert.equal(f.sets[6], null, 'out of the map theme it clears');
|
||||
f.tick(true);
|
||||
assert.equal(f.sets.length, 7, 'cleared once');
|
||||
f.state.cockpit = false;
|
||||
f.root.dataset.cyberSonar = 'on';
|
||||
f.state.reducedMotion = true;
|
||||
f.tick(false);
|
||||
assert.equal(f.sets[7].radius, 0, 'reduced motion rests the sweep');
|
||||
f.state.reducedMotion = false;
|
||||
f.root.dataset.uiTheme = 'tactical';
|
||||
f.tick(false);
|
||||
assert.equal(f.sets[8], null, 'another HUD style clears it');
|
||||
f.tick(true);
|
||||
assert.equal(f.sets.length, 9);
|
||||
f.root.dataset.uiTheme = 'cyber';
|
||||
f.tick(false);
|
||||
assert.ok(f.sets[9]?.radius > 0, 'back in Cyber it sweeps at once');
|
||||
assert.deepEqual(f.requests, [], 'the scene itself never asks for frames');
|
||||
dispose();
|
||||
assert.equal(f.sets[10], null, 'disposal clears it');
|
||||
assert.equal(f.ticks.size, 0);
|
||||
assert.equal(f.changes.size, 0);
|
||||
assert.equal(f.root.dataset.cyberSonarGpu, undefined);
|
||||
dispose();
|
||||
assert.equal(f.sets.length, 11);
|
||||
} finally {
|
||||
performance.now = now;
|
||||
f.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('the renderer cadence paces the idle sweep', () => {
|
||||
const f = fixture({ cadenceHz: 4 });
|
||||
const now = performance.now;
|
||||
let clock = 0;
|
||||
performance.now = () => clock;
|
||||
try {
|
||||
const dispose = createCyberSonarScene(f.viewer);
|
||||
f.tick();
|
||||
clock += CYBER_SONAR_RENDER_INTERVAL_MS;
|
||||
f.tick();
|
||||
assert.equal(f.sets.length, 1, '4 Hz waits 250 ms');
|
||||
clock += 250 - CYBER_SONAR_RENDER_INTERVAL_MS;
|
||||
f.tick();
|
||||
assert.equal(f.sets.length, 2);
|
||||
dispose();
|
||||
} finally {
|
||||
performance.now = now;
|
||||
f.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('a sector the renderer does not list is unsupported: cleared, and the sweep stops', () => {
|
||||
const f = fixture({ lists: false });
|
||||
try {
|
||||
const dispose = createCyberSonarScene(f.viewer);
|
||||
f.tick(true);
|
||||
assert.equal(f.sets.length, 2);
|
||||
assert.equal(f.sets[1], null, 'cleared again');
|
||||
assert.equal(f.root.dataset.cyberSonarGpu, 'unsupported');
|
||||
assert.match(f.status.textContent, /Native contacts remain visible/);
|
||||
f.tick(true);
|
||||
assert.equal(f.sets.length, 2, 'never set again');
|
||||
dispose();
|
||||
assert.equal(f.sets.length, 2);
|
||||
} finally {
|
||||
f.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('a pass the renderer stops drawing on its own stops the sweep', () => {
|
||||
const f = fixture();
|
||||
try {
|
||||
const dispose = createCyberSonarScene(f.viewer);
|
||||
f.tick(true);
|
||||
assert.equal(f.sets.length, 1);
|
||||
for (const cb of [...f.changes]) cb({ style: null, passes: [] });
|
||||
assert.equal(f.root.dataset.cyberSonarGpu, 'unsupported');
|
||||
assert.equal(f.sets.at(-1), null);
|
||||
const count = f.sets.length;
|
||||
f.tick(true);
|
||||
assert.equal(f.sets.length, count);
|
||||
dispose();
|
||||
} finally {
|
||||
f.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('layer visibility changes ask for a frame', () => {
|
||||
const f = fixture();
|
||||
let listener = null;
|
||||
const manager = {
|
||||
subscribe(cb) {
|
||||
listener = cb;
|
||||
return () => (listener = null);
|
||||
},
|
||||
};
|
||||
try {
|
||||
const dispose = createCyberSonarScene(f.viewer, manager);
|
||||
listener({ type: 'visibility' });
|
||||
listener({ type: 'data' });
|
||||
assert.deepEqual(f.requests, ['cyber-sonar']);
|
||||
dispose();
|
||||
assert.equal(listener, null);
|
||||
} finally {
|
||||
f.restore();
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user