diff --git a/docs/RENDERER-CONTRACT.md b/docs/RENDERER-CONTRACT.md index ddb3c0a97..3df9f2434 100644 --- a/docs/RENDERER-CONTRACT.md +++ b/docs/RENDERER-CONTRACT.md @@ -204,6 +204,12 @@ names the nearest frame's time once every globe tile drawn shows that frame's own imagery (`src/render/cesium/imageryFrames.js`). The checks `globe.imagery.frames` and `globe.imagery.video` cover both. +Every Cesium draw set takes `setColumns` (`columns`): icon sets on the GPU, +any other as the rows the columns make over the items it holds, each row the +item of that id with the columns' fields over it, replacing every item as +`set` does (`columnRows` in `src/render/cesium/draw.js`, as the stub does). +`renderer.shape` holds on Cesium. + The Cesium port also draws `pattern` line styles (the image repeated `repeat` times along the line, in the translucent pass; draped too), lines in the `inertial` frame (turned each frame by the set's motion clock, a depth-fail diff --git a/src/render/cesium/draw.js b/src/render/cesium/draw.js index 6cf84b3d5..40b47d540 100644 --- a/src/render/cesium/draw.js +++ b/src/render/cesium/draw.js @@ -128,6 +128,38 @@ const displayConditionOf = (range) => ? new Cesium.DistanceDisplayCondition(range[0], range[1]) : undefined; +/** + * `columns` on a set drawn from items: column `i` is row `ids[i]`, the item + * of that id the set holds with the columns' fields over it (`pos`, + * `course`, `show`, `scale`, `alpha`, `color` as 0..1, `meta`). Rows not + * named are gone, as `set` replaces every item. + * @param {import('../contract/draw').Columns} columns + * @param {Map} items + */ +export function columnRows(columns, items) { + const { + positions: p, + courses, + shown, + scales, + alphas, + colors, + meta, + } = columns; + return columns.ids.map((id, i) => { + const key = String(id); + const row = { ...(items.get(key) ?? { id: key }) }; + if (p) row.pos = { x: p[i * 3], y: p[i * 3 + 1], z: p[i * 3 + 2] }; + if (courses) row.course = courses[i]; + if (shown) row.show = shown[i] !== 0; + if (scales) row.scale = scales[i]; + if (alphas) row.alpha = alphas[i]; + if (colors) row.color = [0, 1, 2, 3].map((k) => colors[i * 4 + k] / 255); + if (meta) row.meta = meta[i]; + return row; + }); +} + /** * Cesium's point blending for a set's `blend`: additive ones are built * translucent, a command a set, and added where they draw (`setBlend.js`). @@ -634,6 +666,9 @@ export function createCesiumDraw({ record.gpu.columns(columns); patched(); }; + // Any other set takes columns as the rows they make, replacing its items. + else if (capabilities.has('columns')) + handle.setColumns = (columns) => handle.set(columnRows(columns, items)); sets.set(spec.id, record); setsVersion += 1; return handle; diff --git a/src/render/cesium/draw.test.mjs b/src/render/cesium/draw.test.mjs index c0eac6389..12fe8ffe7 100644 --- a/src/render/cesium/draw.test.mjs +++ b/src/render/cesium/draw.test.mjs @@ -8027,3 +8027,30 @@ test('a clustered icon set draws one icon a cluster in place of its members, mad transforms.worldToWindowCoordinates = project; } }); + +test('a points set takes columns as rows, over the items it holds', () => { + const { scene, draw } = drawOver(); + const set = draw.points({ id: 'column-dots' }); + set.set([ + { id: 'a', pos: { lon: 0, lat: 0 }, pixelSize: 4, color: '#fff' }, + { id: 'gone', pos: { lon: 1, lat: 0 }, pixelSize: 4, color: '#fff' }, + ]); + const at = Cesium.Cartesian3.fromDegrees(10, 20); + set.setColumns({ + ids: ['a'], + positions: new Float64Array([at.x, at.y, at.z]), + colors: new Uint8Array([255, 0, 0, 255]), + shown: new Uint8Array([1]), + meta: [{ m: 1 }], + }); + assert.equal(set.size(), 1, 'rows not named are gone'); + const point = scene.added[0].get(0); + assert.ok(Cesium.Cartesian3.equalsEpsilon(point.position, at, 0, 1e-6)); + assert.deepEqual( + [point.color.red, point.color.green, point.color.alpha], + [1, 0, 1], + ); + assert.equal(point.pixelSize, 4, 'kept from the item'); + assert.deepEqual(drawHitOf({ id: point.id })?.meta, { m: 1 }); + set.dispose(); +}); diff --git a/src/render/cesium/harness.js b/src/render/cesium/harness.js index 3b3df6db8..bf93f78d2 100644 --- a/src/render/cesium/harness.js +++ b/src/render/cesium/harness.js @@ -112,6 +112,7 @@ export const CESIUM_CHECKS = new Set([ 'quality.signals', 'quality.signals.gpuTiming', 'renderer.listeners', + 'renderer.shape', 'renderer.readPixels', 'renderer.releaseUnused', 'renderer.whenSettled',