mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Draw moving icon sets on the GPU through the Cesium draw port
An icon set whose items move along motion segments, glide their course, recede toward the limb, pick through a larger proxy or switch images by drawn size, or that takes columns, now draws as one instanced IconSetPrimitive in place of its billboards. The set switches the first time an item needs it (or columns arrive) and stays switched; a course blend alone switches it only when everything it holds can go. The Cesium ports advertise columns, motionSegments and courseGlide. GPU sets refuse loudly what billboards draw and they do not: clamped heights, fadeByDistance, displayRange, offsets, anchors other than the centre, axis and screen rotations, opaque and additive blends, images other than URLs and SVG, and more images than the shared atlas has room for. A refused write changes nothing. The shared icon columns gain an image switch size, a pick proxy and a per-row depth-test distance (defaulting to always over depth, as before), arcs gain a climb rate, and the epoch rebases in both directions. Rows keep asking for frames while they move, turn or blend; a write that moves a row as it already moves (a restyle, a focus change) leaves its segment alone. Billboard icons now fade with focus as GPU ones do. Conformance gains columns and motion checks for the Cesium adapter.
This commit is contained in:
1 parent
f0427fc63e
commit
bb85e0fa74
15 files changed
+1675
-39
No files matched your search
@@ -4,6 +4,7 @@ import * as Cesium from 'cesium';
|
||||
import {
|
||||
createIconSet,
|
||||
DirtyRows,
|
||||
ICON_ALWAYS_OVER_DEPTH,
|
||||
ICON_CULL_HEIGHT_M,
|
||||
ICON_CULL_LIFT,
|
||||
ICON_ROTATES,
|
||||
@@ -14,6 +15,7 @@ import {
|
||||
writeCourseGlide,
|
||||
writeHoldSegment,
|
||||
} from './iconSegment.js';
|
||||
import { liftedForHorizon } from '../geo/horizon.js';
|
||||
|
||||
function place(set, id, lon, course = 0) {
|
||||
const row = set.add(id, { id });
|
||||
@@ -228,6 +230,21 @@ test('rebasing moves the epoch without moving any row', () => {
|
||||
assert.deepEqual(set.dirty.segments.runs(set.count), [[0, 0]]);
|
||||
});
|
||||
|
||||
test('a clock set back more than half an hour moves the epoch back too', () => {
|
||||
const epoch = Cesium.JulianDate.fromIso8601('2026-11-03T12:00:00Z');
|
||||
const set = createIconSet({ epoch });
|
||||
const row = place(set, 'a', 4);
|
||||
const before = set.position(row, 0);
|
||||
const earlier = (s) =>
|
||||
Cesium.JulianDate.addSeconds(epoch, s, new Cesium.JulianDate());
|
||||
assert.equal(set.rebase(earlier(-1000)), false);
|
||||
assert.equal(set.rebase(earlier(-86400)), true);
|
||||
assert.equal(set.seconds(earlier(-86400)), 0);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.distance(set.position(row, 86400), before) < 0.01,
|
||||
);
|
||||
});
|
||||
|
||||
test('a cull-lift row is judged at no lower than the cull height above the ellipsoid', () => {
|
||||
const set = createIconSet();
|
||||
const row = set.add('a');
|
||||
@@ -249,3 +266,71 @@ test('a cull-lift row is judged at no lower than the cull height above the ellip
|
||||
'a contact floored higher keeps its own height',
|
||||
);
|
||||
});
|
||||
|
||||
test('the Cesium-free horizon lift judges the point a cull-lift row is judged at', () => {
|
||||
const set = createIconSet();
|
||||
const row = set.add('a');
|
||||
set.setFlag(row, ICON_CULL_LIFT, true);
|
||||
for (const [lon, lat, h] of [
|
||||
[4.05, 51.93, -40],
|
||||
[4.05, 51.93, 3],
|
||||
[-84.43, 33.64, 11.9],
|
||||
[139.7, 35.6, 500],
|
||||
[0, 89.5, -10],
|
||||
]) {
|
||||
const p = Cesium.Cartesian3.fromDegrees(lon, lat, h);
|
||||
const lifted = liftedForHorizon(p);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.distance(set.cullPoint(row, p), lifted) < 1e-6,
|
||||
`${lon}, ${lat}, ${h} m`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('a new row draws over depth everywhere, with no proxy and the default image switch', () => {
|
||||
const set = createIconSet();
|
||||
const row = set.add('a');
|
||||
assert.equal(set.depthTestDistance(row), Math.fround(ICON_ALWAYS_OVER_DEPTH));
|
||||
assert.equal(set.pickProxyWidth(row), 0);
|
||||
assert.equal(set.pickProxyHeight(row), 0);
|
||||
assert.equal(set.imageSwitch(row), 0);
|
||||
});
|
||||
|
||||
test('the switch, proxy and depth-test columns mark the row only when they change', () => {
|
||||
const set = createIconSet();
|
||||
const row = set.add('a');
|
||||
settle(set);
|
||||
set.setImageSwitch(row, 40);
|
||||
set.setPickProxy(row, 30, 20);
|
||||
set.setDepthTestDistance(row, 5000);
|
||||
assert.deepEqual(set.dirty.style.runs(set.count), [[0, 0]]);
|
||||
assert.equal(set.imageSwitch(row), 40);
|
||||
assert.equal(set.pickProxyWidth(row), 30);
|
||||
assert.equal(set.pickProxyHeight(row), 20);
|
||||
assert.equal(set.depthTestDistance(row), 5000);
|
||||
settle(set);
|
||||
set.setImageSwitch(row, 40);
|
||||
set.setPickProxy(row, 30, 20);
|
||||
set.setDepthTestDistance(row, 5000);
|
||||
assert.ok(set.dirty.style.empty, 'unchanged writes leave it clean');
|
||||
set.setDepthTestDistance(row, Infinity);
|
||||
assert.equal(
|
||||
set.depthTestDistance(row),
|
||||
Math.fround(ICON_ALWAYS_OVER_DEPTH),
|
||||
'Infinity is carried as the always-over-depth value',
|
||||
);
|
||||
});
|
||||
|
||||
test('removing a row moves its switch, proxy and depth-test columns too', () => {
|
||||
const set = createIconSet({ capacity: 4 });
|
||||
set.add('a');
|
||||
const b = set.add('b');
|
||||
set.setPickProxy(b, 44, 33);
|
||||
set.setDepthTestDistance(b, 0);
|
||||
set.remove('a');
|
||||
const moved = set.row('b');
|
||||
assert.equal(moved, 0);
|
||||
assert.equal(set.pickProxyWidth(moved), 44);
|
||||
assert.equal(set.pickProxyHeight(moved), 33);
|
||||
assert.equal(set.depthTestDistance(moved), 0);
|
||||
});
|
||||
Reference in new issue
Block a user