Scope pick ownership and selection dispatch to each scene

Create pick registries and selection dispatchers for each scene attachment,
publish them through scene.services, and release their predicates and input
subscriptions before parking the renderer. Resolve layer ownership with the
attached engine so identical layer IDs in simultaneous scenes cannot overwrite
or remove one another. Re-register retained ALPR and cyclone picks on attachment,
and resolve voice pointer picks against the engine that supplied the pick.

Preserve Cesium's selection, sibling ownership, inert trails, touch expansion,
drag and long-press rules on both engines. Extract the unchanged gesture
predicates so portable picking does not acquire a native input dependency.
Exercise scene isolation, teardown and reattachment on fake and headless Cesium
engines, retaining the existing layer assertions.

No coupling count falls or grows. Cesium and Navara renderer lines remain 0 and
189; external Cesium imports 3; viewer lines 910; Navara kind checks 2; engine
sniff calls 0; extension reads 3; ground passes 1; SDK loads 3; screen-handler
files 4; engine-name lines 33.
This commit is contained in:
German Khokhlov committed 2026-11-07 16:27:43 +04:00
1 parent 52c6f68bd5
commit 4252ed0798
53 files changed
+712 -277

No files matched your search

+1 -1
View File
@@ -53,7 +53,7 @@ test('the scene constructs the engine with the viewer and returns it beside the
assert.match(scene, /tilesetRef\.current = tileset;/);
assert.match(
scene.replace(/\s+/g, ' '),
/return \{ viewer, engine, tileset, mapStackController, operations,? \};/,
/return \{ viewer, engine, tileset, mapStackController, operations, services,? \};/,
);
});
+17
View File
@@ -1,6 +1,7 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { createApplicationScene } from './scene.js';
import { sceneServicesFor } from '../data/sceneServices.js';
import { createFakeEngine } from '../globe/testing/fakeEngine.js';
import {
installEngineRenderGovernor,
@@ -260,3 +261,19 @@ test('parking or tearing down the Navara scene releases a running camera verb',
if (end === 'park') cache.clear();
}
});
test('the application scene owns and releases its pick services', async () => {
const run = await startScene({ googleApiKey: '' });
const { engine, services } = run.scene;
try {
assert.equal(sceneServicesFor(engine), services);
services.selection.register('flights', { owns: (id) => id === 'contact' });
assert.equal(services.picking.findPickOwner('contact'), 'flights');
} finally {
await run.teardown();
}
assert.equal(services.picking.findPickOwner('contact'), null);
services.picking.registerPickOwner('late', () => true);
assert.equal(services.picking.findPickOwner('contact'), null);
assert.equal(engine.isDestroyed(), true);
});
+4
View File
@@ -1,3 +1,4 @@
import { createSceneServices } from '../data/sceneServices.js';
import { releaseCameraVerbs } from '../cameraVerbs.js';
import { createApplicationOperations } from './operations.js';
import {
@@ -79,6 +80,8 @@ export async function createApplicationScene({
const { viewer, engine, tileset, mapStackController } = rendererCache
? await rendererCache.acquire(options.engineKind, build, defer)
: await build({ defer });
const services = createSceneServices(engine);
defer(services.destroy);
if (layerSession) {
// DEM cells belong to the session. Mesh samples came from the outgoing
// scene, including when the incoming canvas was warm in the cache.
@@ -93,6 +96,7 @@ export async function createApplicationScene({
tileset,
mapStackController,
operations,
services,
};
}