Treat contacts with the Cyber sonar sweep on Navara behind an optional render.setContactSonar capability

The sprite and point mover shaders rate each contact by its anchor against the sweep with the cyberSonar.js sampler maths; the engine sonar scene feeds the theme, settings and shared sweep angle each drawn frame and keeps the fleet cadence only while the sweep runs over contacts.
This commit is contained in:
German Khokhlov committed 2026-11-03 21:49:56 +04:00
1 parent c2d7a6dbb0
commit 1a3f6f2486
16 files changed
+1040 -6

No files matched your search

@@ -314,11 +314,46 @@ test('setCloudCover hands changed covers to the clouds port and draws a frame',
assert.equal(destroyed, 1);
});
test('setContactSonar hands changes to the sonar port, asking a frame only outside one', () => {
const view = fakeView();
const shown = [];
let destroyed = 0;
const engine = createNavaraEngine(view, {
hooks,
sonar: { set: (state) => shown.push(state), destroy: () => destroyed++ },
});
assertGlobeEngine(engine);
assert.equal(engineCapabilities(engine).contactSonar, true);
assert.equal(engine.render.contactSonar().enabled, false);
engine.render.setContactSonar({ enabled: true, active: true });
assert.deepEqual(view.calls.at(-1), ['forceUpdate']);
assert.equal(shown.length, 1);
// Inside a drawn frame the change shows in that frame: no other frame.
engine.frames.preRender.addEventListener(() =>
engine.render.setContactSonar({ angleDeg: 45 }),
);
const calls = view.calls.length;
view.emit('preRender', 1);
view.emit('postRender', 2);
assert.equal(shown.at(-1).angleDeg, 45);
assert.equal(
view.calls.slice(calls).filter(([name]) => name === 'forceUpdate').length,
0,
);
assert.throws(
() => engine.render.setContactSonar({ opacity: 120 }),
TypeError,
);
engine.destroy();
assert.equal(destroyed, 1);
});
test('without a styles port the engine has no visualStyles capability', () => {
const { engine } = setup();
assert.equal(engineCapabilities(engine).visualStyles, false);
assert.equal(engineCapabilities(engine).bloom, false);
assert.equal(engineCapabilities(engine).cloudCover, false);
assert.equal(engineCapabilities(engine).contactSonar, false);
assert.equal(engine.render.setStyle, undefined);
assert.equal(engine.render.setBloom, undefined);
});