From 72cfea35c4e8461f5a965ac06f1c76dde6d781ae Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sat, 14 Nov 2026 01:06:21 -0800 Subject: [PATCH] A live motion clock's new delay restyles nothing on Cesium Aircraft layers move their display delay a little every frame. Every frame already reads the clock from the set, so a delay-only change now just asks for a frame instead of restyling every row. --- src/render/cesium/draw.js | 12 ++++++++++++ src/render/cesium/gpuIcons.test.mjs | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/render/cesium/draw.js b/src/render/cesium/draw.js index ee960fc4f..c8384a864 100644 --- a/src/render/cesium/draw.js +++ b/src/render/cesium/draw.js @@ -588,6 +588,18 @@ export function createCesiumDraw({ requestRender(); }, setOptions(options) { + // A live clock's new delay only: every frame reads the clock from + // the spec, so nothing is rebuilt or restyled (a layer moves its + // display delay a little every frame). + if ( + Object.keys(options).every((key) => key === 'motionClock') && + options.motionClock?.kind === 'live' && + spec.motionClock?.kind === 'live' + ) { + spec.motionClock = options.motionClock; + requestRender(); + return; + } // Refused, changing nothing, where icons on the GPU cannot take it. if (record.gpu) gpu.check([], { ...spec, ...options }); const culled = spec.horizonCull; diff --git a/src/render/cesium/gpuIcons.test.mjs b/src/render/cesium/gpuIcons.test.mjs index 74dda5a0d..9bc4d4308 100644 --- a/src/render/cesium/gpuIcons.test.mjs +++ b/src/render/cesium/gpuIcons.test.mjs @@ -172,6 +172,26 @@ test('a set’s motion clock is the frame’s scene time, or wall time less its assert.equal(scene.frameState.time instanceof Cesium.JulianDate, true); }); +test('a live clock’s new delay is read the next frame with nothing restyled', () => { + const { part, draw } = drawOver(); + const live = draw.icons({ + id: 'gpu:delay', + motionClock: { kind: 'live', delayMs: 2000 }, + }); + live.set([icon('a', { motion: { kind: 'hold' } })]); + const record = part.sets.get('gpu:delay'); + let restyles = 0; + const restyle = record.gpu.restyle; + record.gpu.restyle = () => ((restyles += 1), restyle()); + live.setOptions({ motionClock: { kind: 'live', delayMs: 5000 } }); + assert.equal(restyles, 0, 'a delay alone restyles nothing'); + const lag = + Date.now() - Cesium.JulianDate.toDate(record.host.renderTime({})).getTime(); + assert.ok(Math.abs(lag - 5000) < 50, `lags ${lag} ms`); + live.setOptions({ motionClock: { kind: 'scene' } }); + assert.equal(restyles, 1, 'a clock of another kind still restyles'); +}); + test('rows moving on a live clock keep frames coming until their segments end', () => { const { scene, part, draw } = drawOver(); const set = draw.icons({ id: 'gpu:animate' });