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

+11 -2
View File
@@ -123,7 +123,8 @@ const dispatchers = new WeakMap();
* Ambient click subscription. Returns its unsubscribe.
* @property {(type: 'down'|'move'|'up'|'click'|'dblclick', fn: Function, options?: {lease?: object|(() => object|null)}) => () => void} onPointer
* Raw pointer subscription: `click` gets the {@link ClickEvent}, the others
* Cesium's event. With a lease, runs only while that lease is current;
* Cesium's event; `move`'s also carries `pickPosition`, its `endPosition`
* corrected for sensor styles as a click's `position` is. With a lease, runs only while that lease is current;
* without one, only while the pointer is free (`move` and `up` always run).
* @property {(reason: string) => () => void} suspendCamera Hold camera input
* off; returns this hold's release.
@@ -227,9 +228,17 @@ function createDispatcher(viewer, { createHandler, now, document } = {}) {
}),
port.on('move', (ev) => {
if (!unmodified(ev)) return;
const endPosition = cartesian(ev.endPosition ?? ev.position);
let pickPosition;
run(pointerSubscribers.move, true, {
startPosition: cartesian(ev.position),
endPosition: cartesian(ev.endPosition ?? ev.position),
endPosition,
// Where the pointer lands in the pick buffer, as a click's
// `position` is (corrected for sensor styles); made on first read.
get pickPosition() {
pickPosition ??= sensorPickPosition(viewer.scene, endPosition);
return pickPosition;
},
});
}),
port.on('up', (ev) => {