mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
The renderer seam: clicks go to the newest tool, recession and display groups through the contract, drawing at parity with Cesium
- Clicks: when two tools want the globe's clicks, the newest takes them and the older is told and turns itself off; a click is decided when it arrives, and ambient selection fires only when no tool holds the pointer. The "map is busy" paths and their strings are removed. - Recession: the limb fade is shared (src/render/recession.js) and reaches icon and model sets through SetSpec.recede; tuning applies on the next frame. - Display panel groups are published through src/ui/displayGroups.js; the Weather group and src/viewWeather.js are removed. - Draw port: a set whose icons only move is moved in place, and models that did not change are not restyled each frame, so moving fleets cost what they did when drawn directly; an untinted, fully opaque model is drawn without a colour. - Conformance: input.lease.lost checks the new lease inside onLost and reports a throwing onLost; draw.sets.recede covers model sets. - QA scripts read the renderer host instead of internals the seam replaced.
This commit is contained in:
1 parent
a0d299523d
commit
0ab31d4fb8
130 files changed
+5438
-1674
No files matched your search
@@ -11,7 +11,9 @@ import {
|
||||
pointerOwner,
|
||||
releasePointer,
|
||||
resetPointerOwnership,
|
||||
bridgePointer,
|
||||
} from './inputOwnership.js';
|
||||
import { createInputRouter } from '../render/input/router.js';
|
||||
|
||||
const ROOT = path.resolve(
|
||||
path.dirname(fileURLToPath(import.meta.url)),
|
||||
@@ -35,22 +37,61 @@ test('the pointer starts free and a claim hands back a lease', () => {
|
||||
assert.equal(isLeaseCurrent(lease), true);
|
||||
});
|
||||
|
||||
test('a claim is never stolen — not even by the same tool name', () => {
|
||||
const first = claimPointer('draw');
|
||||
assert.ok(first);
|
||||
test('the newest claim takes over and the holder it replaces is told, once', () => {
|
||||
const told = [];
|
||||
const first = claimPointer('draw', { onLost: () => told.push('draw') });
|
||||
const second = claimPointer('directions', {
|
||||
onLost: () => told.push('directions'),
|
||||
});
|
||||
assert.ok(second, 'a second claim is not refused');
|
||||
assert.deepEqual(told, ['draw']);
|
||||
assert.equal(pointerOwner(), 'directions');
|
||||
assert.equal(isLeaseCurrent(first), false);
|
||||
assert.equal(isLeaseCurrent(second), true);
|
||||
assert.equal(
|
||||
releasePointer(first),
|
||||
false,
|
||||
'the old late release frees nothing',
|
||||
);
|
||||
assert.equal(pointerOwner(), 'directions');
|
||||
assert.deepEqual(told, ['draw'], 'told once');
|
||||
assert.equal(releasePointer(second), true);
|
||||
assert.deepEqual(told, ['draw'], 'a holder that lets go is not told');
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
claimPointer('directions'),
|
||||
null,
|
||||
'another tool must not displace it',
|
||||
);
|
||||
assert.equal(
|
||||
claimPointer('draw'),
|
||||
null,
|
||||
'a SECOND instance of the same tool is a second owner, not a no-op',
|
||||
);
|
||||
assert.equal(pointerOwner(), 'draw');
|
||||
assert.equal(isLeaseCurrent(first), true);
|
||||
test('a second instance of the same tool takes over from the first', () => {
|
||||
// An old instance mid-teardown and its replacement already running are two
|
||||
// owners: the replacement wins, and the old one is told to turn off.
|
||||
let lost = 0;
|
||||
const old = claimPointer('draw', { onLost: () => (lost += 1) });
|
||||
const live = claimPointer('draw');
|
||||
assert.notEqual(live.id, old.id);
|
||||
assert.equal(lost, 1);
|
||||
assert.equal(isLeaseCurrent(live), true);
|
||||
});
|
||||
|
||||
test('the holder is told after the new claim holds the pointer; its error stays its own', (t) => {
|
||||
const errors = [];
|
||||
t.mock.method(console, 'error', (...args) => errors.push(args));
|
||||
let seen = null;
|
||||
const first = claimPointer('draw', {
|
||||
onLost: () => {
|
||||
seen = { owner: pointerOwner(), current: isLeaseCurrent(first) };
|
||||
throw new Error('onLost');
|
||||
},
|
||||
});
|
||||
const second = claimPointer('directions');
|
||||
assert.deepEqual(seen, { owner: 'directions', current: false });
|
||||
assert.equal(isLeaseCurrent(second), true);
|
||||
assert.equal(errors.length, 1);
|
||||
});
|
||||
|
||||
test('reset tells no one', () => {
|
||||
let lost = 0;
|
||||
claimPointer('draw', { onLost: () => (lost += 1) });
|
||||
resetPointerOwnership();
|
||||
claimPointer('directions');
|
||||
assert.equal(lost, 0);
|
||||
});
|
||||
|
||||
test('a replaced instance cannot free its successor’s claim', () => {
|
||||
@@ -173,3 +214,64 @@ test('ambient selection handlers never claim the pointer themselves', () => {
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
/** A renderer's input port, as the contract's router keeps it. */
|
||||
const portOf = () =>
|
||||
createInputRouter({
|
||||
report: (error) => {
|
||||
throw error;
|
||||
},
|
||||
suspendCamera: () => () => {},
|
||||
}).port;
|
||||
|
||||
test('a bridged port holds a lease for as long as a tool holds the pointer', () => {
|
||||
const port = portOf();
|
||||
const bridge = bridgePointer(port);
|
||||
assert.equal(bridge.lease(), null);
|
||||
const lease = claimPointer('draw');
|
||||
assert.equal(port.isPointerFree(), false, 'the port is taken too');
|
||||
assert.equal(bridge.lease().owner, 'draw');
|
||||
assert.equal(bridge.lease().current, true);
|
||||
const next = claimPointer('directions');
|
||||
assert.equal(bridge.lease().owner, 'directions');
|
||||
releasePointer(lease);
|
||||
assert.equal(port.isPointerFree(), false, 'a stale release frees nothing');
|
||||
releasePointer(next);
|
||||
assert.equal(port.isPointerFree(), true);
|
||||
assert.equal(bridge.lease(), null);
|
||||
bridge.off();
|
||||
});
|
||||
|
||||
test('a claim made on the port takes over from the page’s tool, and back', () => {
|
||||
const port = portOf();
|
||||
const bridge = bridgePointer(port);
|
||||
const told = [];
|
||||
const page = claimPointer('draw', { onLost: () => told.push('draw') });
|
||||
const other = port.claimPointer('other', {
|
||||
onLost: () => told.push('other'),
|
||||
});
|
||||
assert.deepEqual(told, ['draw'], 'the page’s tool is told');
|
||||
assert.equal(isLeaseCurrent(page), false);
|
||||
assert.equal(
|
||||
isPointerFree(),
|
||||
false,
|
||||
'the port’s own claim holds the pointer',
|
||||
);
|
||||
assert.equal(bridge.lease(), null);
|
||||
claimPointer('directions');
|
||||
assert.deepEqual(told, ['draw', 'other'], 'a newer page claim takes it back');
|
||||
assert.equal(other.current, false);
|
||||
assert.equal(bridge.lease().owner, 'directions');
|
||||
bridge.off();
|
||||
});
|
||||
|
||||
test('a port bridged while a tool holds the pointer takes its lease at once; off gives it back', () => {
|
||||
const lease = claimPointer('draw');
|
||||
const port = portOf();
|
||||
const bridge = bridgePointer(port);
|
||||
assert.equal(port.isPointerFree(), false);
|
||||
bridge.off();
|
||||
assert.equal(port.isPointerFree(), true);
|
||||
assert.equal(isLeaseCurrent(lease), true, 'the page claim stands');
|
||||
assert.equal(isPointerFree(), false);
|
||||
});
|
||||
Reference in new issue
Block a user