fix(annotations): a double-click follows a pin and zooms to an area or line again

A mark's ring, marker, areas and lines were entities, which the default
renderer's double-click followed (ring and marker) or zoomed to (the rest)
until the mark was removed. As draw-port items they took no part in it.
This commit is contained in:
Sameh Khamis committed 2026-11-14 01:25:45 -08:00
1 parent 94ea9cd01d
commit 322e4a91d3
2 files changed
+75

No files matched your search

@@ -446,3 +446,33 @@ test('a mark removed and added again draws afresh; two renderers on one viewer k
assert.equal(route._draw, null, 'a destroyed renderer draws nothing more');
assert.equal([...draw.sets.values()].filter((r) => !r.disposed).length, 0);
});
test('a double-click follows a pin and zooms to an area, as their entities were; a removed pin ends it', async (t) => {
const { createStubRenderer } = await import('../render/stub/index.js');
const renderer = createStubRenderer();
const v = { isDestroyed: () => false };
const unbind = bindRenderer(v, renderer);
const r = createWorldAnnotationRenderer(v);
t.after(() => {
r.destroy();
unbind();
renderer.destroy();
});
const [, area, pin] = marks();
r.add(area);
r.add(pin);
const setOf = (anno, kind) => anno._draw[kind].id;
let hit = null;
renderer.testing.scriptPicks(() => (hit ? [hit] : []));
hit = { set: setOf(pin, 'points'), id: 'marker', surface: false };
renderer.testing.pointer('dblclick', 10, 10);
assert.ok(renderer.camera.followed, 'the pin is followed');
hit = { set: setOf(area, 'shapes'), id: 'fill:0', surface: false };
renderer.testing.pointer('dblclick', 10, 10);
assert.equal(renderer.camera.followed, null, 'the area is zoomed to');
hit = { set: setOf(pin, 'shapes'), id: 'ring', surface: false };
renderer.testing.pointer('dblclick', 10, 10);
assert.ok(renderer.camera.followed, 'its ring follows it too');
r.remove(pin);
assert.equal(renderer.camera.followed, null, 'removed: no longer followed');
});