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(gates): third-person runs its package on one frame of game time per frame
esenginefd03589ef409
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.ymlindex ab4b98e4e..126951194 100644--- a/.github/workflows/nightly.yml+++ b/.github/workflows/nightly.yml@@ -182,13 +182,18 @@ jobs:# Four launches of a streamed world, which alone has taken twenty minutes.- shard: streamedcriteria: --only streamed-world-comes-and-goes+ # 29 launches of the third-person package: 15 of its checks took 56 minutes+ # on a runner, so the whole list needs a window of its own.+ - shard: third-person+ criteria: --only a-character-may-only-do-what-the-world-allows,a-streamed-place-is-ready-before-it-is-seen+ timeout: 150- shard: rest- criteria: --except flagship-plays-through,golden-packages,performance-ceilings,static-gates,streamed-world-comes-and-goes+ criteria: --except flagship-plays-through,golden-packages,performance-ceilings,static-gates,streamed-world-comes-and-goes,a-character-may-only-do-what-the-world-allows,a-streamed-place-is-ready-before-it-is-seenenv:ESTELLA_NATIVE_TEMPLATES: ${{ github.workspace }}/.native-templates# Empty outside the golden shards, where verify-golden takes the whole tier.ESTELLA_GOLDEN_SHARD: ${{ matrix.golden }}- timeout-minutes: 60+ timeout-minutes: ${{ matrix.timeout || 60 }}steps:# verify-legacy reads examples out of RELEASE TAGS (git archive v0.20.0 …),diff --git a/tools/launchers/launch-export.mjs b/tools/launchers/launch-export.mjsindex a91f8878c..04d02f7c5 100644--- a/tools/launchers/launch-export.mjs+++ b/tools/launchers/launch-export.mjs@@ -41,6 +41,9 @@* --gameplay p[,c] after settling, print what the third-person character* IS: where it stands, what the physics step gave it, and* what its animator was told+ * --frame-ms <n> every rendered frame advances the game's clock by exactly n ms,+ * so what a gesture held for N frames did does not depend on+ * how fast this machine draws* --log <regex> also print console lines matching this (the engine's own* warnings say why a subsystem sat out; only `[engine]`* lines are forwarded otherwise, which means diagnosing@@ -108,7 +111,19 @@ const MIME = {/** Serve the export directory. Range requests are not implemented: a build that* needs them (video seek) would read as a broken asset here, not a broken server. */-function serve(root, safeArea) {+/** Advances the page's clock once per rendered frame, by `ms`: the loop reads its+ * delta off the rAF timestamp, and a slow runner's frame would otherwise hand a+ * game a quarter of a second at a time. */+const clockScript = (ms) => `<script>(() => {+ let now = performance.now(); let frame = -1;+ const raf = window.requestAnimationFrame.bind(window);+ window.requestAnimationFrame = (cb) => raf((real) => {+ if (real !== frame) { frame = real; now += ${ms}; }+ cb(now);+ });+})();</script>`;++function serve(root, safeArea, frameMs) {const server = http.createServer(async (req, res) => {try {let rel = decodeURIComponent(new URL(req.url, 'http://x').pathname).replace(/^\/+/, '');@@ -119,14 +134,13 @@ function serve(root, safeArea) {// Insets have to exist before the first script runs: the engine reads// them once when its UI plugins build, and a variable set from the// outside after that is a variable nobody ever asks about again.- if (safeArea && rel === 'index.html') {+ if ((safeArea || frameMs) && rel === 'index.html') {const [t = 0, r = 0, b = 0, l = 0] = safeArea.split(',').map(Number);+ const head = (frameMs ? clockScript(frameMs) : '')+ + (safeArea ? `<style>:root{--sat:${t}px;--sar:${r}px;--sab:${b}px;--sal:${l}px}</style>` : '');const html = String(bytes);- const injected = html.replace(- '<head>',- `<head><style>:root{--sat:${t}px;--sar:${r}px;--sab:${b}px;--sal:${l}px}</style>`,- );- if (injected === html) console.log(' safe-area: no <head> to inject into');+ const injected = html.replace('<head>', `<head>${head}`);+ if (injected === html) console.log(' no <head> to inject the safe area or clock into');bytes = Buffer.from(injected);}res.writeHead(200, { 'content-type': MIME[path.extname(abs).toLowerCase()] ?? 'application/octet-stream' })@@ -170,7 +184,7 @@ const AI = flag('ai', '');const RENDER = has('render');/** Boot a named scene from the package instead of its entry. */const SCENE = flag('scene', '');- const server = await serve(DIR, flag('safe-area', ''));+ const server = await serve(DIR, flag('safe-area', ''), Number(flag('frame-ms', '0')));const query = new URLSearchParams();if (PROBE || GAMEPLAY || PARTICLES || COMBAT || AI || RENDER || FACTS || STREAMING) query.set('headless', '');if (SCENE) query.set('scene', SCENE);diff --git a/tools/verify-third-person.mjs b/tools/verify-third-person.mjsindex 486232520..0fd419d27 100644--- a/tools/verify-third-person.mjs+++ b/tools/verify-third-person.mjs@@ -31,6 +31,10 @@ const PROJECT = path.join(ROOT, 'examples', 'third-person-3d');const LAUNCHER = path.join(ROOT, 'tools', 'launchers', 'launch-export.mjs');const W = 960, H = 640;+/** One rendered frame of game time, whatever the machine: a gesture is held for+ * frames, and at a runner's 1.4 s a frame the loop's 0.25 s cap walked the+ * character fifteen times further than the gym is long. */+const FRAME_MS = String(1000 / 60);/** Frames of strafe per lane: the character covers moveSpeed/60 a frame. */const TO_LANE = { wall: 75, step: 75, highStep: 150 };@@ -69,7 +73,7 @@ function reading(stdout, label) {* `undefined` — so it stops here and says what the launcher did print.*/function launch(args, label) {- const r = runElectron([LAUNCHER, ...args], { encoding: 'utf8', cwd: ROOT });+ const r = runElectron([LAUNCHER, '--frame-ms', FRAME_MS, ...args], { encoding: 'utf8', cwd: ROOT });if (!reading(r.stdout, label)) {console.error(`✗ third-person: a launch printed no ${label} reading, so no game ran to judge`);for (const l of `${r.stderr ?? ''}${r.stdout ?? ''}`.trim().split('\n').slice(-12)) {@@ -548,7 +552,7 @@ const HOME_AGENTS = 1;// Crossing publishes a PLACE, not a load: the sentry navigates to the player// and the swing the gym criteria drive kills it. It walks the persistent// CAUSEWAY — the navmesh bakes once, so a cell's own floor gets none.- const seen = excursion({ out: 300, frames: 400, swings: 7 });+ const seen = excursion({ out: 330, frames: 400, swings: 7 });const sentry = seen.ai ?? {};const walked = Math.hypot((sentry.position?.x ?? 120) - 120, (sentry.position?.z ?? 1720) - 1720);// Two claims, and the damaged one is the STANDING target: whether a swing