Draw the Draw tool's live preview through the draw port and take the tool off the Cesium list

The preview of a shape being drawn is now two sets on the renderer's draw
port instead of a Cesium data source: one dashed rubber band along the
globe (the chosen colour at 0.9, 3 px, dash 16, primary at 0.35 behind
the surface) and a dot per vertex (8 px, black outline at 0.6, drawn over
depth). The band is written on each pointer move and vertex change
rather than re-read every frame. A pointer move now carries
`pickPosition`, its point in the pick buffer corrected for sensor styles
as a click's position is, which the rubber band follows; the tool reads
its canvas from the renderer and asks frames through the frame port.

The diagnostics count the preview sets live on the viewer
(`previewSets`, `previewItems`) in place of preview data sources.

One difference: where the band runs behind the surface it is drawn in a
solid colour, as the draw contract's depth-fail colour is a colour, not
a dashed material.
This commit is contained in:
Sameh Khamis committed 2026-11-07 16:56:49 -08:00
1 parent c49191a87b
commit 3cce1aaa3e
7 files changed
+198 -167

No files matched your search

+9 -19
View File
@@ -284,14 +284,14 @@ try {
}
const after = await drawState();
check(
'three enable/disable cycles add no listener, handler or preview data source',
'three enable/disable cycles add no listener, handler or preview set',
after.domListeners === before.domListeners &&
after.previewDataSources === 1 &&
before.previewDataSources === 1 &&
after.previewSets === 2 &&
before.previewSets === 2 &&
after.sceneHandler === false &&
after.pointerOwner === null &&
after.stockDoubleClick === before.stockDoubleClick,
`listeners ${before.domListeners}→${after.domListeners}, previews ${after.previewDataSources}, ` +
`listeners ${before.domListeners}→${after.domListeners}, previews ${after.previewSets}, ` +
`handler ${after.sceneHandler}, owner ${after.pointerOwner}, stock dblclick ${after.stockDoubleClick}`,
);
@@ -774,13 +774,10 @@ try {
finalState.active === false &&
finalState.pointerOwner === null &&
finalState.sceneHandler === false &&
finalState.previewDataSources === 1,
finalState.previewSets === 2,
JSON.stringify(finalState),
);
// ── destroy(): the shell disposing the tool leaves nothing behind ───────
const beforeDestroy = await page.evaluate(
() => window.__godsEyeView.viewer.dataSources.length,
);
await page.click('#draw-toggle'); // destroy from an ACTIVE session: the harder case
await wait(200);
const destroyed = await page.evaluate(async () => {
@@ -788,16 +785,11 @@ try {
const wasActive = tool.active;
await tool.destroy();
await new Promise((resolve) => setTimeout(resolve, 50));
const viewer = window.__godsEyeView.viewer;
let previews = 0;
for (let i = 0; i < viewer.dataSources.length; i += 1)
if (viewer.dataSources.get(i)?.name === 'gev-draw-preview') previews += 1;
const diagnostics = tool.diagnostics();
return {
wasActive,
diagnostics,
previews,
dataSources: viewer.dataSources.length,
previews: diagnostics.previewSets,
handleGone: window.__gevDrawTool === undefined,
// The viewer's own select and follow run again.
clickRestored: diagnostics.stockSingleClick,
@@ -816,11 +808,9 @@ try {
JSON.stringify(destroyed.diagnostics),
);
check(
'destroy() detaches the preview data source and gives the window handle back',
destroyed.previews === 0 &&
destroyed.dataSources === beforeDestroy - 1 &&
destroyed.handleGone,
`previews ${destroyed.previews}, dataSources ${beforeDestroy} → ${destroyed.dataSources}, handle gone ${destroyed.handleGone}`,
'destroy() disposes the preview draw sets and gives the window handle back',
destroyed.previews === 0 && destroyed.handleGone,
`preview sets ${destroyed.previews}, handle gone ${destroyed.handleGone}`,
);
check(
"destroy() returns Cesium's own click actions",