mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-24 04:02:19 +00:00
Moving layers redraw as fast as they move on screen, 3 to 30 times a second
Satellites, flights and vessels held the render loop at the display's rate
while they were on, so a view of slow-moving marks drew 100-170 frames a
second. Each now reads how fast its fastest mark crosses the screen and asks
for a frame whenever that mark would move half a pixel: never fewer than 3 a
second (animated marks never stall), never more than 30 (room in the frame
for the rest of the scene). Below 12 a second the layer asks for one frame at
a time on a timer; from there it holds the loop at 15, 20 or 30, rates the
display divides evenly (renderPace.js).
The render governor takes a rate per hold: the highest asked wins, a hold
with no rate draws at the display's rate. Following a target is capped at
30. Steering the camera (a drag, a pinch, the wheel) still draws at the
display's rate; it ends when the last pointer lifts, the wheel rests, or the
page loses focus or is hidden.
Draw sets whose motion clock is the owner's ('frames: owner') ask for no
frames for moving rows or for rows written in place; the owner's pace does.
The vessels layer places its contacts at most 30 times a second and writes
every move of a pass to its icons in one batch.
Measured in Chrome on a still camera (draws a second, before -> after):
satellites over the whole globe 162 -> 6, at 1,500 km 114 -> 30; flights over
the whole globe 132 -> 10, Europe 53 -> 5, London 114 -> 9. Planes move at
most 0.6 px between draws.
This commit is contained in:
1 parent
43bd25382d
commit
d50f04efeb
30 files changed
+1262
-82
No files matched your search
@@ -163,6 +163,8 @@ export function createSceneFrame(viewer) {
|
||||
const holds = new Map();
|
||||
// Told when the first hold is taken and the last released.
|
||||
const heldListeners = listenerList(uncaught);
|
||||
// Told every hold taken or released.
|
||||
const holdsListeners = listenerList(uncaught);
|
||||
const pendingRenders = new Set();
|
||||
const gone = () => disposed || scene.isDestroyed?.();
|
||||
const sceneTime = (time) =>
|
||||
@@ -250,6 +252,7 @@ export function createSceneFrame(viewer) {
|
||||
holds.set(reason, (holds.get(reason) ?? 0) + 1);
|
||||
if (!gone()) scene.requestRender();
|
||||
if (first) heldListeners.fire(true);
|
||||
holdsListeners.fire();
|
||||
let released = false;
|
||||
return () => {
|
||||
if (released) return;
|
||||
@@ -260,9 +263,11 @@ export function createSceneFrame(viewer) {
|
||||
// What changed in the last held frame still gets drawn.
|
||||
if (!gone()) scene.requestRender();
|
||||
if (holds.size === 0) heldListeners.fire(false);
|
||||
holdsListeners.fire();
|
||||
};
|
||||
},
|
||||
onHeldChange: (cb) => heldListeners.on(cb),
|
||||
onHoldsChange: (cb) => holdsListeners.on(cb),
|
||||
mode: () => (scene.requestRenderMode ? 'demand' : 'continuous'),
|
||||
diagnostics: () => ({
|
||||
mode: port.mode(),
|
||||
@@ -331,6 +336,7 @@ export function createSceneFrame(viewer) {
|
||||
for (const off of removers.splice(0)) off();
|
||||
for (const list of Object.values(listeners)) list.clear();
|
||||
heldListeners.clear();
|
||||
holdsListeners.clear();
|
||||
holds.clear();
|
||||
// Waits settle rather than stay attached to a scene gone quiet.
|
||||
for (const done of [...pendingRenders]) done();
|
||||
|
||||
Reference in new issue
Block a user