mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Draped lines in the sky's frame on the Cesium renderer
A draped line in the inertial frame is no longer refused: it is held as given, drawn turned into the fixed frame where its motion clock has the sky, and draped again each second of that clock, the old ground line kept until the new one is ready.
This commit is contained in:
1 parent
9995b35874
commit
1cc9c45418
3 files changed
+166
-26
No files matched your search
@@ -7326,20 +7326,6 @@ test('a pattern line draws its image along it, repeated, and an inertial line tu
|
||||
later.upsert([{ ...sky(true), id: 'parked' }]);
|
||||
assert.equal(scene.added.at(-1).get(1).length, 1);
|
||||
later.dispose();
|
||||
assert.throws(
|
||||
() =>
|
||||
set.upsert([
|
||||
{
|
||||
id: 'draped',
|
||||
positions: ring,
|
||||
widthPx: 3,
|
||||
mode: 'draped',
|
||||
style: { kind: 'solid', color: '#fff' },
|
||||
frame: 'inertial',
|
||||
},
|
||||
]),
|
||||
/inertial lines undraped/,
|
||||
);
|
||||
set.dispose();
|
||||
assert.equal(scene.added.length, 0);
|
||||
}));
|
||||
@@ -8086,3 +8072,66 @@ test('a points set takes columns as rows, over the items it holds', () => {
|
||||
assert.deepEqual(drawHitOf({ id: point.id })?.meta, { m: 1 });
|
||||
set.dispose();
|
||||
});
|
||||
|
||||
test('a draped line in the sky’s frame drapes where the sky is, again as its clock moves on', () => {
|
||||
const { scene, draw, frame } = drawOver();
|
||||
const realNow = Date.now;
|
||||
let now = Date.UTC(2026, 0, 1);
|
||||
Date.now = () => now;
|
||||
try {
|
||||
const set = draw.lines({ id: 'sky-track' });
|
||||
const given = [
|
||||
Cesium.Cartesian3.fromDegrees(0, 0),
|
||||
Cesium.Cartesian3.fromDegrees(1, 0),
|
||||
];
|
||||
set.set([
|
||||
{
|
||||
id: 'track',
|
||||
positions: given,
|
||||
widthPx: 3,
|
||||
mode: 'draped',
|
||||
style: { kind: 'solid', color: '#fff' },
|
||||
frame: 'inertial',
|
||||
meta: { m: 1 },
|
||||
},
|
||||
]);
|
||||
const grounds = () => {
|
||||
const found = [];
|
||||
for (const host of scene.added)
|
||||
for (let i = 0; i < (host.length ?? 0); i++)
|
||||
if (host.get(i) instanceof Cesium.GroundPolylinePrimitive)
|
||||
found.push(host.get(i));
|
||||
return found;
|
||||
};
|
||||
const start = (ground) =>
|
||||
Cesium.Math.toDegrees(
|
||||
Cesium.Cartographic.fromCartesian(
|
||||
ground.geometryInstances[0].geometry._positions[0],
|
||||
).longitude,
|
||||
);
|
||||
const [first] = grounds();
|
||||
assert.ok(first, 'draped');
|
||||
assert.equal(first.geometryInstances[0].id.id, 'track');
|
||||
assert.deepEqual(first.geometryInstances[0].id.meta, { m: 1 });
|
||||
const turned = start(first);
|
||||
assert.ok(
|
||||
Math.abs(turned) > 1,
|
||||
`turned off where it was given (${turned})`,
|
||||
);
|
||||
// Within a step, nothing is draped again.
|
||||
now += 500;
|
||||
frame();
|
||||
assert.equal(grounds().at(-1), first);
|
||||
// A minute later the sky has turned a quarter of a degree west.
|
||||
now += 60_000;
|
||||
frame();
|
||||
const again = grounds().at(-1);
|
||||
assert.notEqual(again, first, 'draped again');
|
||||
const moved = start(again) - turned;
|
||||
assert.ok(Math.abs(moved + 0.2507) < 0.01, `moved ${moved}°`);
|
||||
assert.equal(set.size(), 1);
|
||||
set.dispose();
|
||||
} finally {
|
||||
Date.now = realNow;
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user