Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

chore(comments): trim three over-length comments to the contract

yhh98946885212d
diff --git a/sdk/src/app/app.ts b/sdk/src/app/app.ts
index 73d6ad2cf..9cf5a0105 100644
--- a/sdk/src/app/app.ts
+++ b/sdk/src/app/app.ts
@@ -1051,17 +1051,9 @@ export class App {
return;
}
- // The frame's clock is the rAF timestamp, not the moment this callback got
- // to run. The timestamp names the vsync the frame is being drawn for, so
- // consecutive frames are exactly one refresh interval apart; platformNow()
- // here measures instead WHEN the browser got round to calling us, and that
- // delay's frame-to-frame variance enters delta twice — added to one frame,
- // subtracted from the next. A perfectly regular display then hands out an
- // irregular delta, and everything integrating `speed * delta` advances by
- // unequal steps: judder, worst on a camera pan, where the whole screen moves.
- // A host that passes no timestamp (a native shell driving its own loop) keeps
- // the old measurement; the clamp below absorbs the one frame where the two
- // clocks meet.
+ // The frame clock is the rAF timestamp — the vsync being drawn for — not
+ // callback entry, whose jitter would enter delta twice and judder motion.
+ // A host that passes no timestamp keeps the old measurement.
const currentTime = typeof rafTime === 'number' && rafTime > 0 ? rafTime : platformNow();
const deltaMs = currentTime - this.lastTime_;
diff --git a/sdk/src/camera/CameraPlugin.ts b/sdk/src/camera/CameraPlugin.ts
index 622324efc..5f15fb77c 100644
--- a/sdk/src/camera/CameraPlugin.ts
+++ b/sdk/src/camera/CameraPlugin.ts
@@ -690,16 +690,9 @@ export function cameraPlugin(
pipeline.setActiveScenes(activeScenes ?? null);
- // The frame opens, and the world's transforms resolve, BEFORE any
- // camera is read. A camera's view is built from its Transform's
- // worldPosition, and the transform pass is what writes it: run
- // behind the read — its old home, inside submitScene — it handed
- // every camera the PREVIOUS frame's placement while the sprites
- // drew at this frame's, so a camera moved in Update trailed the
- // world it was looking at by exactly one frame. beginFrame is what
- // clears the pass's once-per-frame memo, so it has to lead; the
- // call still inside submitScene then finds the answer and costs
- // nothing.
+ // Transforms resolve BEFORE any camera is read — a view is built
+ // from Transform.worldPosition, and a pass behind the read hands
+ // back the previous frame's placement. beginFrame clears the memo.
pipeline.beginFrame(elapsed);
app.measureFrameScope('render.updateTransforms', () =>
Renderer.updateTransforms({ _cpp: cppRegistry }));
diff --git a/sdk/tests/app-tick.test.ts b/sdk/tests/app-tick.test.ts
index 89232aa8c..bae048ad2 100644
--- a/sdk/tests/app-tick.test.ts
+++ b/sdk/tests/app-tick.test.ts
@@ -162,12 +162,9 @@ describe('App.stepFrames()', () => {
expect(app.isPaused()).toBe(true);
});
- // A display hands out frames on a metronome; the callback that draws them does
- // not start on one. Measuring delta at callback entry puts that start delay's
- // variance into delta TWICE — added to one frame, subtracted from the next —
- // so a steady 60 Hz becomes an unsteady delta, and `speed * delta` motion moves
- // in unequal steps. The rAF timestamp is the vsync itself, which is the clock
- // the frame is actually drawn against.
+ // Measuring delta at callback entry folds the scheduling jitter in twice —
+ // added to one frame, subtracted from the next — turning a steady 60 Hz into
+ // unequal `speed * delta` steps. The rAF timestamp is the vsync itself.
it('takes the frame clock from the animation-frame timestamp, not the callback entry time', async () => {
const realRaf = globalThis.requestAnimationFrame;
let pending: ((ts: number) => void) | null = null;