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
feat(ci): the texture atlas is used by a game, and the suite reads it
esengine0e19445fd068
diff --git a/examples/space-shooter/assets/textures/bullet-enemy.png b/examples/space-shooter/assets/textures/sprites.atlas/bullet-enemy.pngsimilarity index 100%rename from examples/space-shooter/assets/textures/bullet-enemy.pngrename to examples/space-shooter/assets/textures/sprites.atlas/bullet-enemy.pngdiff --git a/examples/space-shooter/assets/textures/bullet-enemy.png.meta b/examples/space-shooter/assets/textures/sprites.atlas/bullet-enemy.png.metasimilarity index 100%rename from examples/space-shooter/assets/textures/bullet-enemy.png.metarename to examples/space-shooter/assets/textures/sprites.atlas/bullet-enemy.png.metadiff --git a/examples/space-shooter/assets/textures/bullet-player.png b/examples/space-shooter/assets/textures/sprites.atlas/bullet-player.pngsimilarity index 100%rename from examples/space-shooter/assets/textures/bullet-player.pngrename to examples/space-shooter/assets/textures/sprites.atlas/bullet-player.pngdiff --git a/examples/space-shooter/assets/textures/bullet-player.png.meta b/examples/space-shooter/assets/textures/sprites.atlas/bullet-player.png.metasimilarity index 100%rename from examples/space-shooter/assets/textures/bullet-player.png.metarename to examples/space-shooter/assets/textures/sprites.atlas/bullet-player.png.metadiff --git a/examples/space-shooter/assets/textures/enemy-a.png b/examples/space-shooter/assets/textures/sprites.atlas/enemy-a.pngsimilarity index 100%rename from examples/space-shooter/assets/textures/enemy-a.pngrename to examples/space-shooter/assets/textures/sprites.atlas/enemy-a.pngdiff --git a/examples/space-shooter/assets/textures/enemy-a.png.meta b/examples/space-shooter/assets/textures/sprites.atlas/enemy-a.png.metasimilarity index 100%rename from examples/space-shooter/assets/textures/enemy-a.png.metarename to examples/space-shooter/assets/textures/sprites.atlas/enemy-a.png.metadiff --git a/examples/space-shooter/assets/textures/enemy-b.png b/examples/space-shooter/assets/textures/sprites.atlas/enemy-b.pngsimilarity index 100%rename from examples/space-shooter/assets/textures/enemy-b.pngrename to examples/space-shooter/assets/textures/sprites.atlas/enemy-b.pngdiff --git a/examples/space-shooter/assets/textures/enemy-b.png.meta b/examples/space-shooter/assets/textures/sprites.atlas/enemy-b.png.metasimilarity index 100%rename from examples/space-shooter/assets/textures/enemy-b.png.metarename to examples/space-shooter/assets/textures/sprites.atlas/enemy-b.png.metadiff --git a/examples/space-shooter/assets/textures/heart.png b/examples/space-shooter/assets/textures/sprites.atlas/heart.pngsimilarity index 100%rename from examples/space-shooter/assets/textures/heart.pngrename to examples/space-shooter/assets/textures/sprites.atlas/heart.pngdiff --git a/examples/space-shooter/assets/textures/heart.png.meta b/examples/space-shooter/assets/textures/sprites.atlas/heart.png.metasimilarity index 100%rename from examples/space-shooter/assets/textures/heart.png.metarename to examples/space-shooter/assets/textures/sprites.atlas/heart.png.metadiff --git a/examples/space-shooter/assets/textures/player.png b/examples/space-shooter/assets/textures/sprites.atlas/player.pngsimilarity index 100%rename from examples/space-shooter/assets/textures/player.pngrename to examples/space-shooter/assets/textures/sprites.atlas/player.pngdiff --git a/examples/space-shooter/assets/textures/player.png.meta b/examples/space-shooter/assets/textures/sprites.atlas/player.png.metasimilarity index 100%rename from examples/space-shooter/assets/textures/player.png.metarename to examples/space-shooter/assets/textures/sprites.atlas/player.png.metadiff --git a/examples/space-shooter/assets/textures/star.png b/examples/space-shooter/assets/textures/sprites.atlas/star.pngsimilarity index 100%rename from examples/space-shooter/assets/textures/star.pngrename to examples/space-shooter/assets/textures/sprites.atlas/star.pngdiff --git a/examples/space-shooter/assets/textures/star.png.meta b/examples/space-shooter/assets/textures/sprites.atlas/star.png.metasimilarity index 100%rename from examples/space-shooter/assets/textures/star.png.metarename to examples/space-shooter/assets/textures/sprites.atlas/star.png.metadiff --git a/tools/check-golden.mjs b/tools/check-golden.mjsindex 4c573e0fb..e04a42248 100644--- a/tools/check-golden.mjs+++ b/tools/check-golden.mjs@@ -12,7 +12,7 @@* target. A capability nothing covers is allowed — declared in KNOWN_GAPS, with* a reason, so the hole is a sentence somebody wrote.*/-import { existsSync, readFileSync } from 'node:fs';+import { existsSync, readFileSync, readdirSync } from 'node:fs';import path from 'node:path';import {GOLDEN, CAPABILITIES, KNOWN_GAPS, TIERS, TARGETS,@@ -25,6 +25,7 @@ const fail = (msg) => problems.push(msg);/** Capabilities a packaged frame cannot show, and the declaration whose run reads them. */const NEEDS_RUN = {+ 'texture-atlas': 'atlas','safe-area': 'safeArea','pause-resume': 'suspend','hot-update': 'runBy',@@ -104,6 +105,16 @@ for (const g of GOLDEN) {if (g.runBy && !SCHEDULED.includes(g.runBy)) {fail(`"${g.id}" is settled by \`${g.runBy}\`, which no release criterion runs — add it to releaseGate.mjs`);}+ // A folder convention is only coverage while the folder is there: moving those+ // textures back out would take the claim with them, silently.+ if (g.atlas) {+ if (!(g.atlas.packed > 0)) fail(`"${g.id}" declares atlas without a positive packed count`);+ const dirs = existsSync(projectDir(g.id))+ ? readdirSync(path.join(projectDir(g.id), 'assets'), { withFileTypes: true, recursive: true })+ .filter((e) => e.isDirectory() && e.name.endsWith('.atlas'))+ : [];+ if (!dirs.length) fail(`"${g.id}" claims texture-atlas but has no <name>.atlas/ folder under assets/`);+ }const sa = g.safeArea;if (sa) {if (!sa.entity || !sa.reference) fail(`"${g.id}" declares safeArea without both an entity and a reference`);diff --git a/tools/goldenProjects.mjs b/tools/goldenProjects.mjsindex cb73fa80b..9e8464531 100644--- a/tools/goldenProjects.mjs+++ b/tools/goldenProjects.mjs@@ -54,6 +54,7 @@ export const CAPABILITIES = ['spine', 'material', 'asset-lifecycle','tilemap', 'tile-collision','touch', 'safe-area', 'pause-resume',+ 'texture-atlas','single-file', 'startup-size','hot-update', 'rollback','networking',@@ -100,10 +101,14 @@ export const GOLDEN = [},{id: 'space-shooter',- certifies: ['ecs', 'particles', 'audio'],+ certifies: ['ecs', 'particles', 'audio', 'texture-atlas'],targets: ['web', 'desktop', 'android'],tier: 'pr',interact: { keys: ['ArrowLeft'], frames: 40 },+ // Its small sprites live in a `<name>.atlas/` folder, so the cook packs them+ // into one page and the package samples frames the editor never sees. The+ // count is the claim: packing that quietly stops still passes parity.+ atlas: { packed: 7 },},{id: 'ui-controls',@@ -314,6 +319,17 @@ export function safeAreaFor(g) {};}+/**+ * What a project asks of the texture cook, or null when it claims nothing.+ * `packed` is how many of its textures must come out of the cook inside an atlas+ * page — a count, because packing that silently stops still draws the same frame+ * and therefore still passes parity.+ */+export function atlasFor(g) {+ if (!g.atlas) return null;+ return { packed: g.atlas.packed };+}+/** Absolute path to a golden project's directory. */export function projectDir(id) {return path.join(EXAMPLES, id);diff --git a/tools/verify-golden.mjs b/tools/verify-golden.mjsindex c942fefa7..5d363e64f 100644--- a/tools/verify-golden.mjs+++ b/tools/verify-golden.mjs@@ -19,7 +19,7 @@import { spawnSync } from 'node:child_process';import { mkdirSync, rmSync, readFileSync, existsSync } from 'node:fs';import path from 'node:path';-import { atTier, projectDir, parityFor, interactFor, suspendFor, safeAreaFor, ROOT } from './goldenProjects.mjs';+import { atTier, projectDir, parityFor, interactFor, suspendFor, safeAreaFor, atlasFor, ROOT } from './goldenProjects.mjs';import { frameDistance, frameCellMax, readPNG } from './frameCompare.mjs';const argv = process.argv.slice(2);@@ -139,6 +139,29 @@ for (const { id, target } of pairs) {// Parity compares like for like, so the package is opened at exactly the size// the editor's play surface came out — never a guessed one.const golden = atTier(TIER).find((g) => g.id === id);++ // Did the cook actually pack? Parity cannot answer this: an atlas that stopped+ // working still draws the same frame from nine standalone textures.+ const atlas = atlasFor(golden);+ if (atlas) {+ let packed = 0;+ try {+ const manifest = JSON.parse(readFileSync(path.join(out, 'asset-manifest.json'), 'utf8'));+ for (const group of Object.values(manifest.groups ?? {})) {+ for (const asset of Object.values(group.assets ?? {})) {+ if (asset.metadata?.atlasPage !== undefined) packed++;+ }+ }+ } catch (e) {+ packed = -1;+ }+ const ok = packed === atlas.packed;+ results.push({+ id, target, stage: 'atlas', ok,+ why: ok ? '' : `${packed} texture(s) came out packed, the project claims ${atlas.packed}`,+ });+ console.log(`${ok ? '✓' : '✗'} ${id} ${target} — atlas: ${packed} texture(s) packed into a page`);+ }const tolerance = COMPARABLE.has(target) && !NO_PARITY ? parityFor(golden) : null;const editorPng = path.join(WORK, `${id}-editor.png`);const editor = tolerance != null ? captureEditorFrame(id, editorPng) : null;