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
@@ -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],
|
||||
|
||||
Reference in new issue
Block a user