mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Remove renderer contract members nothing in the application uses
Drops from the contract, the stub, the Cesium renderer and the conformance suite: agent paths, renderer-propagated orbits and celestial draws (orbits stay drawn as icons and inertial lines), scalar raster fields, lodGroup, volume classification, icon eye offsets, the dash gap colour, box shapes, courseBlendMs (courseGlide covers easing), relief surface shading, globe clouds and water, sky atmosphere tuning, heightmap and quantized-mesh terrain, WMTS and ArcGIS imagery, the batched cached height read, the quality benchmark and the animated-style and overlay pixel-ratio knobs. Capabilities clouds, water, celestial, agents, orbits and benchmark go with them. The lodGroup check becomes a displayRange check across two sets, the height-query check uses an extruded polygon in place of a box, the shape scenes draw extruded blocks where they drew boxes, and the fields scene draws a raster shell. The shape references are recorded again.
This commit is contained in:
1 parent
71f2f12f75
commit
46cdeba7fa
37 files changed
+370
-1165
No files matched your search
+21
-23
@@ -25,17 +25,17 @@ measures and fires exactly as the stub does.
|
||||
A renderer is created by a `RendererPlugin` (`{ id, create(options) }`). It
|
||||
exposes nine ports, each typed in its own file in `src/render/contract/`:
|
||||
|
||||
| Port | File | Covers |
|
||||
| --------- | -------------- | ------------------------------------------------------------------------------ |
|
||||
| `frame` | `frame.d.ts` | The render-on-demand loop, frame phases, continuous holds, scene time |
|
||||
| `globe` | `globe.d.ts` | Base (photoreal, terrain, vector, imagery), imagery layers, split, sky |
|
||||
| `draw` | `draw.d.ts` | Draw sets: icons, points, lines, shapes, models, quads, meshes, fields, agents |
|
||||
| `camera` | `camera.d.ts` | Pose, views, flights, `lookAt`, follow, user controls, events, matrices |
|
||||
| `query` | `query.d.ts` | Picks, projection, rays, heights |
|
||||
| `input` | `input.d.ts` | Pointer events with their pick made, leases, stock behaviours |
|
||||
| `effects` | `effects.d.ts` | Screen styles, bloom, sharpen, screen modulation |
|
||||
| `credits` | `credits.d.ts` | Data credits owed |
|
||||
| `quality` | `quality.d.ts` | Quality knobs, device facts, frame signals, benchmark |
|
||||
| Port | File | Covers |
|
||||
| --------- | -------------- | ----------------------------------------------------------------------- |
|
||||
| `frame` | `frame.d.ts` | The render-on-demand loop, frame phases, continuous holds, scene time |
|
||||
| `globe` | `globe.d.ts` | Base (photoreal, terrain, vector, imagery), imagery layers, split, sky |
|
||||
| `draw` | `draw.d.ts` | Draw sets: icons, points, lines, shapes, models, quads, meshes, fields |
|
||||
| `camera` | `camera.d.ts` | Pose, views, flights, `lookAt`, follow, user controls, events, matrices |
|
||||
| `query` | `query.d.ts` | Picks, projection, rays, heights |
|
||||
| `input` | `input.d.ts` | Pointer events with their pick made, leases, stock behaviours |
|
||||
| `effects` | `effects.d.ts` | Screen styles, bloom, sharpen, screen modulation |
|
||||
| `credits` | `credits.d.ts` | Data credits owed |
|
||||
| `quality` | `quality.d.ts` | Quality knobs, device facts, frame signals |
|
||||
|
||||
Some members and options were added to version `0` later. Each is
|
||||
optional, so a renderer written before it still conforms:
|
||||
@@ -54,11 +54,11 @@ optional, so a renderer written before it still conforms:
|
||||
otherwise (not on camera moves or tile loads), so the application can key cached
|
||||
heights by it. `isSettled('surface')` says whether that surface has
|
||||
loaded what is in view; a renderer without it answers `surface` as `base`.
|
||||
- `SurfaceShading` has a `hillshade` kind: view-lit shading of the drawn
|
||||
terrain's own relief (the ellipsoid's curvature where terrain has no
|
||||
normals) that only darkens, at most `strength` opacity. The Cesium port
|
||||
draws it as a globe material it takes only while no one else holds the
|
||||
globe's material; it has no `relief` kind.
|
||||
- `SurfaceShading` is `hillshade`: view-lit shading of the drawn terrain's
|
||||
own relief (the ellipsoid's curvature where terrain has no normals) that
|
||||
only darkens, at most `strength` opacity. The Cesium port draws it as a
|
||||
globe material it takes only while no one else holds the globe's
|
||||
material.
|
||||
- Fields: `windStreamlines` takes `alpha` (changed without a rebuild) and
|
||||
`paused`; `rasterShell` replaces `detailWindow` with
|
||||
`detail: {image, rectangle}`, a sharper image drawn in place of the base
|
||||
@@ -66,8 +66,7 @@ optional, so a renderer written before it still conforms:
|
||||
says once per spec or `update` that it is drawn, never while hidden. These
|
||||
change `fields` itself rather than add to it, so the renderer follows
|
||||
`fields` before must follow them. The Cesium adapter lists `fields` and
|
||||
draws `rasterShell` and `windStreamlines`; it refuses `scalarRaster`. It
|
||||
draws streamlines only over the whole globe: it reads the grid's samples
|
||||
draws `rasterShell` and `windStreamlines`. It draws streamlines only over the whole globe: it reads the grid's samples
|
||||
as points, the first column at `rectangle.west` and the first row at
|
||||
`rectangle.north`, rows running south, and traces paths that wrap east
|
||||
and west, so it refuses a grid short of 360° of longitude.
|
||||
@@ -301,15 +300,14 @@ Browser checks use the chrome-devtools MCP against a page in its own window.
|
||||
|
||||
The Cesium scene renderer (`src/render/cesium/sceneRenderer.js`) draws the
|
||||
icon, point, line, shape, model and city scenes, and the references were
|
||||
recorded with it. It has only the members the scenes need. The quad, mesh,
|
||||
field, agent and orbit scenes have no reference yet. Each family's reference
|
||||
recorded with it. It has only the members the scenes need. The quad, mesh
|
||||
and field scenes have no reference yet. Each family's reference
|
||||
is recorded when the Cesium renderer gains that family.
|
||||
|
||||
Some behaviour is only drawn, so the logic checks cannot see it: course
|
||||
easing (`courseBlendMs`, `courseGlide`), and a hidden row keeping its eased
|
||||
easing (`courseGlide`), and a hidden row keeping its eased
|
||||
course. The stub keeps no drawn course. These wait for scenes that capture
|
||||
an icon mid-turn. Height queries that count a set
|
||||
(`includeInHeightQueries`) are not checked either: the stub's heights are
|
||||
scripted, so it does not model them. Nor are video frames (a check needs a
|
||||
video), `fetchTile` (the stub fetches nothing) or what clouds and water
|
||||
draw.
|
||||
video) or `fetchTile` (the stub fetches nothing).
|
||||
@@ -6906,12 +6906,11 @@
|
||||
"src/geo/geodesic.js",
|
||||
"src/render/camera/events.js",
|
||||
"src/render/stub/viewRectangle.js",
|
||||
"src/render/stub/orbits.js",
|
||||
"src/render/input/router.js",
|
||||
"src/render/conformance/goldens/camera.json",
|
||||
"src/render/conformance/checks/camera.js"
|
||||
],
|
||||
"external": ["satellite.js"]
|
||||
"external": []
|
||||
},
|
||||
"wildlife-sightings": {
|
||||
"exports": ["./layers/wildlife-sightings"],
|
||||
|
||||
@@ -35,15 +35,44 @@ function viewer(t, { heights = () => null } = {}) {
|
||||
}
|
||||
|
||||
const marks = () => [
|
||||
{ id: 'route', type: 'route', color: 'amber', alpha: 1, anchor: { lat: 0, lon: 0 }, path: [{ lat: 0, lon: 0 }, { lat: 0.01, lon: 0.01 }] },
|
||||
{ id: 'area', type: 'area', color: 'green', alpha: 1, anchor: { lat: 0.005, lon: 0.005 }, ring: [[0, 0], [0.01, 0], [0.01, 0.01], [0, 0]] },
|
||||
{ id: 'pin', type: 'pin', color: 'primary', alpha: 1, anchor: { lat: 0.02, lon: 0.02 } },
|
||||
{
|
||||
id: 'route',
|
||||
type: 'route',
|
||||
color: 'amber',
|
||||
alpha: 1,
|
||||
anchor: { lat: 0, lon: 0 },
|
||||
path: [
|
||||
{ lat: 0, lon: 0 },
|
||||
{ lat: 0.01, lon: 0.01 },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'area',
|
||||
type: 'area',
|
||||
color: 'green',
|
||||
alpha: 1,
|
||||
anchor: { lat: 0.005, lon: 0.005 },
|
||||
ring: [
|
||||
[0, 0],
|
||||
[0.01, 0],
|
||||
[0.01, 0.01],
|
||||
[0, 0],
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'pin',
|
||||
type: 'pin',
|
||||
color: 'primary',
|
||||
alpha: 1,
|
||||
anchor: { lat: 0.02, lon: 0.02 },
|
||||
},
|
||||
];
|
||||
|
||||
/** The live sets a mark draws into. */
|
||||
const setsOf = (draw, anno) =>
|
||||
[...draw.sets.values()].filter(
|
||||
(record) => !record.disposed && record.spec.id.startsWith(`${anno._draw.prefix}:`),
|
||||
(record) =>
|
||||
!record.disposed && record.spec.id.startsWith(`${anno._draw.prefix}:`),
|
||||
);
|
||||
|
||||
test('each mark draws in sets of its own; a hidden one has them hidden on sync, and back when shown', (t) => {
|
||||
@@ -51,25 +80,44 @@ test('each mark draws in sets of its own; a hidden one has them hidden on sync,
|
||||
const renderer = createWorldAnnotationRenderer(v);
|
||||
const [route, area, pin] = marks();
|
||||
for (const anno of [route, area, pin]) renderer.add(anno);
|
||||
for (const anno of [route, area, pin]) assert.ok(setsOf(draw, anno).length > 0, anno.id);
|
||||
for (const anno of [route, area, pin])
|
||||
assert.ok(setsOf(draw, anno).length > 0, anno.id);
|
||||
const shown = (anno) => setsOf(draw, anno).map((record) => record.show);
|
||||
|
||||
route.hidden = true;
|
||||
area.hidden = true;
|
||||
renderer.sync();
|
||||
assert.ok(shown(route).every((show) => show === false), 'the line is off');
|
||||
assert.ok(shown(area).every((show) => show === false), 'the area is off');
|
||||
assert.ok(shown(pin).every((show) => show === true), 'a visible mark stays');
|
||||
assert.ok(
|
||||
shown(route).every((show) => show === false),
|
||||
'the line is off',
|
||||
);
|
||||
assert.ok(
|
||||
shown(area).every((show) => show === false),
|
||||
'the area is off',
|
||||
);
|
||||
assert.ok(
|
||||
shown(pin).every((show) => show === true),
|
||||
'a visible mark stays',
|
||||
);
|
||||
|
||||
route.hidden = false;
|
||||
renderer.sync();
|
||||
assert.ok(shown(route).every((show) => show === true), 'the line is back');
|
||||
assert.ok(
|
||||
shown(route).every((show) => show === true),
|
||||
'the line is back',
|
||||
);
|
||||
const areaSets = setsOf(draw, area);
|
||||
renderer.remove(area);
|
||||
assert.ok(areaSets.every((record) => record.disposed), 'a removed mark lets its sets go');
|
||||
assert.ok(
|
||||
areaSets.every((record) => record.disposed),
|
||||
'a removed mark lets its sets go',
|
||||
);
|
||||
renderer.sync();
|
||||
renderer.destroy();
|
||||
assert.equal([...draw.sets.values()].filter((record) => !record.disposed).length, 0);
|
||||
assert.equal(
|
||||
[...draw.sets.values()].filter((record) => !record.disposed).length,
|
||||
0,
|
||||
);
|
||||
});
|
||||
|
||||
test('a fading mark takes its new colours in place, its pulses with them', (t) => {
|
||||
@@ -79,7 +127,10 @@ test('a fading mark takes its new colours in place, its pulses with them', (t) =
|
||||
renderer.add(route);
|
||||
renderer.add(area);
|
||||
const line = () => [...setsOf(draw, route)[0].items.values()][0];
|
||||
const fill = () => setsOf(draw, area).find((r) => r.kind === 'shapes').items.get('fill:0');
|
||||
const fill = () =>
|
||||
setsOf(draw, area)
|
||||
.find((r) => r.kind === 'shapes')
|
||||
.items.get('fill:0');
|
||||
assert.ok(Math.abs(line().style.color[3] - 0.95) < 1e-9);
|
||||
assert.ok(Math.abs(fill().fill[3] - 0.2) < 1e-9);
|
||||
route.alpha = 0.5;
|
||||
@@ -103,35 +154,79 @@ test('every kind draws as it did: draped on terrain and tiles alike, rings by ca
|
||||
const renderer = createWorldAnnotationRenderer(v);
|
||||
const [route, area, pin] = marks();
|
||||
const synth = { ...area, id: 'synth', synthesized: true };
|
||||
const arrow = { id: 'arrow', type: 'arrow', color: 'red', alpha: 1, anchor: { lon: 0, lat: 0 }, to: { lon: 0.01, lat: 0 } };
|
||||
const label = { id: 'label', type: 'label', color: 'amber', alpha: 1, anchor: { lon: 0.03, lat: 0 } };
|
||||
for (const anno of [route, area, pin, synth, arrow, label]) renderer.add(anno);
|
||||
const items = (anno, kind) => [...(setsOf(draw, anno).find((r) => r.kind === kind)?.items.values() ?? [])];
|
||||
for (const record of [...draw.sets.values()]) assert.equal(record.spec.clampTo, 'both');
|
||||
const arrow = {
|
||||
id: 'arrow',
|
||||
type: 'arrow',
|
||||
color: 'red',
|
||||
alpha: 1,
|
||||
anchor: { lon: 0, lat: 0 },
|
||||
to: { lon: 0.01, lat: 0 },
|
||||
};
|
||||
const label = {
|
||||
id: 'label',
|
||||
type: 'label',
|
||||
color: 'amber',
|
||||
alpha: 1,
|
||||
anchor: { lon: 0.03, lat: 0 },
|
||||
};
|
||||
for (const anno of [route, area, pin, synth, arrow, label])
|
||||
renderer.add(anno);
|
||||
const items = (anno, kind) => [
|
||||
...(setsOf(draw, anno)
|
||||
.find((r) => r.kind === kind)
|
||||
?.items.values() ?? []),
|
||||
];
|
||||
for (const record of [...draw.sets.values()])
|
||||
assert.equal(record.spec.clampTo, 'both');
|
||||
|
||||
const [flow] = items(route, 'lines');
|
||||
assert.equal(flow.mode, 'draped');
|
||||
assert.equal(flow.widthPx, 9);
|
||||
assert.deepEqual({ ...flow.style, color: undefined }, { kind: 'flow', color: undefined, repeat: 64, duty: 0.46, speed: 0.55 });
|
||||
assert.deepEqual(
|
||||
{ ...flow.style, color: undefined },
|
||||
{ kind: 'flow', color: undefined, repeat: 64, duty: 0.46, speed: 0.55 },
|
||||
);
|
||||
|
||||
const [areaFill] = items(area, 'shapes');
|
||||
assert.equal(areaFill.height, 'clampGround');
|
||||
assert.equal(areaFill.animate.property, 'alpha');
|
||||
assert.ok(Math.abs(areaFill.animate.periodMs - (2 * Math.PI) / 0.005) < 1e-9);
|
||||
const [areaLine] = items(area, 'lines');
|
||||
assert.deepEqual([areaLine.widthPx, areaLine.style.kind, areaLine.style.power], [6, 'glow', 0.35]);
|
||||
assert.deepEqual(
|
||||
[areaLine.widthPx, areaLine.style.kind, areaLine.style.power],
|
||||
[6, 'glow', 0.35],
|
||||
);
|
||||
const [synthLine] = items(synth, 'lines');
|
||||
assert.deepEqual([synthLine.style.kind, synthLine.style.length], ['dash', 24]);
|
||||
assert.ok(Math.abs(items(synth, 'shapes')[0].fill[3] - 0.1) < 1e-9, 'an approximate area is fainter');
|
||||
assert.deepEqual(
|
||||
[synthLine.style.kind, synthLine.style.length],
|
||||
['dash', 24],
|
||||
);
|
||||
assert.ok(
|
||||
Math.abs(items(synth, 'shapes')[0].fill[3] - 0.1) < 1e-9,
|
||||
'an approximate area is fainter',
|
||||
);
|
||||
|
||||
const [arrowLine] = items(arrow, 'lines');
|
||||
assert.deepEqual([arrowLine.mode, arrowLine.widthPx, arrowLine.style.kind], ['draped', 16, 'arrow']);
|
||||
assert.deepEqual(
|
||||
[arrowLine.mode, arrowLine.widthPx, arrowLine.style.kind],
|
||||
['draped', 16, 'arrow'],
|
||||
);
|
||||
|
||||
const [ring] = items(pin, 'shapes');
|
||||
assert.deepEqual(ring.geometry.semiMajor, { byCameraHeight: { factor: 0.03, min: 14, max: 170 } });
|
||||
assert.deepEqual(ring.geometry.semiMajor, {
|
||||
byCameraHeight: { factor: 0.03, min: 14, max: 170 },
|
||||
});
|
||||
assert.equal(ring.geometry.semiMinor, ring.geometry.semiMajor);
|
||||
const [marker] = items(pin, 'points');
|
||||
assert.deepEqual([marker.pixelSize, marker.height, marker.outlineWidth, marker.disableDepthTest], [14, 'clampGround', 3, Infinity]);
|
||||
assert.deepEqual(
|
||||
[
|
||||
marker.pixelSize,
|
||||
marker.height,
|
||||
marker.outlineWidth,
|
||||
marker.disableDepthTest,
|
||||
],
|
||||
[14, 'clampGround', 3, Infinity],
|
||||
);
|
||||
assert.equal(items(label, 'shapes').length, 0, 'a label has no ring');
|
||||
assert.equal(items(label, 'points')[0].pixelSize, 8);
|
||||
renderer.destroy();
|
||||
@@ -140,28 +235,52 @@ test('every kind draws as it did: draped on terrain and tiles alike, rings by ca
|
||||
test('a building waits for its ground probes, then draws a pulsing column, a cage and a draped base', async (t) => {
|
||||
const { v, draw, emit, frames } = viewer(t, { heights: () => 150 });
|
||||
const renderer = createWorldAnnotationRenderer(v);
|
||||
const ring = [[0, 0], [0.001, 0], [0.001, 0.001], [0, 0.001], [0, 0]];
|
||||
const ring = [
|
||||
[0, 0],
|
||||
[0.001, 0],
|
||||
[0.001, 0.001],
|
||||
[0, 0.001],
|
||||
[0, 0],
|
||||
];
|
||||
const anno = {
|
||||
id: 'b', type: 'area', color: 'amber', alpha: 1, footprintKind: 'building', buildingHeight: 40,
|
||||
anchor: { lon: 0.0005, lat: 0.0005, height: 200 }, ring,
|
||||
id: 'b',
|
||||
type: 'area',
|
||||
color: 'amber',
|
||||
alpha: 1,
|
||||
footprintKind: 'building',
|
||||
buildingHeight: 40,
|
||||
anchor: { lon: 0.0005, lat: 0.0005, height: 200 },
|
||||
ring,
|
||||
};
|
||||
const done = renderer.add(anno);
|
||||
assert.equal(frames.size, 1, 'probing on the frames');
|
||||
assert.equal(setsOf(draw, anno).length, 0, 'nothing until its ground is known');
|
||||
assert.equal(
|
||||
setsOf(draw, anno).length,
|
||||
0,
|
||||
'nothing until its ground is known',
|
||||
);
|
||||
for (let i = 0; i < 8; i++) emit();
|
||||
assert.equal((await done).status, 'installed');
|
||||
assert.equal(frames.size, 0, 'done probing');
|
||||
const shapes = [...setsOf(draw, anno).find((r) => r.kind === 'shapes').items.values()];
|
||||
const shapes = [
|
||||
...setsOf(draw, anno)
|
||||
.find((r) => r.kind === 'shapes')
|
||||
.items.values(),
|
||||
];
|
||||
const volume = shapes.find((s) => s.id === 'volume:0');
|
||||
assert.equal(volume.extrudeHeight, 150 + 40 + 24);
|
||||
assert.equal(volume.geometry.rings[0][0].height, 147);
|
||||
assert.equal(volume.height, 'absolute');
|
||||
assert.equal(volume.classifyVolume, undefined, 'a translucent column, as before');
|
||||
const cage = shapes.find((s) => s.id === 'cage:0');
|
||||
assert.equal(cage.outlineOnly, true);
|
||||
assert.ok(cage.geometry.rings[0].length <= 14);
|
||||
const [base] = setsOf(draw, anno).find((r) => r.kind === 'lines').items.values();
|
||||
assert.deepEqual([base.mode, base.widthPx, base.style.kind, base.style.power], ['draped', 3, 'glow', 0.25]);
|
||||
const [base] = setsOf(draw, anno)
|
||||
.find((r) => r.kind === 'lines')
|
||||
.items.values();
|
||||
assert.deepEqual(
|
||||
[base.mode, base.widthPx, base.style.kind, base.style.power],
|
||||
['draped', 3, 'glow', 0.25],
|
||||
);
|
||||
renderer.destroy();
|
||||
});
|
||||
|
||||
@@ -170,18 +289,35 @@ test('each kind paints the alphas it painted as entities, at full alpha', (t) =>
|
||||
const renderer = createWorldAnnotationRenderer(v);
|
||||
const [route, area, pin] = marks();
|
||||
const synth = { ...area, id: 'synth', synthesized: true };
|
||||
const arrow = { id: 'arrow', type: 'arrow', color: 'red', alpha: 1, anchor: { lon: 0, lat: 0 }, to: { lon: 0.01, lat: 0 } };
|
||||
const arrow = {
|
||||
id: 'arrow',
|
||||
type: 'arrow',
|
||||
color: 'red',
|
||||
alpha: 1,
|
||||
anchor: { lon: 0, lat: 0 },
|
||||
to: { lon: 0.01, lat: 0 },
|
||||
};
|
||||
const ring = Array.from({ length: 40 }, (_, i) => [
|
||||
0.0005 + 0.0004 * Math.cos((i / 40) * 2 * Math.PI),
|
||||
0.0005 + 0.0004 * Math.sin((i / 40) * 2 * Math.PI),
|
||||
]);
|
||||
const building = {
|
||||
id: 'b', type: 'area', color: 'amber', alpha: 1, footprintKind: 'building', buildingHeight: 40,
|
||||
anchor: { lon: 0.0005, lat: 0.0005, height: 200 }, ring,
|
||||
id: 'b',
|
||||
type: 'area',
|
||||
color: 'amber',
|
||||
alpha: 1,
|
||||
footprintKind: 'building',
|
||||
buildingHeight: 40,
|
||||
anchor: { lon: 0.0005, lat: 0.0005, height: 200 },
|
||||
ring,
|
||||
};
|
||||
for (const anno of [route, area, pin, synth, arrow]) renderer.add(anno);
|
||||
renderer.add(building, { sampledGroundHeight: 150 });
|
||||
const items = (anno, kind) => [...(setsOf(draw, anno).find((r) => r.kind === kind)?.items.values() ?? [])];
|
||||
const items = (anno, kind) => [
|
||||
...(setsOf(draw, anno)
|
||||
.find((r) => r.kind === kind)
|
||||
?.items.values() ?? []),
|
||||
];
|
||||
const alpha = (c) => Math.round(c[3] * 1000) / 1000;
|
||||
assert.equal(alpha(items(route, 'lines')[0].style.color), 0.95);
|
||||
assert.equal(alpha(items(area, 'lines')[0].style.color), 1);
|
||||
@@ -189,12 +325,19 @@ test('each kind paints the alphas it painted as entities, at full alpha', (t) =>
|
||||
assert.equal(alpha(items(arrow, 'lines')[0].style.color), 0.95);
|
||||
assert.equal(alpha(items(pin, 'shapes')[0].fill), 0.38);
|
||||
const marker = items(pin, 'points')[0];
|
||||
assert.deepEqual([alpha(marker.color), alpha(marker.outlineColor)], [1, 0.95]);
|
||||
assert.deepEqual(
|
||||
[alpha(marker.color), alpha(marker.outlineColor)],
|
||||
[1, 0.95],
|
||||
);
|
||||
assert.deepEqual(marker.outlineColor.slice(0, 3), [1, 1, 1]);
|
||||
const [volume, cage] = items(building, 'shapes');
|
||||
assert.equal(alpha(volume.fill), 0.45);
|
||||
assert.equal(alpha(cage.outline), 0.32);
|
||||
assert.equal(Math.round(cage.animate.from * 1000) / 1000, 0.192, 'the cage pulses too');
|
||||
assert.equal(
|
||||
Math.round(cage.animate.from * 1000) / 1000,
|
||||
0.192,
|
||||
'the cage pulses too',
|
||||
);
|
||||
assert.equal(cage.geometry.rings[0].length, 14, 'decimated to 14');
|
||||
assert.equal(alpha(items(building, 'lines')[0].style.color), 0.7);
|
||||
renderer.destroy();
|
||||
@@ -211,9 +354,16 @@ test('a mark removed and added again draws afresh; two renderers on one viewer k
|
||||
assert.doesNotThrow(() => first.add(route));
|
||||
assert.notEqual(route._draw.prefix, prefix, 'fresh sets');
|
||||
assert.doesNotThrow(() => second.add(area));
|
||||
assert.ok(!area._draw.prefix.startsWith(route._draw.prefix.split(':').slice(0, 2).join(':') + ':'));
|
||||
assert.ok(
|
||||
!area._draw.prefix.startsWith(
|
||||
route._draw.prefix.split(':').slice(0, 2).join(':') + ':',
|
||||
),
|
||||
);
|
||||
// Added again as another kind, its old sets go.
|
||||
const kinds = () => setsOf(draw, route).map((r) => r.kind).sort();
|
||||
const kinds = () =>
|
||||
setsOf(draw, route)
|
||||
.map((r) => r.kind)
|
||||
.sort();
|
||||
assert.deepEqual(kinds(), ['lines']);
|
||||
Object.assign(route, { type: 'pin', path: undefined });
|
||||
first.add(route);
|
||||
|
||||
@@ -102,12 +102,11 @@ test('a click on a draw-set item reads as its hit; anything else as none', (t) =
|
||||
surface: false,
|
||||
});
|
||||
assert.equal(seen[0][0], seen[0][1], 'read once per click');
|
||||
picked = { id: { set: 'quakes:1', id: 'quake:b', lodGroup: 'near' } };
|
||||
picked = { id: { set: 'quakes:1', id: 'quake:b' } };
|
||||
h.click();
|
||||
assert.deepEqual(seen.at(-1)[0], {
|
||||
set: 'quakes:1',
|
||||
id: 'quake:b',
|
||||
lodGroup: 'near',
|
||||
surface: false,
|
||||
});
|
||||
for (picked of [
|
||||
|
||||
@@ -280,7 +280,7 @@ test('height queries go through the service', () => {
|
||||
'src/layers/streetLevel/view.js',
|
||||
]);
|
||||
const NAMES =
|
||||
'sampleHeight|sampleHeightNow|sampleHeightNowMany|clampToSurface|clampToHeight|sampleHeightMostDetailed|clampToHeightMostDetailed|getHeight';
|
||||
'sampleHeight|sampleHeightNow|clampToSurface|clampToHeight|sampleHeightMostDetailed|clampToHeightMostDetailed|getHeight';
|
||||
const direct = new RegExp(
|
||||
`\\.(${NAMES})\\b|\\[\\s*['"\`](${NAMES})['"\`]\\s*\\]|\\bsampleTerrain(MostDetailed)?\\b`,
|
||||
);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* primitive collection in the scene, rebuilt when its items change (icon
|
||||
* sets, unclamped points restyled or moved, and models, change in place;
|
||||
* `drawModels.js`). Every
|
||||
* item carries a pick id `{set, id, meta, lodGroup}`, which the query port
|
||||
* item carries a pick id `{set, id, meta}`, which the query port
|
||||
* (`ports.js`) reads picks back through.
|
||||
*
|
||||
* Clamped items follow the ground as Cesium's own entities do: a clamped
|
||||
@@ -676,17 +676,7 @@ export function createCesiumDraw({
|
||||
*/
|
||||
function onGpu(record, list, replacing = false, force = false) {
|
||||
if (record.kind !== 'icons') return false;
|
||||
const wanted = record.gpu || force ? 'needs' : gpu.wants(list);
|
||||
if (!wanted) return false;
|
||||
if (wanted === 'prefers') {
|
||||
// Only a course blend: on the GPU if all of it can be, else billboards.
|
||||
try {
|
||||
gpu.check(list, record.spec);
|
||||
if (!replacing) gpu.check(record.items.values(), record.spec);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!record.gpu && !force && !gpu.wants(list)) return false;
|
||||
gpu.check(list, record.spec);
|
||||
if (record.gpu) return true;
|
||||
if (!replacing) gpu.check(record.items.values(), record.spec);
|
||||
@@ -706,7 +696,6 @@ export function createCesiumDraw({
|
||||
set: record.spec.id,
|
||||
id: item.id,
|
||||
meta: item.meta,
|
||||
lodGroup: item.lodGroup,
|
||||
};
|
||||
record.pickIds.push(id);
|
||||
return id;
|
||||
@@ -1061,8 +1050,8 @@ export function createCesiumDraw({
|
||||
}
|
||||
|
||||
/**
|
||||
* What a billboard draws of an icon item but its position, image, `meta`
|
||||
* and `lodGroup`, as plain values: the course rotation follows the
|
||||
* What a billboard draws of an icon item but its position, image and
|
||||
* `meta`, as plain values: the course rotation follows the
|
||||
* position, so it is written with it.
|
||||
*/
|
||||
function iconStyleOf(record, item) {
|
||||
@@ -1170,7 +1159,6 @@ export function createCesiumDraw({
|
||||
entry.style.rotation = item.rotation;
|
||||
}
|
||||
billboard.id.meta = item.meta;
|
||||
billboard.id.lodGroup = item.lodGroup;
|
||||
billboard.show = shownNow(record, placed);
|
||||
}
|
||||
|
||||
@@ -1232,7 +1220,6 @@ export function createCesiumDraw({
|
||||
}
|
||||
// Picks and height queries hold this id object: changed, not replaced.
|
||||
billboard.id.meta = item.meta;
|
||||
billboard.id.lodGroup = item.lodGroup;
|
||||
placed.position = position;
|
||||
placed.shown = look.show;
|
||||
billboard.show = shownNow(record, placed);
|
||||
@@ -1413,7 +1400,6 @@ export function createCesiumDraw({
|
||||
primitive,
|
||||
placed: place(record, primitive, position, show),
|
||||
at: placeOf(item),
|
||||
lodGroup: item.lodGroup,
|
||||
dot: dotLook(item).key,
|
||||
heightReference,
|
||||
});
|
||||
@@ -1448,7 +1434,6 @@ export function createCesiumDraw({
|
||||
primitive,
|
||||
placed: place(record, primitive, position, show),
|
||||
at: placeOf(item),
|
||||
lodGroup: item.lodGroup,
|
||||
look: pointLookOf(item),
|
||||
});
|
||||
}
|
||||
@@ -1661,7 +1646,6 @@ export function createCesiumDraw({
|
||||
(added ??= new Set()).add(item.id);
|
||||
continue;
|
||||
}
|
||||
if (item.lodGroup !== was.lodGroup) return false;
|
||||
if (was.dot === undefined) {
|
||||
if (heightReference !== Cesium.HeightReference.NONE) return false;
|
||||
} else if (
|
||||
@@ -1870,7 +1854,7 @@ export function createCesiumDraw({
|
||||
type: 'PolylineDash',
|
||||
uniforms: {
|
||||
color: toColor(style.color),
|
||||
gapColor: toColor(style.gapColor ?? [0, 0, 0, 0]),
|
||||
gapColor: toColor([0, 0, 0, 0]),
|
||||
dashLength: style.length,
|
||||
...(style.pattern16 !== undefined
|
||||
? { dashPattern: style.pattern16 }
|
||||
@@ -3272,18 +3256,6 @@ export function createCesiumDraw({
|
||||
vertexFormat,
|
||||
}),
|
||||
};
|
||||
case 'box': {
|
||||
const d = g.dimensions;
|
||||
return {
|
||||
fill: Cesium.BoxGeometry.fromDimensions({
|
||||
dimensions: new Cesium.Cartesian3(d.x, d.y, d.z),
|
||||
vertexFormat,
|
||||
}),
|
||||
modelMatrix: Cesium.Transforms.eastNorthUpToFixedFrame(
|
||||
toCartesian(g.center),
|
||||
),
|
||||
};
|
||||
}
|
||||
case 'wall': {
|
||||
// Up from `minimumHeights` (the ellipsoid) to `maximumHeights` (the
|
||||
// positions' own), as the entities' walls draw.
|
||||
@@ -4069,22 +4041,6 @@ export function createCesiumDraw({
|
||||
item.extrudeHeight === undefined &&
|
||||
(typeof item.fill !== 'object' || Array.isArray(item.fill));
|
||||
|
||||
/**
|
||||
* Whether an unclamped shape classifies what is inside its volume: one
|
||||
* with a volume (extruded, or a box) and a fill, on a scene that can
|
||||
* classify. Where it cannot, it draws as the volume itself.
|
||||
*/
|
||||
function classifies(item) {
|
||||
if (!item.classifyVolume || !item.fill) return false;
|
||||
if (item.extrudeHeight === undefined && item.geometry.kind !== 'box')
|
||||
return false;
|
||||
try {
|
||||
return Cesium.ClassificationPrimitive.isSupported(scene);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function buildShapes(record) {
|
||||
// Refused before anything is built: a pulse it cannot run.
|
||||
record.mayPulse = false;
|
||||
@@ -4154,37 +4110,10 @@ export function createCesiumDraw({
|
||||
show: true,
|
||||
};
|
||||
solids.set(item.id, part);
|
||||
const solid =
|
||||
item.extrudeHeight !== undefined || item.geometry.kind === 'box';
|
||||
const solid = item.extrudeHeight !== undefined;
|
||||
// `lit`: shaded by Cesium's light, or flat; by default solids are lit.
|
||||
const lit = item.lit ?? solid;
|
||||
if (classifies(item) && !item.outlineOnly) {
|
||||
if (imageFill)
|
||||
throw new Error(
|
||||
'the Cesium renderer classifies volumes with colours only',
|
||||
);
|
||||
// What lies inside the volume is tinted: the tiles and terrain it
|
||||
// covers, as `clampTo` names them.
|
||||
part.fill = host.add(
|
||||
new Cesium.ClassificationPrimitive({
|
||||
geometryInstances: new Cesium.GeometryInstance({
|
||||
geometry: shape.fill,
|
||||
modelMatrix: shape.modelMatrix,
|
||||
attributes: {
|
||||
color: Cesium.ColorGeometryInstanceAttribute.fromColor(
|
||||
toColor(item.fill),
|
||||
),
|
||||
},
|
||||
id,
|
||||
}),
|
||||
classificationType: classificationOf(
|
||||
item.clampTo ?? record.spec.clampTo ?? 'both',
|
||||
),
|
||||
allowPicking: record.spec.pickable !== false,
|
||||
asynchronous: false,
|
||||
}),
|
||||
);
|
||||
} else if (imageFill && !item.outlineOnly) {
|
||||
if (imageFill && !item.outlineOnly) {
|
||||
const material = ownMaterial(
|
||||
imageMaterial(toImage(imageFill.image), imageFill.repeat),
|
||||
);
|
||||
@@ -4223,7 +4152,7 @@ export function createCesiumDraw({
|
||||
translucent: part.translucent.fill,
|
||||
closed: solid,
|
||||
// Flat shapes unlit by default: lit, their faces shade by
|
||||
// the light (a lit box's sides differ, an unlit one's match).
|
||||
// the light (a lit block's sides differ, an unlit one's match).
|
||||
flat: !lit,
|
||||
faceForward: !solid,
|
||||
}),
|
||||
|
||||
@@ -137,7 +137,6 @@ test('a clamped point is a billboard dot that follows the ground; others stay po
|
||||
set: 'dots',
|
||||
id: 'ground',
|
||||
meta: undefined,
|
||||
lodGroup: undefined,
|
||||
});
|
||||
set.dispose();
|
||||
});
|
||||
@@ -510,13 +509,6 @@ test('hidden clamped fills wait for nothing, and the hidden ones it cannot build
|
||||
fill('a', 0, false, { outline: '#000' }),
|
||||
fill('b', 1, false, { extrudeHeight: 10 }),
|
||||
fill('c', 2, false, { fill: { preset: 'radialRim' } }),
|
||||
fill('d', 3, false, {
|
||||
geometry: {
|
||||
kind: 'box',
|
||||
center: { lon: 3, lat: 0 },
|
||||
dimensions: { x: 1, y: 1, z: 1 },
|
||||
},
|
||||
}),
|
||||
]),
|
||||
);
|
||||
assert.equal(groundsIn(scene.added.at(-1)).length, 0);
|
||||
@@ -959,16 +951,6 @@ test('colour fills carry what their appearance reads, as entities do', () =>
|
||||
extrudeHeight: 100,
|
||||
height: 'absolute',
|
||||
},
|
||||
{
|
||||
id: 'box',
|
||||
geometry: {
|
||||
kind: 'box',
|
||||
center: { lon: 1, lat: 0, height: 10 },
|
||||
dimensions: { x: 10, y: 10, z: 10 },
|
||||
},
|
||||
fill: '#fff',
|
||||
height: 'absolute',
|
||||
},
|
||||
{
|
||||
id: 'disc',
|
||||
geometry: {
|
||||
@@ -1004,7 +986,7 @@ test('colour fills carry what their appearance reads, as entities do', () =>
|
||||
}
|
||||
};
|
||||
walk(host);
|
||||
assert.equal(formats.length, 4);
|
||||
assert.equal(formats.length, 3);
|
||||
// Position and normal only: with texture coordinates too, Cesium packs
|
||||
// them with the normals, and the colour appearance misreads them.
|
||||
for (const format of formats) {
|
||||
@@ -1999,12 +1981,12 @@ test('unclamped points join and leave their collection in place, and keep what h
|
||||
assert.deepEqual(ids(), ['b', 'c', 'a']);
|
||||
// A new id sent twice is drawn once, as the last one.
|
||||
set.upsert([
|
||||
{ ...dot('n', 6), lodGroup: 'first' },
|
||||
{ ...dot('n', 6), lodGroup: 'last' },
|
||||
{ ...dot('n', 6), meta: 'first' },
|
||||
{ ...dot('n', 6), meta: 'last' },
|
||||
]);
|
||||
const picks = part.sets.get('population').pickIds;
|
||||
assert.deepEqual(
|
||||
picks.filter((pick) => pick.id === 'n').map((pick) => pick.lodGroup),
|
||||
picks.filter((pick) => pick.id === 'n').map((pick) => pick.meta),
|
||||
['last'],
|
||||
);
|
||||
set.dispose();
|
||||
@@ -4137,7 +4119,7 @@ test('an aircraft layer draws its contacts as one GPU icon set moving on the del
|
||||
unbind();
|
||||
}
|
||||
});
|
||||
test('an extruded shape that classifies its volume tints what it covers; its outline is the volume edges', () => {
|
||||
test('an extruded outline-only shape draws the volume edges, not a ring at its base', () => {
|
||||
const scene = fakeScene();
|
||||
const { draw } = drawOver(scene);
|
||||
const set = draw.shapes({ id: 'volumes' });
|
||||
@@ -4146,54 +4128,22 @@ test('an extruded shape that classifies its volume tints what it covers; its out
|
||||
{ lon: 0.001, lat: 0, height: 100 },
|
||||
{ lon: 0.001, lat: 0.001, height: 100 },
|
||||
];
|
||||
const volume = {
|
||||
id: 'volume',
|
||||
geometry: { kind: 'polygon', rings: [ring] },
|
||||
fill: [1, 0.7, 0.3, 0.45],
|
||||
extrudeHeight: 220,
|
||||
height: 'absolute',
|
||||
classifyVolume: true,
|
||||
};
|
||||
const cage = {
|
||||
id: 'cage',
|
||||
geometry: { kind: 'polygon', rings: [ring] },
|
||||
outline: [1, 0.7, 0.3, 0.32],
|
||||
outlineOnly: true,
|
||||
extrudeHeight: 220,
|
||||
height: 'absolute',
|
||||
};
|
||||
// A scene that cannot classify draws the volume itself.
|
||||
set.set([volume]);
|
||||
assert.ok(scene.added[0].get(0) instanceof Cesium.Primitive);
|
||||
assert.ok(!(scene.added[0].get(0) instanceof Cesium.ClassificationPrimitive));
|
||||
scene.context = { stencilBuffer: true };
|
||||
set.set([volume, cage]);
|
||||
const host = scene.added[0];
|
||||
const classified = host.get(0);
|
||||
assert.ok(classified instanceof Cesium.ClassificationPrimitive);
|
||||
assert.equal(classified.classificationType, Cesium.ClassificationType.BOTH);
|
||||
const [instance] = [classified.geometryInstances].flat();
|
||||
assert.ok(instance.geometry instanceof Cesium.PolygonGeometry);
|
||||
assert.deepEqual(
|
||||
[instance.geometry._extrudedHeight, instance.geometry._height].sort(
|
||||
(a, b) => a - b,
|
||||
),
|
||||
[100, 220],
|
||||
'from its base to its extruded face',
|
||||
);
|
||||
assert.equal(instance.id.id, 'volume');
|
||||
// The cage: the extruded outline, not a ring at its base.
|
||||
const edges = host.get(1);
|
||||
set.set([
|
||||
{
|
||||
id: 'cage',
|
||||
geometry: { kind: 'polygon', rings: [ring] },
|
||||
outline: [1, 0.7, 0.3, 0.32],
|
||||
outlineOnly: true,
|
||||
extrudeHeight: 220,
|
||||
height: 'absolute',
|
||||
},
|
||||
]);
|
||||
const edges = scene.added[0].get(0);
|
||||
assert.ok(edges instanceof Cesium.Primitive);
|
||||
assert.ok(
|
||||
[edges.geometryInstances].flat()[0].geometry instanceof
|
||||
Cesium.PolygonOutlineGeometry,
|
||||
);
|
||||
// An image cannot classify.
|
||||
assert.throws(
|
||||
() => set.set([{ ...volume, fill: { image: 'a.png' } }]),
|
||||
/classifies volumes with colours only/,
|
||||
);
|
||||
set.dispose();
|
||||
});
|
||||
|
||||
@@ -6218,7 +6168,6 @@ test('models re-pose and restyle in place; only a new url loads again', async ()
|
||||
set: 'planes',
|
||||
id: 'p',
|
||||
meta: { n: 1 },
|
||||
lodGroup: undefined,
|
||||
});
|
||||
|
||||
// Moved, turned and restyled: the same model, no load, no ready.
|
||||
@@ -6600,7 +6549,6 @@ test('quads draw a posed plane and its outline, changed in place', () =>
|
||||
set: 'monitors',
|
||||
id: 'q',
|
||||
meta: { camera: 'c1' },
|
||||
lodGroup: undefined,
|
||||
});
|
||||
// Scaled to its size about its centre, as a plane entity's matrix is.
|
||||
const scale = Cesium.Matrix4.getScale(
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
* `windStreamlines` (drawStreamlines.js) and `rasterShell`, a raster on a
|
||||
* rectangle raised above the ellipsoid, drawn flat in the opaque pass in
|
||||
* the scene's primitive order (ascending height), alpha-blended, without
|
||||
* depth writes and never picked. Other kinds (`scalarRaster`) are refused
|
||||
* loudly.
|
||||
* depth writes and never picked. Other kinds are refused loudly.
|
||||
*
|
||||
* Choices the contract leaves open, taken conservatively:
|
||||
* - An image is read when it is first named, as a Cesium material reads
|
||||
|
||||
@@ -628,8 +628,8 @@ test('a raster shell never swaps in a stage superseded by content still decoding
|
||||
test('the Cesium fields refuse kinds they cannot draw and live ids', () => {
|
||||
const h = fieldHarness();
|
||||
assert.throws(
|
||||
() => h.fields.field({ kind: 'scalarRaster', id: 'x' }),
|
||||
/no scalarRaster fields/,
|
||||
() => h.fields.field(/** @type {any} */ ({ kind: 'contours', id: 'x' })),
|
||||
/no contours fields/,
|
||||
);
|
||||
const spec = {
|
||||
kind: 'rasterShell',
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
/**
|
||||
* A Cesium pick as the contract's `Hit` (`query.d.ts`), when what it picked
|
||||
* is a draw-set item (its pick id is `{set, id, meta, lodGroup}`); else
|
||||
* is a draw-set item (its pick id is `{set, id, meta}`); else
|
||||
* null. For code that reads a pick Cesium already made (the click
|
||||
* dispatcher's); `query.pick` makes its own, and also leaves out items of
|
||||
* hidden or unpickable sets. It does not check that the set or item is
|
||||
@@ -21,7 +21,6 @@ export function drawHitOf(picked) {
|
||||
set: id.set,
|
||||
id: id.id,
|
||||
...(id.meta === undefined ? {} : { meta: id.meta }),
|
||||
...(id.lodGroup === undefined ? {} : { lodGroup: id.lodGroup }),
|
||||
surface: false,
|
||||
};
|
||||
}
|
||||
@@ -389,7 +389,6 @@ export function createModelSets({
|
||||
entry.item = item;
|
||||
// The pick id is the model's own object: changed where it is.
|
||||
entry.pickId.meta = item.meta;
|
||||
entry.pickId.lodGroup = item.lodGroup;
|
||||
}
|
||||
positionOf(item.pos, entry.at);
|
||||
// A fleet re-poses every frame with the same tint: parsed when it changes.
|
||||
|
||||
@@ -33,61 +33,10 @@ const ROUTES = {
|
||||
'google-ion': 'fallback',
|
||||
};
|
||||
|
||||
/** Heights of one DEM tile, decoded from its RGB pixels. */
|
||||
function decodeHeights(pixels, encoding) {
|
||||
const heights = new Float32Array(pixels.length / 4);
|
||||
for (let i = 0, p = 0; i < heights.length; i++, p += 4) {
|
||||
const r = pixels[p];
|
||||
const g = pixels[p + 1];
|
||||
const b = pixels[p + 2];
|
||||
heights[i] =
|
||||
encoding === 'mapbox'
|
||||
? -10000 + (r * 65536 + g * 256 + b) * 0.1
|
||||
: r * 256 + g + b / 256 - 32768;
|
||||
}
|
||||
return heights;
|
||||
}
|
||||
|
||||
/** A terrain provider for a heightmap DEM pyramid. */
|
||||
function heightmapTerrain(spec) {
|
||||
if (spec.geoid)
|
||||
throw new TypeError('Geoid-relative heightmaps are not supported yet');
|
||||
const size = 256;
|
||||
return new Cesium.CustomHeightmapTerrainProvider({
|
||||
width: size,
|
||||
height: size,
|
||||
tilingScheme: new Cesium.WebMercatorTilingScheme(),
|
||||
callback: async (x, y, level) => {
|
||||
// Past the pyramid a tile fails, and the globe refines its parent's.
|
||||
if (spec.maxLevel !== undefined && level > spec.maxLevel)
|
||||
throw new RangeError('Past the heightmap’s deepest level');
|
||||
const url = spec.url
|
||||
.replaceAll('{x}', String(x))
|
||||
.replaceAll('{y}', String(y))
|
||||
.replaceAll('{z}', String(level));
|
||||
const image = await Cesium.Resource.fetchImage({
|
||||
url,
|
||||
preferImageBitmap: true,
|
||||
});
|
||||
const canvas = new OffscreenCanvas(size, size);
|
||||
const context = canvas.getContext('2d');
|
||||
context.drawImage(image, 0, 0, size, size);
|
||||
return decodeHeights(
|
||||
context.getImageData(0, 0, size, size).data,
|
||||
spec.encoding,
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/** The terrain provider a spec describes, once ready. */
|
||||
async function terrainProvider(spec, { worldDataToken }) {
|
||||
if (!spec || spec.kind === 'ellipsoid')
|
||||
return new Cesium.EllipsoidTerrainProvider();
|
||||
if (spec.kind === 'quantizedMesh')
|
||||
return Cesium.CesiumTerrainProvider.fromUrl(spec.url, {
|
||||
requestVertexNormals: spec.requestVertexNormals ?? false,
|
||||
});
|
||||
if (spec.kind === 'world') {
|
||||
const accessToken = String(worldDataToken || '').trim();
|
||||
if (!accessToken)
|
||||
@@ -102,7 +51,6 @@ async function terrainProvider(spec, { worldDataToken }) {
|
||||
requestWaterMask: false,
|
||||
});
|
||||
}
|
||||
if (spec.kind === 'heightmap') return heightmapTerrain(spec);
|
||||
throw new TypeError(`Unknown terrain kind: ${spec.kind}`);
|
||||
}
|
||||
|
||||
@@ -322,11 +270,6 @@ export function createCesiumGlobe(
|
||||
const sky = {
|
||||
atmosphere:
|
||||
scene.skyAtmosphere?.show ?? scene.globe?.showGroundAtmosphere ?? false,
|
||||
atmosphereTuning: {
|
||||
brightness: scene.skyAtmosphere?.brightnessShift ?? 0,
|
||||
hueShift: scene.skyAtmosphere?.hueShift ?? 0,
|
||||
saturation: scene.skyAtmosphere?.saturationShift ?? 0,
|
||||
},
|
||||
stars: scene.skyBox?.show ?? false,
|
||||
milkyWay: scene.skyBox?.milkyWayVisibility ?? 0,
|
||||
sun: scene.sun?.show ?? false,
|
||||
@@ -337,7 +280,7 @@ export function createCesiumGlobe(
|
||||
|
||||
/** The settings as drawn: the scene's own parts, else what was set. */
|
||||
function readSky() {
|
||||
const out = { ...sky, atmosphereTuning: { ...sky.atmosphereTuning } };
|
||||
const out = { ...sky };
|
||||
if (scene.skyAtmosphere) out.atmosphere = scene.skyAtmosphere.show;
|
||||
else if (scene.globe) out.atmosphere = scene.globe.showGroundAtmosphere;
|
||||
if (scene.skyBox && 'show' in scene.skyBox) out.stars = scene.skyBox.show;
|
||||
@@ -351,23 +294,11 @@ export function createCesiumGlobe(
|
||||
}
|
||||
|
||||
function setSky(settings) {
|
||||
const { atmosphereTuning, ...rest } = settings;
|
||||
Object.assign(sky, rest);
|
||||
if (atmosphereTuning)
|
||||
sky.atmosphereTuning = { ...sky.atmosphereTuning, ...atmosphereTuning };
|
||||
Object.assign(sky, settings);
|
||||
if ('atmosphere' in settings) {
|
||||
if (scene.skyAtmosphere) scene.skyAtmosphere.show = sky.atmosphere;
|
||||
if (scene.globe) scene.globe.showGroundAtmosphere = sky.atmosphere;
|
||||
}
|
||||
if (atmosphereTuning && scene.skyAtmosphere) {
|
||||
const tuning = sky.atmosphereTuning;
|
||||
if (tuning.brightness !== undefined)
|
||||
scene.skyAtmosphere.brightnessShift = tuning.brightness;
|
||||
if (tuning.hueShift !== undefined)
|
||||
scene.skyAtmosphere.hueShift = tuning.hueShift;
|
||||
if (tuning.saturation !== undefined)
|
||||
scene.skyAtmosphere.saturationShift = tuning.saturation;
|
||||
}
|
||||
if ('stars' in settings && scene.skyBox && 'show' in scene.skyBox)
|
||||
scene.skyBox.show = sky.stars;
|
||||
if (
|
||||
|
||||
@@ -357,8 +357,8 @@ test('fetchTile fetches in place of the provider, with the URL it would fetch',
|
||||
assert.throws(
|
||||
() =>
|
||||
port.imagery.add({
|
||||
kind: 'arcgis',
|
||||
url: 'https://arcgis.invalid',
|
||||
kind: 'single-image',
|
||||
url: 'https://image.invalid/one.png',
|
||||
fetchTile: async () => ({ missing: true }),
|
||||
}),
|
||||
/xyz/,
|
||||
@@ -377,10 +377,9 @@ test('the sky reads the scene and writes through, keeping the rest', () => {
|
||||
const { scene, port } = setup();
|
||||
const before = port.sky.get();
|
||||
assert.deepEqual(
|
||||
{ ...before, atmosphereTuning: undefined },
|
||||
{ ...before },
|
||||
{
|
||||
atmosphere: true,
|
||||
atmosphereTuning: undefined,
|
||||
stars: true,
|
||||
milkyWay: 1,
|
||||
sun: true,
|
||||
@@ -389,15 +388,9 @@ test('the sky reads the scene and writes through, keeping the rest', () => {
|
||||
lighting: false,
|
||||
},
|
||||
);
|
||||
port.sky.set({
|
||||
fog: false,
|
||||
milkyWay: 0.25,
|
||||
atmosphereTuning: { hueShift: 0.1 },
|
||||
});
|
||||
port.sky.set({ fog: false, milkyWay: 0.25 });
|
||||
assert.equal(scene.fog.enabled, false);
|
||||
assert.equal(scene.skyBox.milkyWayVisibility, 0.25);
|
||||
assert.equal(scene.skyAtmosphere.hueShift, 0.1);
|
||||
assert.equal(scene.skyAtmosphere.brightnessShift, -0.08, 'tuning kept');
|
||||
// Written outside the port, as the IR mode still does: read as drawn.
|
||||
scene.fog.enabled = true;
|
||||
assert.equal(port.sky.get().fog, true);
|
||||
@@ -424,20 +417,8 @@ test('terrain: the ellipsoid with exaggeration; the last call wins', async () =>
|
||||
assert.equal(scene.verticalExaggeration, 2);
|
||||
await port.setTerrain(null);
|
||||
assert.equal(scene.verticalExaggeration, 1);
|
||||
await assert.rejects(
|
||||
port.setTerrain({
|
||||
kind: 'heightmap',
|
||||
url: '',
|
||||
encoding: 'mapbox',
|
||||
geoid: 'egm96',
|
||||
}),
|
||||
/Geoid/,
|
||||
);
|
||||
const flat = setup(new Set());
|
||||
await assert.rejects(
|
||||
flat.port.setTerrain({ kind: 'quantizedMesh', url: 'x' }),
|
||||
/no terrain/,
|
||||
);
|
||||
await assert.rejects(flat.port.setTerrain({ kind: 'world' }), /no terrain/);
|
||||
});
|
||||
|
||||
test('setBase replaces the imagery and says what it drew', async () => {
|
||||
@@ -636,15 +617,10 @@ test('hillshade shading owns a free globe material, follows the terrain, gives i
|
||||
);
|
||||
assert.throws(
|
||||
() =>
|
||||
port.setSurfaceShading({
|
||||
kind: 'relief',
|
||||
values: new Float32Array(1),
|
||||
width: 1,
|
||||
height: 1,
|
||||
rectangle: { west: 0, south: 0, east: 1, north: 1 },
|
||||
strength: 1,
|
||||
}),
|
||||
/no relief shading/,
|
||||
port.setSurfaceShading(
|
||||
/** @type {any} */ ({ kind: 'contour', strength: 1 }),
|
||||
),
|
||||
/no contour shading/,
|
||||
);
|
||||
port.setSurfaceShading({ kind: 'hillshade', strength: 0.28 });
|
||||
const curvature = scene.globe.material;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* @module render/cesium/gpuIcons
|
||||
* @description The Cesium draw port's GPU icon sets: an icon set whose items
|
||||
* move (`motionSegments`), glide their course (`courseGlide`,
|
||||
* `courseBlendMs`), recede toward the limb, pick through a larger proxy,
|
||||
* move (`motionSegments`), glide their course (`courseGlide`), recede
|
||||
* toward the limb, pick through a larger proxy,
|
||||
* switch images by drawn size, or that takes columns (`columns`), draws as
|
||||
* one instanced primitive (`IconSetPrimitive`) over an icon set's typed
|
||||
* columns (`iconSet.js`) instead of a billboard collection. Each item is one
|
||||
@@ -10,12 +10,11 @@
|
||||
* row is written only when its item changes.
|
||||
*
|
||||
* What these sets draw as billboards do not: an icon set becomes one when
|
||||
* an item first needs it (or it first takes columns), and stays one; a
|
||||
* course blend alone moves it only when all of it can move. They refuse
|
||||
* loudly what billboards draw and they do not: clamped heights,
|
||||
* `fadeByDistance`, `displayRange`, pixel and eye offsets, anchors other
|
||||
* than the centre, axis and screen rotations, opaque and additive blends,
|
||||
* and images other than URLs, SVG and atlas slots of those. Their images
|
||||
* an item first needs it (or it first takes columns), and stays one. They
|
||||
* refuse loudly what billboards draw and they do not: clamped heights,
|
||||
* `fadeByDistance`, `displayRange`, pixel offsets, anchors other than the
|
||||
* centre, axis and screen rotations, opaque and additive blends, and
|
||||
* images other than URLs, SVG and atlas slots of those. Their images
|
||||
* are rasterised square into the icon atlas every GPU icon set shares, and
|
||||
* refused when it has no room left for them: an SVG at its own size (its
|
||||
* root's larger `width`/`height`, as a billboard rasterises it), any other
|
||||
@@ -33,9 +32,6 @@
|
||||
* ids are those of the last columns, row for row.
|
||||
* - A `lerp` whose `t1` is not after `t0` steps from `from` to `to` 1 ms
|
||||
* after `t0`.
|
||||
* - A course blend eases from the course shown when its course changes;
|
||||
* writes keeping that course (and columns of neither position nor
|
||||
* course) let it go on rather than start over.
|
||||
*/
|
||||
import * as Cesium from 'cesium';
|
||||
import {
|
||||
@@ -54,10 +50,8 @@ import { contextIconSlots, IconSetPrimitive } from './iconSetPrimitive.js';
|
||||
import { iconAtlas, MAX_ICON_SLOTS } from '../../data/iconAtlas.js';
|
||||
import {
|
||||
glideOffset,
|
||||
iconCourse,
|
||||
LERP_STEP_MS,
|
||||
motionEndsAt,
|
||||
norm180,
|
||||
} from '../motion/iconMotion.js';
|
||||
import { toCartesian } from './common.js';
|
||||
|
||||
@@ -89,7 +83,6 @@ function motionOf(item) {
|
||||
course: item.course,
|
||||
motion: item.motion ? { ...item.motion } : undefined,
|
||||
courseGlide: item.courseGlide ? { ...item.courseGlide } : undefined,
|
||||
courseBlendMs: item.courseBlendMs,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -185,13 +178,8 @@ export function createGpuIcons({
|
||||
}) {
|
||||
const can = (capability) => capabilities.has(capability);
|
||||
|
||||
/**
|
||||
* Whether drawing these items needs a GPU icon set ('needs'), would only
|
||||
* draw them better on one ('prefers': a course blend, which billboards
|
||||
* draw as a snap), or neither (false).
|
||||
*/
|
||||
/** Whether drawing these items needs a GPU icon set. */
|
||||
function wants(items) {
|
||||
let prefers = false;
|
||||
for (const item of items) {
|
||||
if (
|
||||
(item.motion && can('motionSegments')) ||
|
||||
@@ -200,10 +188,9 @@ export function createGpuIcons({
|
||||
item.pickProxy ||
|
||||
item.imageLod
|
||||
)
|
||||
return 'needs';
|
||||
if (item.courseBlendMs > 0) prefers = true;
|
||||
return true;
|
||||
}
|
||||
return prefers ? 'prefers' : false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Refuse what a GPU icon set cannot draw, before anything changes. */
|
||||
@@ -223,7 +210,6 @@ export function createGpuIcons({
|
||||
if (item.fadeByDistance) refuse('fadeByDistance');
|
||||
if (item.displayRange) refuse('displayRange');
|
||||
if (nonZero(item.pixelOffset)) refuse('pixelOffset');
|
||||
if (nonZero(item.eyeOffset)) refuse('eyeOffset');
|
||||
if (item.anchor !== undefined && item.anchor !== 'center')
|
||||
refuse('anchors but the centre');
|
||||
if (item.rotationMode === 'axis') refuse('axis rotation');
|
||||
@@ -285,8 +271,8 @@ export function createGpuIcons({
|
||||
clockTime(frameState, new Cesium.JulianDate()),
|
||||
requestRender: () => requestRender(`icons:${spec.id}`),
|
||||
cull: () => spec.horizonCull === true,
|
||||
// Picked as the draw port's other items are: `{set, id, meta,
|
||||
// lodGroup}` as the item now is, hidden row by row for drill picks.
|
||||
// Picked as the draw port's other items are: `{set, id, meta}` as
|
||||
// the item now is, hidden row by row for drill picks.
|
||||
pickObject: (id, _set, primitive) => ({
|
||||
primitive,
|
||||
id: {
|
||||
@@ -295,9 +281,6 @@ export function createGpuIcons({
|
||||
get meta() {
|
||||
return record.items.get(id)?.meta;
|
||||
},
|
||||
get lodGroup() {
|
||||
return record.items.get(id)?.lodGroup;
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
@@ -305,14 +288,8 @@ export function createGpuIcons({
|
||||
// Until when (epoch ms on the motion clock) a row may still move or turn.
|
||||
let movingUntil = -Infinity;
|
||||
const clockMs = () => Cesium.JulianDate.toDate(clockTime()).getTime();
|
||||
// Each row's course blend, by id: {target, from, t0 (epoch ms), rate}.
|
||||
const blends = new Map();
|
||||
// What each row's segment was last written from, by id.
|
||||
const written = new Map();
|
||||
// What each row is drawn along now, by id: its position, course and
|
||||
// motion as the renderer reads them, and the course glide in effect
|
||||
// (`iconMotion` evaluates it as the GPU does).
|
||||
const drawn = new Map();
|
||||
// The ids of the last columns, while no other write came after them.
|
||||
let columnIds = null;
|
||||
// Written in full on the first write.
|
||||
@@ -385,12 +362,6 @@ export function createGpuIcons({
|
||||
let row = set.row(item.id);
|
||||
const added = row < 0;
|
||||
if (added) row = set.add(item.id);
|
||||
const now = clockMs();
|
||||
// The course on screen before this write, to ease from.
|
||||
const shownCourse =
|
||||
added || !drawn.has(item.id)
|
||||
? null
|
||||
: iconCourse(drawn.get(item.id), now);
|
||||
const [width = 0, height = 0] = item.size ?? [];
|
||||
const far = slotOf(item.image, item);
|
||||
const near = item.imageLod ? slotOf(item.imageLod.near, item) : far;
|
||||
@@ -445,41 +416,11 @@ export function createGpuIcons({
|
||||
glideOffset(along.motion, along.course, g),
|
||||
);
|
||||
let end = motionEndsAt(along);
|
||||
let glide = can('courseGlide') ? from.courseGlide : undefined;
|
||||
const glide = can('courseGlide') ? from.courseGlide : undefined;
|
||||
if (glide) {
|
||||
writeGlide(glide);
|
||||
end = motionEndsAt({ ...along, courseGlide: glide });
|
||||
} else if (item.courseBlendMs > 0 && shownCourse !== null) {
|
||||
const target = iconCourse(along, now);
|
||||
let blend = blends.get(item.id);
|
||||
// The same course as the blend under way heads for: it goes on.
|
||||
if (!blend || blend.target !== target) {
|
||||
// Over `courseBlendMs`: at the rate that closes the gap in that time.
|
||||
const gap = Math.abs(norm180(shownCourse - target));
|
||||
blend =
|
||||
gap > 0
|
||||
? {
|
||||
target,
|
||||
from: shownCourse,
|
||||
t0: now,
|
||||
rate: gap / (item.courseBlendMs / 1000),
|
||||
until: now + item.courseBlendMs,
|
||||
}
|
||||
: null;
|
||||
if (blend) blends.set(item.id, blend);
|
||||
else blends.delete(item.id);
|
||||
}
|
||||
if (blend) {
|
||||
glide = {
|
||||
fromCourseDeg: blend.from,
|
||||
t0: blend.t0,
|
||||
rateDps: blend.rate,
|
||||
};
|
||||
writeGlide(glide);
|
||||
end = Math.max(end, blend.until);
|
||||
}
|
||||
} else blends.delete(item.id);
|
||||
drawn.set(item.id, { ...along, courseGlide: glide });
|
||||
}
|
||||
set.segmentWritten(row);
|
||||
if (end > movingUntil) movingUntil = end;
|
||||
}
|
||||
@@ -495,9 +436,7 @@ export function createGpuIcons({
|
||||
const id = set.idAt(row);
|
||||
if (!record.items.has(id)) {
|
||||
set.remove(id);
|
||||
blends.delete(id);
|
||||
written.delete(id);
|
||||
drawn.delete(id);
|
||||
}
|
||||
}
|
||||
for (const item of record.items.values()) writeRow(item);
|
||||
@@ -519,9 +458,7 @@ export function createGpuIcons({
|
||||
columnIds = null;
|
||||
for (const id of ids) {
|
||||
set.remove(id);
|
||||
blends.delete(id);
|
||||
written.delete(id);
|
||||
drawn.delete(id);
|
||||
}
|
||||
if (record.items.size === 0) movingUntil = -Infinity;
|
||||
},
|
||||
@@ -544,9 +481,7 @@ export function createGpuIcons({
|
||||
if (!keep.has(id)) {
|
||||
record.items.delete(id);
|
||||
set.remove(id);
|
||||
blends.delete(id);
|
||||
written.delete(id);
|
||||
drawn.delete(id);
|
||||
}
|
||||
}
|
||||
const runs =
|
||||
|
||||
@@ -269,14 +269,11 @@ test('a row picks as a draw-set item, with the meta its item has now', () => {
|
||||
meta: { n: 1 },
|
||||
surface: false,
|
||||
});
|
||||
set.upsert([
|
||||
icon('a', { motion: { kind: 'hold' }, meta: { n: 2 }, lodGroup: 'g' }),
|
||||
]);
|
||||
set.upsert([icon('a', { motion: { kind: 'hold' }, meta: { n: 2 } })]);
|
||||
assert.deepEqual(drawHitOf(picked).meta, { n: 2 });
|
||||
assert.equal(drawHitOf(picked).lodGroup, 'g');
|
||||
});
|
||||
|
||||
test('a course glides at its rate with courseGlide, and eases over courseBlendMs without it', () => {
|
||||
test('a course glides at its rate with courseGlide, and turns at once without it', () => {
|
||||
const t0 = Date.now();
|
||||
const glideItem = (rateDps) =>
|
||||
icon('a', {
|
||||
@@ -293,27 +290,24 @@ test('a course glides at its rate with courseGlide, and eases over courseBlendMs
|
||||
set.set([glideItem(0)]);
|
||||
assert.ok(Math.abs(course('a', t0 + 20000) - 0) < 0.01, '0°/s holds');
|
||||
|
||||
// Without the capability: the blend over courseBlendMs instead.
|
||||
// Without the capability: the glide is ignored and the course turns at once.
|
||||
const without = drawOver({
|
||||
capabilities: new Set(['motionSegments', 'columns']),
|
||||
});
|
||||
const blended = without.draw.icons({ id: 'gpu:blend' });
|
||||
const blend = (courseDeg) =>
|
||||
const turned = without.draw.icons({ id: 'gpu:turn' });
|
||||
const turn = (courseDeg) =>
|
||||
icon('a', {
|
||||
motion: { kind: 'hold', courseDeg },
|
||||
courseBlendMs: 2000,
|
||||
courseGlide: { fromCourseDeg: 180, t0, rateDps: 1 },
|
||||
});
|
||||
blended.set([blend(0)]);
|
||||
const r = rows(without.part, 'gpu:blend');
|
||||
turned.set([turn(0)]);
|
||||
const r = rows(without.part, 'gpu:turn');
|
||||
assert.ok(
|
||||
Math.abs(r.course('a', Date.now())) < 0.01,
|
||||
'new: on course at once, its glide ignored',
|
||||
);
|
||||
blended.upsert([blend(60)]);
|
||||
const at = Date.now();
|
||||
assert.ok(Math.abs(r.course('a', at + 1000) - 30) < 1, 'halfway at 1 s');
|
||||
assert.ok(Math.abs(r.course('a', at + 2500) - 60) < 0.01, 'there by 2 s');
|
||||
turned.upsert([turn(60)]);
|
||||
assert.ok(Math.abs(r.course('a', Date.now()) - 60) < 0.01, 'turned at once');
|
||||
});
|
||||
|
||||
test('without motionSegments, motion is ignored: billboards at the item’s place', () => {
|
||||
@@ -333,7 +327,6 @@ test('GPU icon sets refuse what they cannot draw, changing nothing', () => {
|
||||
{ fadeByDistance: { near: 1, nearValue: 1, far: 2, farValue: 0 } },
|
||||
{ displayRange: [0, 10] },
|
||||
{ pixelOffset: { x: 1, y: 0 } },
|
||||
{ eyeOffset: { x: 0, y: 0, z: 5 } },
|
||||
{ anchor: 'bottom' },
|
||||
{ rotationMode: 'axis' },
|
||||
{ rotationMode: 'screen', rotation: 1 },
|
||||
@@ -465,38 +458,6 @@ test('held rows still turning keep frames coming until their course settles', ()
|
||||
const settled = scene.renders;
|
||||
part.afterRender();
|
||||
assert.equal(scene.renders, settled);
|
||||
// A course blend under way: frames until it ends.
|
||||
set.set([
|
||||
icon('a', { motion: { kind: 'hold', courseDeg: 0 }, courseBlendMs: 2000 }),
|
||||
]);
|
||||
set.upsert([
|
||||
icon('a', { motion: { kind: 'hold', courseDeg: 50 }, courseBlendMs: 2000 }),
|
||||
]);
|
||||
const blending = scene.renders;
|
||||
part.afterRender();
|
||||
assert.equal(scene.renders, blending + 1, 'blending: another frame');
|
||||
});
|
||||
|
||||
test('a course blend goes on through writes that keep its course, columns that only hide included', () => {
|
||||
const { part, draw } = drawOver({
|
||||
capabilities: new Set(['motionSegments', 'columns']),
|
||||
});
|
||||
const set = draw.icons({ id: 'gpu:blend-keep' });
|
||||
const item = (courseDeg) =>
|
||||
icon('a', { motion: { kind: 'hold', courseDeg }, courseBlendMs: 2000 });
|
||||
set.set([item(0)]);
|
||||
set.upsert([item(60)]);
|
||||
const at = Date.now();
|
||||
const r = rows(part, 'gpu:blend-keep');
|
||||
const halfway = r.course('a', at + 1000);
|
||||
// The same course again, then a column that only hides and shows it.
|
||||
set.upsert([{ ...item(60), alpha: 0.5 }]);
|
||||
set.setColumns({ ids: ['a'], shown: new Uint8Array([1]) });
|
||||
assert.ok(
|
||||
Math.abs(r.course('a', at + 1000) - halfway) < 1,
|
||||
'not restarted from where it is now',
|
||||
);
|
||||
assert.ok(Math.abs(r.course('a', at + 2500) - 60) < 0.01, 'there by 2 s');
|
||||
});
|
||||
|
||||
test('an icon set refuses, changing nothing, images the shared atlas has no room for', () => {
|
||||
@@ -522,21 +483,18 @@ test('focus fades a billboard icon as it fades a GPU one', () => {
|
||||
assert.equal(billboards.get(0).color.alpha, 1, 'at most no fade');
|
||||
});
|
||||
|
||||
test('a course blend alone moves a set onto the GPU only when all of it can go', () => {
|
||||
test('an icon set stays on billboards until an item needs the GPU', () => {
|
||||
const { scene, part, draw } = drawOver();
|
||||
const stays = draw.icons({ id: 'gpu:blend-stays' });
|
||||
stays.set([icon('a', { anchor: 'bottom', courseBlendMs: 500 })]);
|
||||
assert.equal(part.sets.get('gpu:blend-stays').gpu, undefined, 'billboards');
|
||||
const goes = draw.icons({ id: 'gpu:blend-goes' });
|
||||
goes.set([icon('a', { courseBlendMs: 500 })]);
|
||||
assert.ok(part.sets.get('gpu:blend-goes').gpu, 'on the GPU');
|
||||
const stays = draw.icons({ id: 'gpu:stays' });
|
||||
stays.set([icon('a', { anchor: 'bottom' })]);
|
||||
assert.equal(part.sets.get('gpu:stays').gpu, undefined, 'billboards');
|
||||
// A blend GPU icons do not draw is refused, not ignored.
|
||||
const additive = draw.icons({ id: 'gpu:additive', blend: 'additive' });
|
||||
assert.throws(
|
||||
() => additive.set([icon('a', { motion: { kind: 'hold' } })]),
|
||||
/additive blend/,
|
||||
);
|
||||
assert.ok(scene.added.length >= 2);
|
||||
assert.ok(scene.added.length >= 1);
|
||||
});
|
||||
|
||||
test('a write that moves a row as it already moves keeps its segment', () => {
|
||||
@@ -632,52 +590,19 @@ test('rows draw where the shared evaluator puts them, with the course it gives',
|
||||
}
|
||||
});
|
||||
|
||||
test('a course blend starts from the course shown, as the shared evaluator reads it', () => {
|
||||
const t0 = Date.now();
|
||||
const { part, draw } = drawOver();
|
||||
const set = draw.icons({ id: 'gpu:blend-parity' });
|
||||
const motion = { kind: 'hold', courseDeg: 0 };
|
||||
const item = (courseDeg) =>
|
||||
icon('a', {
|
||||
motion: { ...motion, courseDeg },
|
||||
rotationMode: 'course',
|
||||
courseBlendMs: 4000,
|
||||
});
|
||||
set.set([item(0)]);
|
||||
set.upsert([item(80)]);
|
||||
const { course } = rows(part, 'gpu:blend-parity');
|
||||
// Partway through, a new course: the next blend starts where this one is.
|
||||
const before = course('a', Date.now());
|
||||
set.upsert([item(150)]);
|
||||
const at = Date.now();
|
||||
const turn = (x, y) => Math.abs(((x - y + 540) % 360) - 180);
|
||||
assert.ok(
|
||||
turn(course('a', at), before) < 0.5,
|
||||
`no jump: ${before} then ${course('a', at)}`,
|
||||
);
|
||||
assert.ok(Math.abs(course('a', at + 10_000) - 150) < 0.01, 'then there');
|
||||
assert.ok(at - t0 < 4000, 'the test ran inside the first blend');
|
||||
});
|
||||
|
||||
test('a row keeps the course it showed when its item’s motion is changed in place', () => {
|
||||
test('a row takes its item’s motion changed in place', () => {
|
||||
const { part, draw } = drawOver();
|
||||
const set = draw.icons({ id: 'gpu:in-place' });
|
||||
const motion = { kind: 'hold', courseDeg: 0 };
|
||||
const item = icon('a', {
|
||||
motion,
|
||||
rotationMode: 'course',
|
||||
courseBlendMs: 2000,
|
||||
});
|
||||
const item = icon('a', { motion, rotationMode: 'course' });
|
||||
set.set([item]);
|
||||
motion.courseDeg = 90;
|
||||
set.upsert([item]);
|
||||
const { course } = rows(part, 'gpu:in-place');
|
||||
const at = Date.now();
|
||||
assert.ok(
|
||||
course('a', at) < 1,
|
||||
`blends from 0, not from 90: ${course('a', at)}`,
|
||||
Math.abs(course('a', Date.now()) - 90) < 0.01,
|
||||
'the written copy is not the item, so the change is seen',
|
||||
);
|
||||
assert.ok(Math.abs(course('a', at + 2500) - 90) < 0.01, 'there by 2 s');
|
||||
});
|
||||
|
||||
test('an SVG takes the atlas at its own size, other images at the item’s', async () => {
|
||||
|
||||
@@ -62,9 +62,8 @@ export const CESIUM_CHECKS = new Set([
|
||||
'draw.pick',
|
||||
'draw.points.update',
|
||||
'draw.points.population',
|
||||
'draw.lodGroup',
|
||||
'draw.displayRange',
|
||||
'draw.sets',
|
||||
'draw.shapes.classifyVolume',
|
||||
'draw.shapes.drapedRotation',
|
||||
'draw.shapes.radiusByCameraHeight',
|
||||
'effects.crossfade',
|
||||
|
||||
@@ -117,23 +117,6 @@ export function providerFor(spec, { worldDataToken } = {}) {
|
||||
...(spec.subdomains ? { subdomains: spec.subdomains } : {}),
|
||||
...common,
|
||||
});
|
||||
case 'wmts':
|
||||
if (!spec.wmts) throw new TypeError('WMTS imagery needs its wmts fields');
|
||||
return new Cesium.WebMapTileServiceImageryProvider({
|
||||
url: resourceOf(spec),
|
||||
layer: spec.wmts.layer,
|
||||
style: spec.wmts.style,
|
||||
tileMatrixSetID: spec.wmts.tileMatrixSetId,
|
||||
...(spec.wmts.format ? { format: spec.wmts.format } : {}),
|
||||
tilingScheme: tilingOf(spec.tiling),
|
||||
...(spec.subdomains ? { subdomains: spec.subdomains } : {}),
|
||||
...common,
|
||||
});
|
||||
case 'arcgis':
|
||||
return Cesium.ArcGisMapServerImageryProvider.fromUrl(resourceOf(spec), {
|
||||
enablePickFeatures: false,
|
||||
...common,
|
||||
});
|
||||
case 'single-image':
|
||||
return Cesium.SingleTileImageryProvider.fromUrl(resourceOf(spec), common);
|
||||
case 'world': {
|
||||
|
||||
@@ -166,8 +166,7 @@ test('height queries see through very large sets, built once per change', () =>
|
||||
big.set(Array.from({ length: 150_000 }, (_, i) => point(String(i))));
|
||||
assert.equal(ports.query.sampleHeightNow({ lon: 0, lat: 0 }), 10);
|
||||
assert.equal(calls[0].exclude.length, 150_000, 'every item seen through');
|
||||
const out = new Float64Array(3);
|
||||
ports.query.sampleHeightNowMany(new Float64Array(6), out);
|
||||
ports.query.sampleHeightNow({ lon: 1, lat: 1 });
|
||||
assert.ok(calls.slice(1).every((c) => c.exclude === calls[0].exclude));
|
||||
big.setOptions({ includeInHeightQueries: true });
|
||||
ports.query.sampleHeightNow({ lon: 0, lat: 0 });
|
||||
@@ -711,7 +710,10 @@ test('camera events: Cesium’s moves relayed, a throw reported, off and dispose
|
||||
off();
|
||||
scene.camera.moveStart.raiseEvent();
|
||||
assert.deepEqual(seen, ['start', 'end']);
|
||||
assert.throws(() => ports.camera.on('turned', () => {}), /Unknown camera event/);
|
||||
assert.throws(
|
||||
() => ports.camera.on('turned', () => {}),
|
||||
/Unknown camera event/,
|
||||
);
|
||||
ports.dispose();
|
||||
scene.camera.moveEnd.raiseEvent();
|
||||
scene.camera.lookRight(1);
|
||||
@@ -724,7 +726,9 @@ test('pose: degrees, and NaN where Cesium has no cartographic position', () => {
|
||||
cityView(scene.camera);
|
||||
const ports = createCesiumPorts(widget, { capabilities: all });
|
||||
const pose = ports.camera.pose();
|
||||
assert.ok(Math.abs(pose.lon + 97.74) < 1e-9 && Math.abs(pose.lat - 30.27) < 1e-9);
|
||||
assert.ok(
|
||||
Math.abs(pose.lon + 97.74) < 1e-9 && Math.abs(pose.lat - 30.27) < 1e-9,
|
||||
);
|
||||
assert.ok(Math.abs(pose.height - 2000) < 1e-6);
|
||||
scene.camera.position = new Cesium.Cartesian3(0, 0, 0);
|
||||
const centre = ports.camera.pose();
|
||||
|
||||
@@ -389,17 +389,6 @@ export function createCesiumQuery({
|
||||
if (!can('sampleHeight')) return null;
|
||||
return heightNow(point, against, seeThrough(exclude));
|
||||
},
|
||||
sampleHeightNowMany(points, out, { against = 'surface', exclude } = {}) {
|
||||
// Terrain sees through nothing, so it needs no sets to see through.
|
||||
const excluded =
|
||||
against === 'terrain' || (can('sampleHeight') && seeThrough(exclude));
|
||||
const point = { lon: 0, lat: 0 };
|
||||
for (let i = 0; i < out.length; i++) {
|
||||
point.lon = points[i * 2];
|
||||
point.lat = points[i * 2 + 1];
|
||||
out[i] = excluded ? (heightNow(point, against, excluded) ?? NaN) : NaN;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Cesium streams the finest tiles for every sample, `mostDetailed` or
|
||||
* not. Against `tiles` it streams them, then samples them with the
|
||||
|
||||
@@ -112,13 +112,6 @@ test('terrain heights answer without depth textures; the drawn surface does not'
|
||||
const point = { lon: 1, lat: 2 };
|
||||
assert.equal(query.sampleHeightNow(point, { against: 'terrain' }), 2600);
|
||||
assert.equal(query.sampleHeightNow(point), null);
|
||||
const out = new Float64Array(1);
|
||||
query.sampleHeightNowMany(new Float64Array([1, 2]), out, {
|
||||
against: 'terrain',
|
||||
});
|
||||
assert.equal(out[0], 2600);
|
||||
query.sampleHeightNowMany(new Float64Array([1, 2]), out);
|
||||
assert.ok(Number.isNaN(out[0]));
|
||||
});
|
||||
|
||||
test('nothing to query, no port', () => {
|
||||
@@ -200,9 +193,11 @@ test('a height sample hides the sets it sees through for that sample alone', ()
|
||||
[true, true, false],
|
||||
);
|
||||
|
||||
const out = new Float64Array(2);
|
||||
query.sampleHeightNowMany(new Float64Array([0, 0, 1, 0]), out);
|
||||
assert.deepEqual([...out], [12, 12]);
|
||||
const out = [
|
||||
query.sampleHeightNow({ lon: 0, lat: 0 }),
|
||||
query.sampleHeightNow({ lon: 1, lat: 0 }),
|
||||
];
|
||||
assert.deepEqual(out, [12, 12]);
|
||||
assert.deepEqual(shownWhileSampling.slice(-2), [
|
||||
[true, false, false],
|
||||
[true, false, false],
|
||||
|
||||
@@ -11,13 +11,6 @@ import {
|
||||
checkRendererShape,
|
||||
} from '../../contract/index.js';
|
||||
import { AUSTIN, SCRIPT_VIEWPORT } from '../cameraScripts.js';
|
||||
import {
|
||||
eciToEcf,
|
||||
eciToGeodetic,
|
||||
gstime,
|
||||
propagate,
|
||||
twoline2satrec,
|
||||
} from 'satellite.js';
|
||||
import { deepEqual, equal, near, nearVec, ok, throws } from '../expect.js';
|
||||
import { iconPosition } from '../../motion/iconMotion.js';
|
||||
|
||||
@@ -29,12 +22,6 @@ const PIXEL_PNGS = [
|
||||
];
|
||||
const PIXEL_PNG = PIXEL_PNGS[0];
|
||||
|
||||
/** Elements for the orbit check: a station-like orbit, epoch 2026-01-04. */
|
||||
const ISS_TLE = Object.freeze([
|
||||
'1 25544U 98067A 26004.50000000 .00016717 00000-0 10270-3 0 9992',
|
||||
'2 25544 51.6400 208.9163 0006317 69.9862 25.2906 15.49560532 10009',
|
||||
]);
|
||||
|
||||
const DOT = {
|
||||
svg: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><circle cx="8" cy="8" r="8" fill="#fff"/></svg>',
|
||||
};
|
||||
@@ -182,8 +169,6 @@ const SET_KINDS = [
|
||||
['models', 'models'],
|
||||
['quads', 'quads'],
|
||||
['meshes', 'meshes'],
|
||||
['agents', 'agents'],
|
||||
['orbits', 'orbits'],
|
||||
];
|
||||
|
||||
/** A plain style that swaps colour channels by its intensity. */
|
||||
@@ -1511,8 +1496,8 @@ export function portChecks() {
|
||||
{ capability: 'motionSegments' },
|
||||
),
|
||||
check(
|
||||
'draw.lodGroup',
|
||||
'members of a lodGroup show over their own ranges and picks report the group',
|
||||
'draw.displayRange',
|
||||
'one thing drawn near and far in two sets shows each over its own range',
|
||||
async (h, r) => {
|
||||
const pos = h.toEcef({ ...AUSTIN, height: 0 });
|
||||
const near = r.draw.points({ id: 'conf:lod-near' });
|
||||
@@ -1524,7 +1509,6 @@ export function portChecks() {
|
||||
pos,
|
||||
pixelSize: 20,
|
||||
color: '#f00',
|
||||
lodGroup: 'thing',
|
||||
displayRange: nearRange,
|
||||
},
|
||||
]);
|
||||
@@ -1534,7 +1518,6 @@ export function portChecks() {
|
||||
pos,
|
||||
image: DOT,
|
||||
size: [20, 20],
|
||||
lodGroup: 'thing',
|
||||
displayRange: farRange,
|
||||
},
|
||||
]);
|
||||
@@ -1560,8 +1543,7 @@ export function portChecks() {
|
||||
[set],
|
||||
`at ${height} m only ${set} is drawn`,
|
||||
);
|
||||
equal(hits[0]?.id, 'a', `at ${height} m the hit names the member`);
|
||||
equal(hits[0]?.lodGroup, 'thing', `at ${height} m the group`);
|
||||
equal(hits[0]?.id, 'a', `at ${height} m the hit names the item`);
|
||||
}
|
||||
members([0, 100000], [1000, Infinity]);
|
||||
await drawn(h, r);
|
||||
@@ -1570,132 +1552,12 @@ export function portChecks() {
|
||||
.map((x) => x.set)
|
||||
.sort(),
|
||||
['conf:lod-far', 'conf:lod-near'],
|
||||
'overlapping ranges show both members',
|
||||
'overlapping ranges show both',
|
||||
);
|
||||
const plain = r.draw.points({ id: 'conf:lod-none' });
|
||||
plain.set([{ id: 'b', pos, pixelSize: 20, color: '#0f0' }]);
|
||||
await drawn(h, r);
|
||||
const s = r.query.project(pos);
|
||||
const hit = r.query.drillPick(s.x, s.y).find((x) => x.id === 'b');
|
||||
ok(hit && !('lodGroup' in hit), 'an item without a group has none');
|
||||
near.dispose();
|
||||
far.dispose();
|
||||
plain.dispose();
|
||||
},
|
||||
),
|
||||
check(
|
||||
'draw.orbits',
|
||||
'an orbit is drawn where SGP4 puts it on its set’s motion clock',
|
||||
async (h, r) => {
|
||||
const t = Date.UTC(2026, 0, 4, 12);
|
||||
const expected = (ms) => {
|
||||
const date = new Date(ms);
|
||||
const satrec = twoline2satrec(ISS_TLE[0], ISS_TLE[1]);
|
||||
const eci = propagate(satrec, date).position;
|
||||
const gmst = gstime(date);
|
||||
const ecf = eciToEcf(eci, gmst);
|
||||
const geo = eciToGeodetic(eci, gmst);
|
||||
return {
|
||||
ecef: { x: ecf.x * 1000, y: ecf.y * 1000, z: ecf.z * 1000 },
|
||||
lon: (geo.longitude * 180) / Math.PI,
|
||||
lat: (geo.latitude * 180) / Math.PI,
|
||||
height: geo.height * 1000,
|
||||
};
|
||||
};
|
||||
const set = r.draw.orbits({
|
||||
id: 'conf:orbits',
|
||||
motionClock: { kind: 'scene' },
|
||||
});
|
||||
set.set([
|
||||
{
|
||||
id: 'iss',
|
||||
tle: ISS_TLE,
|
||||
marker: { pixelSize: 16, color: '#fff' },
|
||||
meta: { n: 1 },
|
||||
},
|
||||
]);
|
||||
const hitAt = (p) => {
|
||||
const s = r.query.project(p);
|
||||
return s
|
||||
? r.query
|
||||
.drillPick(s.x, s.y)
|
||||
.find((x) => x.set === 'conf:orbits' && x.id === 'iss')
|
||||
: undefined;
|
||||
};
|
||||
const now = expected(t);
|
||||
r.camera.setView({
|
||||
destination: {
|
||||
lon: now.lon,
|
||||
lat: now.lat,
|
||||
height: now.height + 2000000,
|
||||
},
|
||||
orientation: { heading: 0, pitch: -Math.PI / 2, roll: 0 },
|
||||
});
|
||||
r.frame.setTime(t);
|
||||
await drawn(h, r);
|
||||
const hit = hitAt(now.ecef);
|
||||
ok(hit, 'picked at its propagated position');
|
||||
deepEqual(hit?.meta, { n: 1 }, 'Hit.meta');
|
||||
if (hit?.position)
|
||||
nearVec(hit.position, now.ecef, 1000, 'within a kilometre of SGP4');
|
||||
r.frame.setTime(t + 60000);
|
||||
await drawn(h, r);
|
||||
const later = expected(t + 60000);
|
||||
const laterHit = hitAt(later.ecef);
|
||||
ok(laterHit, 'a minute on, where SGP4 puts it then');
|
||||
if (laterHit?.position)
|
||||
nearVec(
|
||||
laterHit.position,
|
||||
later.ecef,
|
||||
1000,
|
||||
'a minute on, within a kilometre',
|
||||
);
|
||||
ok(!hitAt(now.ecef), 'no longer where it was');
|
||||
set.dispose();
|
||||
// `orbits` alone, without `motionSegments`, still reads the clock.
|
||||
const alone = await h.create({
|
||||
viewport: SCRIPT_VIEWPORT,
|
||||
capabilities: [...r.capabilities].filter(
|
||||
(c) => c !== 'motionSegments',
|
||||
),
|
||||
});
|
||||
if (alone)
|
||||
try {
|
||||
const only = alone.draw.orbits({
|
||||
id: 'conf:orbits-alone',
|
||||
motionClock: { kind: 'scene' },
|
||||
});
|
||||
only.set([
|
||||
{
|
||||
id: 'iss',
|
||||
tle: ISS_TLE,
|
||||
marker: { pixelSize: 16, color: '#fff' },
|
||||
},
|
||||
]);
|
||||
alone.camera.setView({
|
||||
destination: {
|
||||
lon: now.lon,
|
||||
lat: now.lat,
|
||||
height: now.height + 2000000,
|
||||
},
|
||||
orientation: { heading: 0, pitch: -Math.PI / 2, roll: 0 },
|
||||
});
|
||||
alone.frame.setTime(t);
|
||||
await drawn(h, alone);
|
||||
const s = alone.query.project(now.ecef);
|
||||
ok(
|
||||
alone.query
|
||||
.drillPick(s.x, s.y)
|
||||
.some((x) => x.set === 'conf:orbits-alone'),
|
||||
'without motionSegments, on the scene clock it was given',
|
||||
);
|
||||
only.dispose();
|
||||
} finally {
|
||||
alone.destroy();
|
||||
}
|
||||
},
|
||||
{ capability: 'orbits' },
|
||||
),
|
||||
check(
|
||||
'draw.clampState',
|
||||
'clampState says whether clamped items drape or overlay',
|
||||
@@ -2078,62 +1940,6 @@ export function portChecks() {
|
||||
ok(!covers(0), 'gone with its set');
|
||||
},
|
||||
),
|
||||
check(
|
||||
'draw.shapes.classifyVolume',
|
||||
'an extruded shape that classifies its volume picks where it tints what it covers, and hides',
|
||||
async (h, r) => {
|
||||
await overAustin(h, r);
|
||||
const shapes = r.draw.shapes({ id: 'conf:volume' });
|
||||
const d = 0.002;
|
||||
const ring = [
|
||||
[-d, -d],
|
||||
[d, -d],
|
||||
[d, d],
|
||||
[-d, d],
|
||||
].map(([dLon, dLat]) => ({
|
||||
lon: AUSTIN.lon + dLon,
|
||||
lat: AUSTIN.lat + dLat,
|
||||
height: -200,
|
||||
}));
|
||||
const volume = (extra = {}) => ({
|
||||
id: 'volume',
|
||||
geometry: { kind: 'polygon', rings: [ring] },
|
||||
fill: [1, 0.7, 0.3, 0.45],
|
||||
extrudeHeight: 300,
|
||||
height: 'absolute',
|
||||
classifyVolume: true,
|
||||
...extra,
|
||||
});
|
||||
const mine = (dLon) => {
|
||||
const s = r.query.project(
|
||||
h.toEcef({ lon: AUSTIN.lon + dLon, lat: AUSTIN.lat }),
|
||||
);
|
||||
return Boolean(
|
||||
s &&
|
||||
r.query
|
||||
.drillPick(s.x, s.y)
|
||||
.some((hit) => hit.set === 'conf:volume' && hit.id === 'volume'),
|
||||
);
|
||||
};
|
||||
const until = async (test) => {
|
||||
for (let i = 0; i < 300; i++) {
|
||||
await drawn(h, r, 1);
|
||||
if (test()) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
shapes.set([volume()]);
|
||||
ok(await until(() => mine(0)), 'it picks inside');
|
||||
ok(!mine(0.008), 'and not outside');
|
||||
shapes.upsert([volume({ show: false })]);
|
||||
ok(await until(() => !mine(0)), 'hidden');
|
||||
shapes.upsert([volume()]);
|
||||
ok(await until(() => mine(0)), 'shown again');
|
||||
shapes.dispose();
|
||||
await drawn(h, r);
|
||||
ok(!mine(0), 'gone with its set');
|
||||
},
|
||||
),
|
||||
check(
|
||||
'draw.lines.styles',
|
||||
'flow lines draw draped and in space, and a line with a depth-fail colour moves every frame, without stopping the frame or picks',
|
||||
@@ -2236,7 +2042,6 @@ export function portChecks() {
|
||||
style: {
|
||||
kind: 'dash',
|
||||
color: [1, 0.6, 0.2, 1],
|
||||
gapColor: [0.2, 0.6, 1, 1],
|
||||
length: 16,
|
||||
},
|
||||
},
|
||||
@@ -2890,13 +2695,6 @@ export function portChecks() {
|
||||
near(terrain.height, 123.5, 0.01, 'terrain');
|
||||
near(tiles.height, 300, 0.01, 'tiles, not the terrain answer');
|
||||
h.scriptHeights(r, (point) => (point.lon > 0 ? null : 123.5));
|
||||
const out = new Float64Array(2);
|
||||
r.query.sampleHeightNowMany(
|
||||
new Float64Array([AUSTIN.lon, AUSTIN.lat, 10, 10]),
|
||||
out,
|
||||
);
|
||||
near(out[0], 123.5, 0.01, 'a batched cached height');
|
||||
ok(Number.isNaN(out[1]), 'a batched miss is NaN');
|
||||
const [plain] = await r.query.sampleHeight([{ ...AUSTIN }], {
|
||||
mostDetailed: true,
|
||||
});
|
||||
@@ -2931,10 +2729,21 @@ export function portChecks() {
|
||||
{
|
||||
id: 'tower',
|
||||
geometry: {
|
||||
kind: 'box',
|
||||
center: { ...AUSTIN, height: 500 },
|
||||
dimensions: { x: 200, y: 200, z: 1000 },
|
||||
kind: 'polygon',
|
||||
rings: [
|
||||
[
|
||||
[-0.001, -0.001],
|
||||
[0.001, -0.001],
|
||||
[0.001, 0.001],
|
||||
[-0.001, 0.001],
|
||||
].map(([dLon, dLat]) => ({
|
||||
lon: AUSTIN.lon + dLon,
|
||||
lat: AUSTIN.lat + dLat,
|
||||
height: 0,
|
||||
})),
|
||||
],
|
||||
},
|
||||
extrudeHeight: 1000,
|
||||
fill: '#888',
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
"points-top.png",
|
||||
"lines-top.png",
|
||||
"lines-tilted.png",
|
||||
"shapes-top.png",
|
||||
"shapes-tilted.png",
|
||||
"models-oblique.png",
|
||||
"shapes-lit-tilted.png",
|
||||
"city-orbit.png",
|
||||
"city-city.png",
|
||||
"city-street.png"
|
||||
"city-street.png",
|
||||
"shapes-top.png",
|
||||
"shapes-tilted.png",
|
||||
"shapes-lit-tilted.png"
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 6.9 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 5.6 KiB |
@@ -302,15 +302,6 @@ export const REFERENCE_SCENES = Object.freeze([
|
||||
},
|
||||
fill: '#bf5af2',
|
||||
},
|
||||
{
|
||||
id: 'box',
|
||||
geometry: {
|
||||
kind: 'box',
|
||||
center: offset(700, -400, 150),
|
||||
dimensions: { x: 300, y: 300, z: 300 },
|
||||
},
|
||||
fill: '#ff9f0a',
|
||||
},
|
||||
{
|
||||
id: 'outline',
|
||||
geometry: { kind: 'polygon', rings: [square(0, -1000, 200)] },
|
||||
@@ -326,7 +317,7 @@ export const REFERENCE_SCENES = Object.freeze([
|
||||
],
|
||||
},
|
||||
{
|
||||
// `ShapeItem.lit`: a lit box's faces shade apart, an unlit one's match;
|
||||
// `ShapeItem.lit`: a lit block's faces shade apart, an unlit one's match;
|
||||
// a flat square lit, beside one drawn flat. Lit, the default renderer
|
||||
// shades a flat square's two triangles apart (a seam on the diagonal):
|
||||
// that is its lighting, recorded as it is.
|
||||
@@ -342,19 +333,26 @@ export const REFERENCE_SCENES = Object.freeze([
|
||||
offset(east + half, north + half, 5),
|
||||
offset(east - half, north + half, 5),
|
||||
];
|
||||
const box = (id, east, lit) => ({
|
||||
const block = (id, east, lit) => ({
|
||||
id,
|
||||
geometry: {
|
||||
kind: 'box',
|
||||
center: offset(east, 300, 150),
|
||||
dimensions: { x: 300, y: 300, z: 300 },
|
||||
kind: 'polygon',
|
||||
rings: [
|
||||
[
|
||||
offset(east - 150, 150, 0),
|
||||
offset(east + 150, 150, 0),
|
||||
offset(east + 150, 450, 0),
|
||||
offset(east - 150, 450, 0),
|
||||
],
|
||||
],
|
||||
},
|
||||
extrudeHeight: 300,
|
||||
fill: '#ff9f0a',
|
||||
lit,
|
||||
});
|
||||
set.set([
|
||||
box('lit-box', -400, true),
|
||||
box('flat-box', 400, false),
|
||||
block('lit-block', -400, true),
|
||||
block('flat-block', 400, false),
|
||||
{
|
||||
id: 'lit-square',
|
||||
geometry: { kind: 'polygon', rings: [square(-400, -500, 200)] },
|
||||
@@ -450,24 +448,15 @@ export const REFERENCE_SCENES = Object.freeze([
|
||||
capability: 'fields',
|
||||
async build(r) {
|
||||
await bare(r);
|
||||
const width = 32;
|
||||
const height = 16;
|
||||
const values = new Float32Array(width * height).map(
|
||||
(_, i) => (i % width) / width,
|
||||
);
|
||||
const field = r.draw.field({
|
||||
kind: 'scalarRaster',
|
||||
id: 'ref:scalar',
|
||||
values,
|
||||
width,
|
||||
height,
|
||||
kind: 'rasterShell',
|
||||
id: 'ref:shell',
|
||||
// A 1 × 1 red PNG, stretched over the rectangle.
|
||||
image:
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==',
|
||||
rectangle: { west: -100, south: 28, east: -95, north: 32 },
|
||||
ramp: [
|
||||
{ value: 0, color: '#0a84ff' },
|
||||
{ value: 0.5, color: '#34c759' },
|
||||
{ value: 1, color: '#ff3b30' },
|
||||
],
|
||||
alpha: 0.8,
|
||||
heightM: 10000,
|
||||
alpha: 0.6,
|
||||
});
|
||||
return () => field.dispose();
|
||||
},
|
||||
@@ -478,27 +467,6 @@ export const REFERENCE_SCENES = Object.freeze([
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'agents',
|
||||
family: 'agents',
|
||||
capability: 'agents',
|
||||
async build(r, ctx) {
|
||||
await bare(r);
|
||||
const set = r.draw.agents({ id: 'ref:agents' });
|
||||
set.set([
|
||||
{
|
||||
id: 'road',
|
||||
positions: [ctx.toEcef(offset(-800, 0)), ctx.toEcef(offset(800, 0))],
|
||||
count: 20,
|
||||
speedMps: 0,
|
||||
color: '#ffd60a',
|
||||
pixelSize: 6,
|
||||
},
|
||||
]);
|
||||
return disposeAll(set);
|
||||
},
|
||||
views: [{ name: 'top', view: over(2500) }],
|
||||
},
|
||||
{
|
||||
id: 'city',
|
||||
family: 'city',
|
||||
|
||||
@@ -26,7 +26,7 @@ function contractOnly(renderer) {
|
||||
return (...args) =>
|
||||
guard(
|
||||
value.apply(obj, args),
|
||||
key === 'field' || key === 'celestial' ? 'handle' : 'drawSet',
|
||||
key === 'field' ? 'handle' : 'drawSet',
|
||||
);
|
||||
const nested = Object.keys(MEMBERS[port]).some((m) =>
|
||||
m.startsWith(`${member}.`),
|
||||
@@ -80,7 +80,6 @@ test('every reference scene builds and disposes on the stub through the contract
|
||||
'quads',
|
||||
'meshes',
|
||||
'fields',
|
||||
'agents',
|
||||
'city',
|
||||
])
|
||||
assert.ok(ids.has(family), `a ${family} scene`);
|
||||
|
||||
Vendored
+2
-14
@@ -162,10 +162,6 @@ export type Capability =
|
||||
| 'surfaceShading'
|
||||
/** A version of what surface heights answer against (`globe.surfaceVersion`). */
|
||||
| 'surfaceIdentity'
|
||||
/** Volumetric clouds (`globe.setClouds`). */
|
||||
| 'clouds'
|
||||
/** A water surface on the oceans (`globe.setWater`). */
|
||||
| 'water'
|
||||
/** Main-thread tile hooks: `tileTransform`, `admit` and `canvas` imagery. */
|
||||
| 'imageHooks'
|
||||
/** A screen-space sector modulation pass (a sweeping sonar band). */
|
||||
@@ -188,14 +184,8 @@ export type Capability =
|
||||
| 'quads'
|
||||
/** Custom meshes in a local east-north-up frame. */
|
||||
| 'meshes'
|
||||
/** Wind streamlines, scalar rasters and raised raster shells. */
|
||||
/** Wind streamlines and raised raster shells. */
|
||||
| 'fields'
|
||||
/** Stars and orbit rings in an inertial frame. */
|
||||
| 'celestial'
|
||||
/** Agents moving along polylines (traffic flow). */
|
||||
| 'agents'
|
||||
/** Satellites propagated by the renderer from their elements (`draw.orbits`). */
|
||||
| 'orbits'
|
||||
/** Rate-limited course easing (`IconItem.courseGlide`). */
|
||||
| 'courseGlide'
|
||||
/** Screen-space clustering of icons. */
|
||||
@@ -213,6 +203,4 @@ export type Capability =
|
||||
/** Reading the frame the eye is placed in (`camera.followFrame`). */
|
||||
| 'followFrame'
|
||||
/** A `threshold` per `changed` listener (`camera.on`). */
|
||||
| 'cameraChangeThreshold'
|
||||
/** A built-in quality benchmark. */
|
||||
| 'benchmark';
|
||||
| 'cameraChangeThreshold';
|
||||
Vendored
+5
-113
@@ -68,8 +68,7 @@ export interface SetSpec {
|
||||
/** What clamped items clamp to. */
|
||||
clampTo?: ClampTarget;
|
||||
/**
|
||||
* `motionSegments` or `orbits`: the clock motion segments and orbits are
|
||||
* evaluated on.
|
||||
* `motionSegments`: the clock motion segments are evaluated on.
|
||||
* `live` (the default) is wall time minus `delayMs`, as a live feed is
|
||||
* drawn a little behind real time; `scene` is the frame port's scene time.
|
||||
*/
|
||||
@@ -90,14 +89,6 @@ export interface Placed {
|
||||
fadeByDistance?: NearFar;
|
||||
/** Shown only at eye distances in `[near, far)`, metres. */
|
||||
displayRange?: [near: number, far: number];
|
||||
/**
|
||||
* Items in different sets that share a `lodGroup` are one thing drawn at
|
||||
* different detail (a model near, an icon far), each shown over its own
|
||||
* `displayRange`. A renderer may draw the group as one entity; a pick on
|
||||
* it names the member shown at that distance (`Hit.set`, `Hit.id`) and
|
||||
* reports the group (`Hit.lodGroup`).
|
||||
*/
|
||||
lodGroup?: string;
|
||||
/** Draw over depth within this many metres of the eye (`Infinity`: always). */
|
||||
disableDepthTest?: number;
|
||||
}
|
||||
@@ -124,9 +115,8 @@ export type ImageRef =
|
||||
* climbing along the fix's up axis at `climbMps` (default 0). The elapsed
|
||||
* time is clamped to `[minDtS, maxDtS]`; a negative `minDtS` runs the same
|
||||
* path backward before `t0` (a warm-up), `maxDtS` is how long it coasts.
|
||||
* The drawn course eases onto a new one over the item's `courseBlendMs`; an
|
||||
* item that also has `courseGlide` eases at its rate instead, on a renderer
|
||||
* with the `courseGlide` capability.
|
||||
* The drawn course turns onto a new one at once; an item with `courseGlide`
|
||||
* eases at its rate instead, on a renderer with the `courseGlide` capability.
|
||||
*/
|
||||
export type MotionSegment =
|
||||
| { kind: 'hold'; courseDeg?: number }
|
||||
@@ -170,12 +160,6 @@ export interface IconItem extends Placed {
|
||||
motion?: MotionSegment;
|
||||
/** `courseGlide`: ease the drawn course at a rate, from `fromCourseDeg`. */
|
||||
courseGlide?: CourseGlide;
|
||||
/**
|
||||
* Ease the drawn course onto a new one over this long; 0 or omitted turns
|
||||
* at once. The renderer has it; with the `courseGlide` capability an
|
||||
* item's `courseGlide`, when it has one, is used instead.
|
||||
*/
|
||||
courseBlendMs?: number;
|
||||
/** Degrees clockwise from north. */
|
||||
course?: number;
|
||||
/**
|
||||
@@ -189,8 +173,6 @@ export interface IconItem extends Placed {
|
||||
/** ECEF axis for `rotationMode: 'axis'`. */
|
||||
alignedAxis?: Vec3;
|
||||
pixelOffset?: ScreenXY;
|
||||
/** Offset toward the eye, metres in eye space. */
|
||||
eyeOffset?: Vec3;
|
||||
anchor?: 'center' | 'bottom' | 'top';
|
||||
/** Swap to `near` when drawn larger than `switchPx`. */
|
||||
imageLod?: { near: ImageRef; switchPx: number };
|
||||
@@ -212,13 +194,7 @@ export interface PointItem extends Placed {
|
||||
export type LineStyle =
|
||||
| { kind: 'solid'; color: Color }
|
||||
| { kind: 'glow'; color: Color; power: number; taper?: number }
|
||||
| {
|
||||
kind: 'dash';
|
||||
color: Color;
|
||||
gapColor?: Color;
|
||||
length: number;
|
||||
pattern16?: number;
|
||||
}
|
||||
| { kind: 'dash'; color: Color; length: number; pattern16?: number }
|
||||
| { kind: 'arrow'; color: Color }
|
||||
| { kind: 'pattern'; image: ImageRef; repeat: number }
|
||||
| { kind: 'flow'; color: Color; repeat: number; duty: number; speed: number };
|
||||
@@ -297,12 +273,6 @@ export type ShapeGeometry =
|
||||
* image fill turns with it.
|
||||
*/
|
||||
| { kind: 'rectangle'; rect: GeoRect; height?: number; rotation?: number }
|
||||
| {
|
||||
kind: 'box';
|
||||
center: Position;
|
||||
dimensions: Vec3;
|
||||
orientation?: Quaternion;
|
||||
}
|
||||
| {
|
||||
kind: 'wall';
|
||||
positions: Position[];
|
||||
@@ -322,13 +292,11 @@ export interface ShapeItem {
|
||||
extrudeHeight?: number;
|
||||
height?: 'absolute' | 'clampGround';
|
||||
clampTo?: ClampTarget;
|
||||
/** Classify what is inside the volume (tint the tiles it covers). */
|
||||
classifyVolume?: boolean;
|
||||
/** Pull toward the eye, metres, to win depth against coplanar surfaces. */
|
||||
depthBias?: number;
|
||||
/**
|
||||
* Shaded by the renderer's fixed light (true) or flat colour (false).
|
||||
* Omitted: lit for extruded shapes and boxes, flat otherwise. A renderer
|
||||
* Omitted: lit for extruded shapes, flat otherwise. A renderer
|
||||
* may draw clamped shapes, which drape on the surface, flat whatever it
|
||||
* says.
|
||||
*/
|
||||
@@ -412,17 +380,6 @@ export type FieldSpec =
|
||||
/** Draw the paths still, dimmed. */
|
||||
paused?: boolean;
|
||||
}
|
||||
| {
|
||||
kind: 'scalarRaster';
|
||||
id: string;
|
||||
values: Float32Array;
|
||||
width: number;
|
||||
height: number;
|
||||
rectangle: GeoRect;
|
||||
/** Colour ramp: value stops in ascending order. */
|
||||
ramp: Array<{ value: number; color: Color }>;
|
||||
alpha?: number;
|
||||
}
|
||||
| {
|
||||
/**
|
||||
* A raster on a sphere raised above the ground. Shells draw in
|
||||
@@ -456,65 +413,6 @@ export interface FieldHandle extends Handle {
|
||||
on(event: 'drawn', cb: () => void): Off;
|
||||
}
|
||||
|
||||
export type CelestialSpec =
|
||||
| {
|
||||
kind: 'stars';
|
||||
id: string;
|
||||
/**
|
||||
* Packed stars; omitted draws the renderer's own catalogue (one it
|
||||
* streams, say), down to `magnitudeLimit`, or no stars when it has
|
||||
* none.
|
||||
*/
|
||||
catalogue?: Float32Array;
|
||||
magnitudeLimit?: number;
|
||||
}
|
||||
| {
|
||||
kind: 'orbitRings';
|
||||
id: string;
|
||||
/** Each ring: packed `x, y, z` in the inertial frame, metres. */
|
||||
rings: Float64Array[];
|
||||
color: Color;
|
||||
widthPx: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* `orbits`: a satellite from its elements. The renderer propagates it with
|
||||
* SGP4 on its set's `motionClock` and draws the marker and, optionally, its
|
||||
* ring. Without the capability the app propagates and draws the positions
|
||||
* itself as icons and lines.
|
||||
*/
|
||||
export interface OrbitItem {
|
||||
id: string;
|
||||
/** A two-line element set. */
|
||||
tle: [line1: string, line2: string];
|
||||
marker:
|
||||
| { image: ImageRef; size: [width: number, height: number] }
|
||||
| { pixelSize: number; color: Color };
|
||||
/** The orbit's ring over `periods` orbits (default 1), in the inertial frame. */
|
||||
ring?: { color: Color; widthPx: number; periods?: number } | null;
|
||||
meta?: Meta;
|
||||
show?: boolean;
|
||||
pickable?: boolean;
|
||||
/** As on `Placed`. */
|
||||
displayRange?: [near: number, far: number];
|
||||
lodGroup?: string;
|
||||
}
|
||||
|
||||
/** `agents`: dots moving along polylines (traffic flow). */
|
||||
export interface AgentPathItem {
|
||||
id: string;
|
||||
positions: Ecef[] | Float64Array;
|
||||
/** Agents on this path. */
|
||||
count: number;
|
||||
speedMps: number;
|
||||
/** 0 flows freely; 1 stopped; between creeps. */
|
||||
congestion?: number;
|
||||
color: Color;
|
||||
pixelSize: number;
|
||||
fadeByDistance?: NearFar;
|
||||
meta?: Meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Columnar update for large sets (`columns`). Column `i` of each array is
|
||||
* row `ids[i]`. `dirty` limits the upload to these index runs.
|
||||
@@ -580,12 +478,6 @@ export interface DrawPort {
|
||||
meshes?(spec: SetSpec): DrawSet<MeshItem>;
|
||||
/** `fields`. */
|
||||
field?(spec: FieldSpec): FieldHandle;
|
||||
/** `celestial`: drawn in an inertial frame rotated by sidereal time. */
|
||||
celestial?(spec: CelestialSpec): Handle;
|
||||
/** `agents`. */
|
||||
agents?(spec: SetSpec): DrawSet<AgentPathItem>;
|
||||
/** `orbits`. */
|
||||
orbits?(spec: SetSpec): DrawSet<OrbitItem>;
|
||||
/**
|
||||
* Whether clamped items (`clampTo: 'tiles' | 'both'`, draped lines and
|
||||
* shapes) are draped onto the 3D tiles now (`draped`), or drawn over them
|
||||
|
||||
Vendored
+7
-43
@@ -31,21 +31,11 @@ export interface PhotorealStatus {
|
||||
*/
|
||||
export type TerrainSpec = (
|
||||
| { kind: 'ellipsoid' }
|
||||
| { kind: 'quantizedMesh'; url: string; requestVertexNormals?: boolean }
|
||||
/**
|
||||
* The renderer's global terrain, through `CreateOptions.worldDataToken`
|
||||
* (for the default renderer, Cesium World Terrain).
|
||||
*/
|
||||
| { kind: 'world'; requestVertexNormals?: boolean }
|
||||
/** A DEM image pyramid (`{z}/{x}/{y}`), heights encoded in RGB. */
|
||||
| {
|
||||
kind: 'heightmap';
|
||||
url: string;
|
||||
encoding: 'terrarium' | 'mapbox';
|
||||
maxLevel?: number;
|
||||
/** The geoid the encoded heights are relative to; omitted: the ellipsoid. */
|
||||
geoid?: 'egm96' | 'egm2008';
|
||||
}
|
||||
) & {
|
||||
/** Vertical exaggeration of the drawn terrain; default 1. */
|
||||
exaggeration?: number;
|
||||
@@ -75,20 +65,13 @@ export interface ImagerySpec {
|
||||
* `CreateOptions.worldDataToken` (for the default renderer, Cesium ion's
|
||||
* world imagery), in `worldStyle`. `canvas`: `imageHooks`.
|
||||
*/
|
||||
kind: 'xyz' | 'wmts' | 'arcgis' | 'world' | 'single-image' | 'canvas';
|
||||
kind: 'xyz' | 'world' | 'single-image' | 'canvas';
|
||||
/** `world`: aerial (the default), or aerial with labels. */
|
||||
worldStyle?: 'aerial' | 'aerialLabels';
|
||||
/** URL or URL template (`{x}`, `{y}`, `{z}`, `{s}`, `{time}`). */
|
||||
url?: string;
|
||||
/** `'canvas'` (`imageHooks`): draws one tile. */
|
||||
drawTile?: (tile: TileRequest, canvas: HTMLCanvasElement) => void;
|
||||
/** WMTS: layer, style, tile matrix set and format. */
|
||||
wmts?: {
|
||||
layer: string;
|
||||
style: string;
|
||||
tileMatrixSetId: string;
|
||||
format?: string;
|
||||
};
|
||||
subdomains?: string[];
|
||||
tiling?: TilingScheme;
|
||||
rectangle?: GeoRect;
|
||||
@@ -216,11 +199,6 @@ export interface BaseStatus {
|
||||
*/
|
||||
export interface SkySettings {
|
||||
atmosphere: boolean;
|
||||
atmosphereTuning?: {
|
||||
brightness?: number;
|
||||
hueShift?: number;
|
||||
saturation?: number;
|
||||
};
|
||||
stars: boolean;
|
||||
/** Milky Way brightness, 0..1. */
|
||||
milkyWay: number;
|
||||
@@ -232,22 +210,12 @@ export interface SkySettings {
|
||||
lighting: boolean;
|
||||
}
|
||||
|
||||
export type SurfaceShading =
|
||||
| {
|
||||
kind: 'relief';
|
||||
/** Elevation-like field to shade, row-major, `width × height`. */
|
||||
values: Float32Array;
|
||||
width: number;
|
||||
height: number;
|
||||
rectangle: GeoRect;
|
||||
strength: number;
|
||||
}
|
||||
/**
|
||||
* View-lit shading of the drawn terrain's own relief (the ellipsoid's
|
||||
* curvature where terrain has no normals); darkens only, at most
|
||||
* `strength` opacity.
|
||||
*/
|
||||
| { kind: 'hillshade'; strength: number };
|
||||
/**
|
||||
* View-lit shading of the drawn terrain's own relief (the ellipsoid's
|
||||
* curvature where terrain has no normals); darkens only, at most
|
||||
* `strength` opacity.
|
||||
*/
|
||||
export type SurfaceShading = { kind: 'hillshade'; strength: number };
|
||||
|
||||
export interface LoadProgress {
|
||||
tilesPending: number;
|
||||
@@ -287,10 +255,6 @@ export interface GlobePort {
|
||||
surfaceVersion?(): number;
|
||||
/** `surfaceShading`. */
|
||||
setSurfaceShading?(shading: SurfaceShading | null): void;
|
||||
/** `clouds`: the renderer's volumetric clouds, or none. */
|
||||
setClouds?(clouds: { coverage: number } | null): void;
|
||||
/** `water`: the renderer's own water surface on the oceans, on or off. */
|
||||
setWater?(enabled: boolean): void;
|
||||
readonly imagery: {
|
||||
/**
|
||||
* Without `imageHooks`, a spec with `tileTransform`, `admit` or kind
|
||||
|
||||
@@ -24,8 +24,6 @@ export const CAPABILITIES = Object.freeze([
|
||||
'imageryFrames',
|
||||
'surfaceShading',
|
||||
'surfaceIdentity',
|
||||
'clouds',
|
||||
'water',
|
||||
'imageHooks',
|
||||
'screenModulation',
|
||||
'gpuTiming',
|
||||
@@ -38,9 +36,6 @@ export const CAPABILITIES = Object.freeze([
|
||||
'quads',
|
||||
'meshes',
|
||||
'fields',
|
||||
'celestial',
|
||||
'agents',
|
||||
'orbits',
|
||||
'courseGlide',
|
||||
'cluster',
|
||||
'styles',
|
||||
@@ -50,7 +45,6 @@ export const CAPABILITIES = Object.freeze([
|
||||
'globeVisibility',
|
||||
'followFrame',
|
||||
'cameraChangeThreshold',
|
||||
'benchmark',
|
||||
]);
|
||||
|
||||
/** @type {readonly import('./frame').FrameStep[]} */
|
||||
@@ -69,7 +63,6 @@ export const FRAME_STEPS = Object.freeze([
|
||||
/** Every quality setting a renderer may support. */
|
||||
export const QUALITY_KEYS = Object.freeze([
|
||||
'pixelRatio',
|
||||
'overlayPixelRatio',
|
||||
'msaa',
|
||||
'tiles3dDetail',
|
||||
'terrainDetail',
|
||||
@@ -83,7 +76,6 @@ export const QUALITY_KEYS = Object.freeze([
|
||||
'particles',
|
||||
'models',
|
||||
'postFx',
|
||||
'animatedStyleFps',
|
||||
'sonarCadenceHz',
|
||||
'targetFps',
|
||||
]);
|
||||
@@ -154,8 +146,6 @@ export const PORTS = deepFreeze({
|
||||
['isGlobeVisible', 'globeVisibility'],
|
||||
['surfaceVersion', 'surfaceIdentity'],
|
||||
['setSurfaceShading', 'surfaceShading'],
|
||||
['setClouds', 'clouds'],
|
||||
['setWater', 'water'],
|
||||
['imagery.getSplit', 'splitSwipe'],
|
||||
['imagery.setSplit', 'splitSwipe'],
|
||||
]),
|
||||
@@ -173,9 +163,6 @@ export const PORTS = deepFreeze({
|
||||
['quads', 'quads'],
|
||||
['meshes', 'meshes'],
|
||||
['field', 'fields'],
|
||||
['celestial', 'celestial'],
|
||||
['agents', 'agents'],
|
||||
['orbits', 'orbits'],
|
||||
]),
|
||||
camera: Object.fromEntries([
|
||||
...required(
|
||||
@@ -232,7 +219,6 @@ export const PORTS = deepFreeze({
|
||||
'projectMany',
|
||||
'isOccluded',
|
||||
'sampleHeightNow',
|
||||
'sampleHeightNowMany',
|
||||
'sampleHeight',
|
||||
'clampToSurface',
|
||||
'rayCast',
|
||||
@@ -269,8 +255,8 @@ export const PORTS = deepFreeze({
|
||||
['screenModulation', 'screenModulation'],
|
||||
]),
|
||||
credits: Object.fromEntries(required('addStatic', 'list', 'on')),
|
||||
quality: Object.fromEntries([
|
||||
...required(
|
||||
quality: Object.fromEntries(
|
||||
required(
|
||||
'knobs',
|
||||
'get',
|
||||
'set',
|
||||
@@ -280,8 +266,7 @@ export const PORTS = deepFreeze({
|
||||
'signals.gpuTiming',
|
||||
'signals.on',
|
||||
),
|
||||
['benchmark', 'benchmark'],
|
||||
]),
|
||||
),
|
||||
drawSet: Object.fromEntries([
|
||||
...required(
|
||||
'id',
|
||||
|
||||
Vendored
-15
@@ -8,8 +8,6 @@ import type { Off } from './common';
|
||||
export interface QualitySettings {
|
||||
/** Absolute device pixel ratio for the scene; 0 = browser recommended. */
|
||||
pixelRatio: number;
|
||||
/** Pixel ratio of screen-space overlays. */
|
||||
overlayPixelRatio: number;
|
||||
msaa: 0 | 2 | 4 | 8;
|
||||
/** 0..1: 3D tile detail (screen-space error, both directions). */
|
||||
tiles3dDetail: number;
|
||||
@@ -25,8 +23,6 @@ export interface QualitySettings {
|
||||
particles: number;
|
||||
models: { maxInstances: number; maxDistance: number };
|
||||
postFx: { bloom: boolean; sharpen: boolean; style: 'low' | 'high' };
|
||||
/** Frame rate of animated styles. */
|
||||
animatedStyleFps: number;
|
||||
/** Updates per second of a screen modulation sweep. */
|
||||
sonarCadenceHz: number;
|
||||
targetFps: number;
|
||||
@@ -90,12 +86,6 @@ export interface ProbeResult {
|
||||
knobs: KnobDescriptor[];
|
||||
}
|
||||
|
||||
export interface BenchResult {
|
||||
frames: number;
|
||||
cpuMs: { median: number; p95: number };
|
||||
gpuMs?: { median: number; p95: number };
|
||||
}
|
||||
|
||||
export interface QualityPort {
|
||||
/** The settings this renderer supports, with ranges, defaults and costs. */
|
||||
knobs(): KnobDescriptor[];
|
||||
@@ -108,9 +98,4 @@ export interface QualityPort {
|
||||
readonly gpuTiming: 'none' | 'frame' | 'perPass';
|
||||
on(event: 'frame', cb: (signals: FrameSignals) => void): Off;
|
||||
};
|
||||
/** `benchmark`: the renderer's own; the governor has a default. */
|
||||
benchmark?(options: {
|
||||
durationMs: number;
|
||||
scene?: 'standard';
|
||||
}): Promise<BenchResult>;
|
||||
}
|
||||
Vendored
-12
@@ -19,8 +19,6 @@ export interface Hit {
|
||||
id: string;
|
||||
/** The item's `meta`, as it was given; absent when the item had none. */
|
||||
meta?: Meta;
|
||||
/** The item's `lodGroup`, when it has one: the thing it is a detail level of. */
|
||||
lodGroup?: string;
|
||||
/** The map itself (tiles or globe), rather than a drawn item. */
|
||||
surface: boolean;
|
||||
/** Where the hit is, when the renderer knows it. */
|
||||
@@ -96,16 +94,6 @@ export interface QueryPort {
|
||||
isOccluded(position: Ecef): boolean;
|
||||
/** `sampleHeight`: cached height now, or null when not loaded. */
|
||||
sampleHeightNow(point: LonLat, options?: HeightOptions): number | null;
|
||||
/**
|
||||
* `sampleHeight`: cached heights for many points at once: packed `lon, lat`
|
||||
* degrees in, one height per point out (NaN when not loaded). The app makes
|
||||
* its per-frame height reads through this, once a frame.
|
||||
*/
|
||||
sampleHeightNowMany(
|
||||
points: Float64Array,
|
||||
out: Float64Array,
|
||||
options?: HeightOptions,
|
||||
): void;
|
||||
/**
|
||||
* `sampleHeight`: heights, loading as needed; null per miss.
|
||||
* `mostDetailed` (`finestHeights`) waits for the finest data.
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
* Positions and courses come from the shared evaluator (`iconMotion.js`), on
|
||||
* the set's motion clock: pass the same epoch ms the set draws at (wall time
|
||||
* less its `delayMs` for a live clock, the frame port's time for a scene
|
||||
* clock). An item's `courseBlendMs` is not modelled: an item easing its
|
||||
* course by it reads its target course (give it a `courseGlide` to read the
|
||||
* eased one).
|
||||
* clock). An item's course eases only by its `courseGlide`.
|
||||
*/
|
||||
import { iconCourse, iconPosition } from './iconMotion.js';
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import { cssColor } from '../color.js';
|
||||
import { CAPABILITIES, CONTRACT_VERSION } from '../contract/index.js';
|
||||
import { createStubCamera } from './camera.js';
|
||||
import { motionPosition } from '../motion/iconMotion.js';
|
||||
import { orbitPosition } from './orbits.js';
|
||||
import { computeViewRectangle } from './viewRectangle.js';
|
||||
import {
|
||||
add,
|
||||
@@ -510,12 +509,6 @@ export function createStubRenderer(options = {}) {
|
||||
if (capabilities.has('quads')) draw.quads = (spec) => makeSet('quads', spec);
|
||||
if (capabilities.has('meshes'))
|
||||
draw.meshes = (spec) => makeSet('meshes', spec);
|
||||
if (capabilities.has('agents'))
|
||||
draw.agents = (spec) => makeSet('agents', spec);
|
||||
/** Parsed orbit elements, by line pair; cleared on destroy. */
|
||||
const satrecs = new Map();
|
||||
if (capabilities.has('orbits'))
|
||||
draw.orbits = (spec) => makeSet('orbits', spec);
|
||||
if (capabilities.has('fields'))
|
||||
draw.field = (spec) => {
|
||||
const handle = simpleHandle('field', spec);
|
||||
@@ -554,8 +547,6 @@ export function createStubRenderer(options = {}) {
|
||||
};
|
||||
return handle;
|
||||
};
|
||||
if (capabilities.has('celestial'))
|
||||
draw.celestial = (spec) => simpleHandle('celestial', spec);
|
||||
|
||||
// --- Query -----------------------------------------------------------------
|
||||
|
||||
@@ -618,10 +609,6 @@ export function createStubRenderer(options = {}) {
|
||||
}
|
||||
|
||||
function itemPosition(set, item, aheadMs = 0) {
|
||||
if (set.kind === 'orbits')
|
||||
return item.tle
|
||||
? orbitPosition(satrecs, item.tle, motionTime(set) + aheadMs)
|
||||
: null;
|
||||
if (!item.pos) return null;
|
||||
const base = toEcef(item.pos);
|
||||
if (
|
||||
@@ -755,25 +742,6 @@ export function createStubRenderer(options = {}) {
|
||||
);
|
||||
}
|
||||
|
||||
/** Whether `lon`, `lat` (degrees) is inside a ring of positions. */
|
||||
function inRing(ring, lon, lat) {
|
||||
const points = ring.map((p) => {
|
||||
const c = toCartographicRadians(toEcef(p));
|
||||
return [toDegrees(c.lon), toDegrees(c.lat)];
|
||||
});
|
||||
let inside = false;
|
||||
for (let i = 0, j = points.length - 1; i < points.length; j = i++) {
|
||||
const [xi, yi] = points[i];
|
||||
const [xj, yj] = points[j];
|
||||
if (
|
||||
yi > lat !== yj > lat &&
|
||||
lon < ((xj - xi) * (lat - yi)) / (yj - yi) + xi
|
||||
)
|
||||
inside = !inside;
|
||||
}
|
||||
return inside;
|
||||
}
|
||||
|
||||
/**
|
||||
* The pickable items under a pixel, nearest first. With a `depth`, only
|
||||
* the nearest `depth` things drawn there are looked through, unpickable
|
||||
@@ -809,10 +777,9 @@ export function createStubRenderer(options = {}) {
|
||||
continue;
|
||||
}
|
||||
if (set.kind === 'shapes') {
|
||||
// Draped rectangles and ellipses, and volumes that classify what
|
||||
// they cover, are picked where they cover the ellipsoid (rectangles
|
||||
// turned as the default renderer turns them); other shapes are not
|
||||
// picked.
|
||||
// Draped rectangles and ellipses are picked where they cover the
|
||||
// ellipsoid (rectangles turned as the default renderer turns them);
|
||||
// other shapes are not picked.
|
||||
const ground = rayEllipsoid(pickRay(x, y));
|
||||
const at = ground && toCartographicRadians(ground);
|
||||
if (!at) continue;
|
||||
@@ -823,14 +790,9 @@ export function createStubRenderer(options = {}) {
|
||||
if (!item.fill || item.outlineOnly) continue;
|
||||
const g = item.geometry;
|
||||
const covers =
|
||||
item.height === 'clampGround'
|
||||
? (g?.kind === 'rectangle' && inRectangle(g, lon, lat)) ||
|
||||
(g?.kind === 'ellipse' && inEllipse(g, lon, lat))
|
||||
: item.classifyVolume === true &&
|
||||
item.extrudeHeight !== undefined &&
|
||||
g?.kind === 'polygon' &&
|
||||
inRing(g.rings[0], lon, lat) &&
|
||||
!g.rings.slice(1).some((hole) => inRing(hole, lon, lat));
|
||||
item.height === 'clampGround' &&
|
||||
((g?.kind === 'rectangle' && inRectangle(g, lon, lat)) ||
|
||||
(g?.kind === 'ellipse' && inEllipse(g, lon, lat)));
|
||||
if (!covers) continue;
|
||||
hits.push({
|
||||
set: setId,
|
||||
@@ -847,8 +809,7 @@ export function createStubRenderer(options = {}) {
|
||||
if (
|
||||
set.kind !== 'icons' &&
|
||||
set.kind !== 'points' &&
|
||||
set.kind !== 'models' &&
|
||||
set.kind !== 'orbits'
|
||||
set.kind !== 'models'
|
||||
)
|
||||
continue;
|
||||
for (const item of set.items.values()) {
|
||||
@@ -868,10 +829,8 @@ export function createStubRenderer(options = {}) {
|
||||
continue;
|
||||
const s = project(p);
|
||||
if (!s) continue;
|
||||
const pixel = item.pixelSize ?? item.marker?.pixelSize ?? 10;
|
||||
const size = item.pickProxy?.size ??
|
||||
item.size ??
|
||||
item.marker?.size ?? [pixel, pixel];
|
||||
const pixel = item.pixelSize ?? 10;
|
||||
const size = item.pickProxy?.size ?? item.size ?? [pixel, pixel];
|
||||
const scale = item.scaleByDistance
|
||||
? nearFarValue(item.scaleByDistance, distance)
|
||||
: 1;
|
||||
@@ -885,7 +844,6 @@ export function createStubRenderer(options = {}) {
|
||||
set: setId,
|
||||
id: item.id,
|
||||
meta: item.meta,
|
||||
...(item.lodGroup !== undefined ? { lodGroup: item.lodGroup } : {}),
|
||||
surface: false,
|
||||
position: p,
|
||||
depth: distance,
|
||||
@@ -1034,15 +992,6 @@ export function createStubRenderer(options = {}) {
|
||||
const key = cacheKey(point, opts.against);
|
||||
return heightCache.has(key) ? heightCache.get(key) : null;
|
||||
},
|
||||
sampleHeightNowMany(points, out, opts = {}) {
|
||||
for (let i = 0; i < out.length; i++) {
|
||||
const height = query.sampleHeightNow(
|
||||
{ lon: points[i * 2], lat: points[i * 2 + 1] },
|
||||
opts,
|
||||
);
|
||||
out[i] = height ?? NaN;
|
||||
}
|
||||
},
|
||||
async sampleHeight(points, opts = {}) {
|
||||
if (!capabilities.has('sampleHeight')) return points.map(() => null);
|
||||
return points.map((point) => {
|
||||
@@ -1319,16 +1268,6 @@ export function createStubRenderer(options = {}) {
|
||||
log('globe', 'setSurfaceShading', [shading]);
|
||||
requestRender('base');
|
||||
};
|
||||
if (capabilities.has('clouds'))
|
||||
globe.setClouds = (clouds) => {
|
||||
log('globe', 'setClouds', [clouds]);
|
||||
requestRender('base');
|
||||
};
|
||||
if (capabilities.has('water'))
|
||||
globe.setWater = (water) => {
|
||||
log('globe', 'setWater', [water]);
|
||||
requestRender('base');
|
||||
};
|
||||
if (capabilities.has('splitSwipe')) {
|
||||
globe.imagery.getSplit = () => split;
|
||||
globe.imagery.setSplit = (x01) => {
|
||||
@@ -1534,11 +1473,6 @@ export function createStubRenderer(options = {}) {
|
||||
},
|
||||
},
|
||||
};
|
||||
if (capabilities.has('benchmark'))
|
||||
quality.benchmark = async ({ durationMs }) => ({
|
||||
frames: Math.round(durationMs / FRAME_MS),
|
||||
cpuMs: { median: 0, p95: 0 },
|
||||
});
|
||||
|
||||
// --- Renderer --------------------------------------------------------------
|
||||
|
||||
@@ -1625,7 +1559,6 @@ export function createStubRenderer(options = {}) {
|
||||
for (const clear of onceTimers) clear();
|
||||
onceTimers.clear();
|
||||
sets.clear();
|
||||
satrecs.clear();
|
||||
sceneFrameLayers.clear();
|
||||
frameFlushes.clear();
|
||||
},
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* @module render/stub/orbits
|
||||
* @description Where an orbit item is at a time: its two-line elements
|
||||
* propagated with SGP4 and turned into Earth-fixed metres.
|
||||
*/
|
||||
import { eciToEcf, gstime, propagate, twoline2satrec } from 'satellite.js';
|
||||
|
||||
/**
|
||||
* @param {Map<string, object>} satrecs Parsed elements by line pair, the caller's cache.
|
||||
* @param {[string, string]} tle
|
||||
* @param {number} t Epoch ms.
|
||||
* @returns {{x: number, y: number, z: number}|null} ECEF metres, or null when the elements cannot be propagated to `t`.
|
||||
*/
|
||||
export function orbitPosition(satrecs, tle, t) {
|
||||
const key = `${tle[0]}\n${tle[1]}`;
|
||||
let satrec = satrecs.get(key);
|
||||
if (!satrec) {
|
||||
satrec = twoline2satrec(tle[0], tle[1]);
|
||||
satrecs.set(key, satrec);
|
||||
}
|
||||
const date = new Date(t);
|
||||
const state = propagate(satrec, date);
|
||||
const eci = state?.position;
|
||||
if (!eci || typeof eci !== 'object') return null;
|
||||
const ecf = eciToEcf(eci, gstime(date));
|
||||
return { x: ecf.x * 1000, y: ecf.y * 1000, z: ecf.z * 1000 };
|
||||
}
|
||||
@@ -141,40 +141,6 @@ test('a draped rectangle across the antimeridian picks on both sides of it, turn
|
||||
r.destroy();
|
||||
});
|
||||
|
||||
test('an extruded volume that classifies picks inside its outer ring and not in its holes', () => {
|
||||
const r = createStubRenderer();
|
||||
r.camera.setView({
|
||||
destination: { lon: 0, lat: 0, height: 20_000 },
|
||||
orientation: { heading: 0, pitch: -Math.PI / 2, roll: 0 },
|
||||
});
|
||||
const shapes = r.draw.shapes({ id: 'volume' });
|
||||
const square = (d) =>
|
||||
[
|
||||
[-d, -d],
|
||||
[d, -d],
|
||||
[d, d],
|
||||
[-d, d],
|
||||
].map(([lon, lat]) => ({ lon, lat, height: -50 }));
|
||||
shapes.set([
|
||||
{
|
||||
id: 'v',
|
||||
geometry: { kind: 'polygon', rings: [square(0.02), square(0.005)] },
|
||||
fill: '#f80',
|
||||
extrudeHeight: 100,
|
||||
height: 'absolute',
|
||||
classifyVolume: true,
|
||||
},
|
||||
]);
|
||||
const picked = (lon, lat) => {
|
||||
const s = r.query.project(toEcef({ lon, lat, height: 0 }));
|
||||
return r.query.drillPick(s.x, s.y).some((hit) => hit.set === 'volume');
|
||||
};
|
||||
assert.ok(picked(0.012, 0), 'between its rings');
|
||||
assert.ok(!picked(0, 0), 'not in its hole');
|
||||
assert.ok(!picked(0.03, 0), 'not outside');
|
||||
r.destroy();
|
||||
});
|
||||
|
||||
test('the stub says where it draws an item, for a camera that is not its own', () => {
|
||||
const r = createStubRenderer();
|
||||
const t0 = r.frame.time();
|
||||
|
||||
Reference in new issue
Block a user