perf(globe): less churn in movers and lines

Review of Tasks 2–3:
- the mover store's instance checks no longer build arrays or closures
  per set() (orientation and colour checked field by field), and dirty()
  returns one reused range object;
- Cesium models get their matrix and colour through scratch objects
  (Model.modelMatrix and Model.color copy what they are given) instead
  of a new Matrix4 and Color per placement;
- a destroyed MoverSet releases its store (count 0, empty instance
  arrays, no pick ids) so a set object a layer still holds keeps no
  memory, and the Cesium parts drop their billboard, point and model
  lists;
- (with the overlay commit) the Navara line viewport is updated in
  place.

Node micro-measure, 10 000 instances set + packed per frame: 0.27-0.29
ms, about 1.7 KB per frame (0.17 B per instance), as before. Contract:
Cesium 70/70, Navara 76/76.
This commit is contained in:
German Khokhlov committed 2026-10-16 19:33:46 +04:00
1 parent d483e5897e
commit 39d522c9a9
3 files changed
+84 -17

No files matched your search

+12 -4
View File
@@ -12,6 +12,8 @@ const scratchPosition = new Cesium.Cartesian3();
const scratchColor = new Cesium.Color();
const scratchQuaternion = new Cesium.Quaternion();
const scratchRotation = new Cesium.Matrix3();
// Model.modelMatrix and Model.color copy what they are given.
const scratchModelMatrix = new Cesium.Matrix4();
/** The atlas cells as canvases, by key (a DOM canvas or image source). */
async function cropAtlasCells(atlas, keys) {
@@ -143,6 +145,9 @@ function spritePart(scene, options, store, factories, requestRender, owners) {
},
destroy() {
destroyed = true;
billboards.length = 0;
shownCell.length = 0;
cells = null;
},
};
}
@@ -180,7 +185,9 @@ function pointPart(options, store, factories, requestRender, owners) {
}
requestRender('movers');
},
destroy() {},
destroy() {
points.length = 0;
},
};
}
@@ -203,13 +210,12 @@ function modelPart(options, store, factories, requestRender, owners) {
item.modelMatrix = Cesium.Matrix4.fromRotationTranslation(
Cesium.Matrix3.fromQuaternion(scratchQuaternion, scratchRotation),
readPosition(store, index),
new Cesium.Matrix4(),
scratchModelMatrix,
);
item.scale = store.scales[index];
item.show = index < store.count && store.shows[index] === 1;
item.id = store.pickIds[index];
if (model.colorBlend)
item.color = Cesium.Color.clone(readColor(store, index));
if (model.colorBlend) item.color = readColor(store, index);
};
const ensure = (index) => {
if (models[index] || loading[index]) return;
@@ -258,6 +264,8 @@ function modelPart(options, store, factories, requestRender, owners) {
},
destroy() {
destroyed = true;
models.length = 0;
loading.length = 0;
},
};
}