mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 08:42:21 +00:00
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:
1 parent
c49191a87b
commit
3cce1aaa3e
7 files changed
+198
-167
No files matched your search
+11
-2
@@ -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) => {
|
||||
|
||||
@@ -426,6 +426,28 @@ test('sensor styles move the pick to where the picture came from', () => {
|
||||
assert.deepEqual([plain.x, plain.y], [300, 50]);
|
||||
});
|
||||
|
||||
test('a move carries its pick-buffer position, sensor-corrected as a click is', (t) => {
|
||||
const h = harness();
|
||||
t.after(() => h.input.destroy());
|
||||
Object.assign(h.viewer.scene.canvas, {
|
||||
clientWidth: 400,
|
||||
clientHeight: 200,
|
||||
width: 400,
|
||||
height: 200,
|
||||
});
|
||||
const stage = { enabled: true, uniforms: { intensity: 1, pixelation: 4 } };
|
||||
registerStyleStages(h.viewer.scene, { surveillance: stage });
|
||||
const seen = [];
|
||||
h.input.onPointer('move', (event) => seen.push(event));
|
||||
h.handler.fire(TYPES.MOUSE_MOVE, { endPosition: { x: 300, y: 50 } });
|
||||
const expected = sensorPickPosition(h.viewer.scene, { x: 300, y: 50 });
|
||||
assert.deepEqual(
|
||||
[seen[0].pickPosition.x, seen[0].pickPosition.y],
|
||||
[expected.x, expected.y],
|
||||
);
|
||||
assert.deepEqual([seen[0].endPosition.x, seen[0].endPosition.y], [300, 50]);
|
||||
});
|
||||
|
||||
test('the dispatcher is the package input export', async () => {
|
||||
const exported = await import('gods-eye-view/input');
|
||||
assert.equal(exported.inputFor, inputFor);
|
||||
|
||||
Reference in new issue
Block a user