From d5e3968caa1b7dcf07746c19efc19fbcc4867020 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Tue, 10 Nov 2026 09:46:11 -0800 Subject: [PATCH] Draw outlined draped lines with their outline; relay pinches for an early Ctrl+wheel A draped solid line with an outline went into a colour batch and lost its edge; it now draws by its own outline material. A camera controller that binds Ctrl+wheel before the controls are made relays trackpad pinches from the start, not only after the binding is set again. A raster shell image zero pixels wide is left to the material, as before. --- src/render/cesium/cameraControls.js | 2 ++ src/render/cesium/cameraControls.test.mjs | 18 +++++++++++++ src/render/cesium/draw.js | 8 ++++-- src/render/cesium/draw.test.mjs | 32 +++++++++++++++++++++++ src/render/cesium/drawFields.js | 2 +- 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/render/cesium/cameraControls.js b/src/render/cesium/cameraControls.js index 925fab34b..7e1c69941 100644 --- a/src/render/cesium/cameraControls.js +++ b/src/render/cesium/cameraControls.js @@ -250,6 +250,8 @@ export function createCesiumControls({ relayPinches(value.includes('ctrlWheel')); }, }; + // A controller that already binds Ctrl+wheel relays pinches from the start. + relayPinches(controls.zoomInputs.includes('ctrlWheel')); return { controls, diff --git a/src/render/cesium/cameraControls.test.mjs b/src/render/cesium/cameraControls.test.mjs index d1ae6eb67..e211e5058 100644 --- a/src/render/cesium/cameraControls.test.mjs +++ b/src/render/cesium/cameraControls.test.mjs @@ -157,6 +157,24 @@ test('ctrlWheel relays trackpad pinches while it is bound, and not after', () => assert.deepEqual(relays, ['on', 'off', 'on', 'off'], 'none after dispose'); }); +test('a controller that already binds Ctrl+wheel relays pinches from the start', () => { + const scene = sceneWithController(); + const c = scene.screenSpaceCameraController; + c.zoomEventTypes = [WHEEL, { eventType: WHEEL, modifier: CTRL }]; + const relays = []; + const { dispose } = createCesiumControls({ + scene, + widget: { container: {} }, + pinchRelay: () => { + relays.push('on'); + return () => relays.push('off'); + }, + }); + assert.deepEqual(relays, ['on']); + dispose(); + assert.deepEqual(relays, ['on', 'off']); +}); + test('suspend shares the scene’s holds with other users', () => { const scene = sceneWithController(); const c = scene.screenSpaceCameraController; diff --git a/src/render/cesium/draw.js b/src/render/cesium/draw.js index 39511154c..594f3a44c 100644 --- a/src/render/cesium/draw.js +++ b/src/render/cesium/draw.js @@ -1944,8 +1944,12 @@ export function createCesiumDraw({ }); } - /** Whether a draped line draws in a batch of solid ones. */ - const batchable = (item) => item.style.kind === 'solid' && !revealed(item); + /** + * Whether a draped line draws in a batch of solid ones: a batch draws + * colours only, so an outlined line draws by its own material. + */ + const batchable = (item) => + item.style.kind === 'solid' && !item.style.outline && !revealed(item); /** * A ground primitive of a draped line's own, drawn by a material (a diff --git a/src/render/cesium/draw.test.mjs b/src/render/cesium/draw.test.mjs index 8acfe7f07..02412a79a 100644 --- a/src/render/cesium/draw.test.mjs +++ b/src/render/cesium/draw.test.mjs @@ -215,6 +215,38 @@ test('draped lines are ground polylines; a rebuild keeps the old ones until the assert.equal(scene.added.length, 0); }); +test('a draped outlined line keeps its outline in its own material', () => + withImageClasses(() => { + const { scene, draw } = drawOver(); + const set = draw.lines({ id: 'edged' }); + set.set([ + { + id: 'a', + positions: [ + { lon: 0, lat: 0 }, + { lon: 1, lat: 1 }, + ], + widthPx: 6, + mode: 'draped', + style: { + kind: 'solid', + color: '#7fe6ed', + outline: { color: '#000000', widthPx: 2 }, + }, + }, + ]); + const host = scene.added[0]; + const grounds = []; + for (let i = 0; i < host.length; i++) + if (host.get(i) instanceof Cesium.GroundPolylinePrimitive) + grounds.push(host.get(i)); + assert.equal(grounds.length, 1); + const { material } = grounds[0].appearance; + assert.equal(material.type, 'PolylineOutline'); + assert.equal(material.uniforms.outlineWidth, 2); + set.dispose(); + })); + test('clamped fills are ground primitives packed so none overlap within one', () => { const { scene, draw } = drawOver(); const set = draw.shapes({ id: 'discs' }); diff --git a/src/render/cesium/drawFields.js b/src/render/cesium/drawFields.js index fa0a4497a..5cc6d64be 100644 --- a/src/render/cesium/drawFields.js +++ b/src/render/cesium/drawFields.js @@ -353,7 +353,7 @@ function placeIn(outer, inner) { * pixel wide image would never draw. Doubling the column samples the same. */ function widened(source) { - if (!(source?.width < 2)) return source; + if (source?.width !== 1) return source; const canvas = typeof document !== 'undefined' ? document.createElement('canvas')