mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Cut the range ring's frame cost while the camera moves
The pulse level is worked out once a step, so the camera pose is read once rather than on every call. The band's alpha is tabulated along the radius and each pixel looks it up (0.78 ms a paint down to 0.21 ms in Node). A line sent again where it already runs keeps its positions, so the polyline collection does not rewrite the ring's vertices on every step. The band test now compares images byte by byte. A failing deepEqual on a 256x256 image builds a diff of every byte, and that ran a test process out of memory.
This commit is contained in:
1 parent
74d6d97b29
commit
e4af6c8ed7
4 files changed
+103
-18
No files matched your search
@@ -2824,8 +2824,12 @@ export function createCesiumDraw({
|
||||
was.positions = flatPositions(item.positions);
|
||||
unsettle(record);
|
||||
}
|
||||
const positions = linePositions(item);
|
||||
was.polyline.positions = positions;
|
||||
// A line sent again where it runs keeps its positions: writing them
|
||||
// would have the collection rewrite its vertices.
|
||||
const drawn = was.polyline.positions;
|
||||
const unmoved = drawnAt(drawn, item.positions);
|
||||
const positions = unmoved ? drawn : linePositions(item);
|
||||
if (!unmoved) was.polyline.positions = positions;
|
||||
was.polyline.show = show;
|
||||
if (recolour) paintLine(was.polyline.material, item.style);
|
||||
if (was.reveal)
|
||||
@@ -2835,6 +2839,41 @@ export function createCesiumDraw({
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether `positions` (an item's, ECEF points or packed triples) are the
|
||||
* Cartesians a polyline already draws. False for any given by longitude
|
||||
* and latitude, which are converted, not compared.
|
||||
*/
|
||||
function drawnAt(drawn, positions) {
|
||||
if (!Array.isArray(drawn)) return false;
|
||||
if (positions instanceof Float64Array) {
|
||||
if (positions.length !== drawn.length * 3) return false;
|
||||
for (let i = 0; i < drawn.length; i++) {
|
||||
const p = drawn[i];
|
||||
if (
|
||||
!Object.is(p.x, positions[i * 3]) ||
|
||||
!Object.is(p.y, positions[i * 3 + 1]) ||
|
||||
!Object.is(p.z, positions[i * 3 + 2])
|
||||
)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (positions.length !== drawn.length) return false;
|
||||
for (let i = 0; i < drawn.length; i++) {
|
||||
const p = positions[i];
|
||||
const q = drawn[i];
|
||||
if (
|
||||
!('x' in p) ||
|
||||
!Object.is(p.x, q.x) ||
|
||||
!Object.is(p.y, q.y) ||
|
||||
!Object.is(p.z, q.z)
|
||||
)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* After a draw: a line set whose lines have not changed for
|
||||
* `SETTLE_FRAMES` drawn frames starts building its static batch, of all
|
||||
|
||||
@@ -2954,10 +2954,16 @@ test('an outlined solid line draws one outline material, recoloured in place, an
|
||||
return null;
|
||||
};
|
||||
const first = line();
|
||||
const drawnPositions = first.positions;
|
||||
assert.equal(first.material.type, 'PolylineOutline');
|
||||
assert.equal(first.material.uniforms.outlineWidth, 1);
|
||||
s.set.upsert([outlined([0, 0.5, 1, 0.4], [0, 0, 0, 0.32])]);
|
||||
assert.equal(line(), first, 'the same line');
|
||||
assert.equal(
|
||||
first.positions,
|
||||
drawnPositions,
|
||||
'positions sent again where they were are not rewritten',
|
||||
);
|
||||
assert.equal(first.material.uniforms.color.alpha, 0.4);
|
||||
assert.ok(
|
||||
Math.abs(first.material.uniforms.outlineColor.alpha - 0.32) < 1e-9,
|
||||
|
||||
Reference in new issue
Block a user