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.

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.png
similarity index 100%
rename from examples/space-shooter/assets/textures/bullet-enemy.png
rename to examples/space-shooter/assets/textures/sprites.atlas/bullet-enemy.png
diff --git a/examples/space-shooter/assets/textures/bullet-enemy.png.meta b/examples/space-shooter/assets/textures/sprites.atlas/bullet-enemy.png.meta
similarity index 100%
rename from examples/space-shooter/assets/textures/bullet-enemy.png.meta
rename to examples/space-shooter/assets/textures/sprites.atlas/bullet-enemy.png.meta
diff --git a/examples/space-shooter/assets/textures/bullet-player.png b/examples/space-shooter/assets/textures/sprites.atlas/bullet-player.png
similarity index 100%
rename from examples/space-shooter/assets/textures/bullet-player.png
rename to examples/space-shooter/assets/textures/sprites.atlas/bullet-player.png
diff --git a/examples/space-shooter/assets/textures/bullet-player.png.meta b/examples/space-shooter/assets/textures/sprites.atlas/bullet-player.png.meta
similarity index 100%
rename from examples/space-shooter/assets/textures/bullet-player.png.meta
rename to examples/space-shooter/assets/textures/sprites.atlas/bullet-player.png.meta
diff --git a/examples/space-shooter/assets/textures/enemy-a.png b/examples/space-shooter/assets/textures/sprites.atlas/enemy-a.png
similarity index 100%
rename from examples/space-shooter/assets/textures/enemy-a.png
rename to examples/space-shooter/assets/textures/sprites.atlas/enemy-a.png
diff --git a/examples/space-shooter/assets/textures/enemy-a.png.meta b/examples/space-shooter/assets/textures/sprites.atlas/enemy-a.png.meta
similarity index 100%
rename from examples/space-shooter/assets/textures/enemy-a.png.meta
rename to examples/space-shooter/assets/textures/sprites.atlas/enemy-a.png.meta
diff --git a/examples/space-shooter/assets/textures/enemy-b.png b/examples/space-shooter/assets/textures/sprites.atlas/enemy-b.png
similarity index 100%
rename from examples/space-shooter/assets/textures/enemy-b.png
rename to examples/space-shooter/assets/textures/sprites.atlas/enemy-b.png
diff --git a/examples/space-shooter/assets/textures/enemy-b.png.meta b/examples/space-shooter/assets/textures/sprites.atlas/enemy-b.png.meta
similarity index 100%
rename from examples/space-shooter/assets/textures/enemy-b.png.meta
rename to examples/space-shooter/assets/textures/sprites.atlas/enemy-b.png.meta
diff --git a/examples/space-shooter/assets/textures/heart.png b/examples/space-shooter/assets/textures/sprites.atlas/heart.png
similarity index 100%
rename from examples/space-shooter/assets/textures/heart.png
rename to examples/space-shooter/assets/textures/sprites.atlas/heart.png
diff --git a/examples/space-shooter/assets/textures/heart.png.meta b/examples/space-shooter/assets/textures/sprites.atlas/heart.png.meta
similarity index 100%
rename from examples/space-shooter/assets/textures/heart.png.meta
rename to examples/space-shooter/assets/textures/sprites.atlas/heart.png.meta
diff --git a/examples/space-shooter/assets/textures/player.png b/examples/space-shooter/assets/textures/sprites.atlas/player.png
similarity index 100%
rename from examples/space-shooter/assets/textures/player.png
rename to examples/space-shooter/assets/textures/sprites.atlas/player.png
diff --git a/examples/space-shooter/assets/textures/player.png.meta b/examples/space-shooter/assets/textures/sprites.atlas/player.png.meta
similarity index 100%
rename from examples/space-shooter/assets/textures/player.png.meta
rename to examples/space-shooter/assets/textures/sprites.atlas/player.png.meta
diff --git a/examples/space-shooter/assets/textures/star.png b/examples/space-shooter/assets/textures/sprites.atlas/star.png
similarity index 100%
rename from examples/space-shooter/assets/textures/star.png
rename to examples/space-shooter/assets/textures/sprites.atlas/star.png
diff --git a/examples/space-shooter/assets/textures/star.png.meta b/examples/space-shooter/assets/textures/sprites.atlas/star.png.meta
similarity index 100%
rename from examples/space-shooter/assets/textures/star.png.meta
rename to examples/space-shooter/assets/textures/sprites.atlas/star.png.meta
diff --git a/tools/check-golden.mjs b/tools/check-golden.mjs
index 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.mjs
index 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.mjs
index 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;