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.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(editor-checks): the gizmo check reads a settled frame, not a slept one
yhh4178e69fb0d1
diff --git a/desktop/scripts/editor-checks/gizmo-chrome.mjs b/desktop/scripts/editor-checks/gizmo-chrome.mjsindex c1a845b59..26ac67d5a 100644--- a/desktop/scripts/editor-checks/gizmo-chrome.mjs+++ b/desktop/scripts/editor-checks/gizmo-chrome.mjs@@ -80,9 +80,7 @@ export async function run(ed) {// The design overlay belongs to UI mode, and the editor remembers its mode.await ed.call('run_editor_command', { id: 'mode.scene' }, 30000);await ed.call('select', { id: null }, 30000);- await ed.sleep(800);-- const first = await ed.screenshot('gizmo-chrome-locate');+ const first = await ed.screenshot('gizmo-chrome-locate', { settled: true });const origin = originIn(first, viewportRegion(first));if (!check(origin != null, "the grid's axis lines were not found — the subject is at the origin")) {return check.failures;@@ -96,13 +94,13 @@ export async function run(ed) {}// Adding a component selects its entity, and a selection draws chrome of its own.await ed.call('select', { id: null }, 30000);- await ed.sleep(700);+ // Settled, not slept: the baseline is the difference between these two frames,+ // so a frame read before its toggle landed inflates it and every shaped gizmo+ // is then measured against a bar nothing can clear.await ed.call('run_editor_command', { id: 'view.toggleGizmos' }, 30000);- await ed.sleep(700);- const off = await ed.screenshot(`gizmo-chrome-${c.comp}-off`);+ const off = await ed.screenshot(`gizmo-chrome-${c.comp}-off`, { settled: true });await ed.call('run_editor_command', { id: 'view.toggleGizmos' }, 30000);- await ed.sleep(700);- const on = await ed.screenshot(`gizmo-chrome-${c.comp}-on`);+ const on = await ed.screenshot(`gizmo-chrome-${c.comp}-on`, { settled: true });const m = ink(off, on, origin, 300);await ed.call('remove_component', { entity: 0, component: c.comp }, 30000);await ed.sleep(400);diff --git a/desktop/scripts/lib/editorDriver.mjs b/desktop/scripts/lib/editorDriver.mjsindex 2bf2dbc15..bd0bbf7d8 100644--- a/desktop/scripts/lib/editorDriver.mjs+++ b/desktop/scripts/lib/editorDriver.mjs@@ -184,10 +184,25 @@ export async function withEditor(body, opts = {}) {if (out) await writeFile(path.join(out, `${label}.png`), png);return readPNG(png);},- /** The composited window (the only way to see gizmo overlays or the play realm). */- screenshot: async (label, args = {}) => {- const block = await call('screenshot', args, 60000);- const png = Buffer.from(block.data ?? '', 'base64');+ /**+ * The composited window (the only way to see gizmo overlays or the play realm).+ * `settled` returns the first frame that repeats — a command reaches the+ * compositor after the call that asked for it, and a sleep guesses at when.+ * A frame that never repeats (a running realm) comes back at the deadline.+ */+ screenshot: async (label, { settled = false, settleMs = 4000, ...args } = {}) => {+ const shoot = async () => Buffer.from((await call('screenshot', args, 60000)).data ?? '', 'base64');+ let png = await shoot();+ if (settled) {+ const deadline = Date.now() + settleMs;+ while (Date.now() < deadline) {+ await sleep(120);+ const next = await shoot();+ const same = next.equals(png);+ png = next;+ if (same) break;+ }+ }if (out) await writeFile(path.join(out, `${label}.png`), png);return readPNG(png);},