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(verify): a pixel gate whose scene could not load an asset fails and names it
esenginecaa3a53ee107
diff --git a/desktop b/desktopindex 46534f01f..bcadebb7b 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit 46534f01f24e237c73e51bdd0a5cd4c7d2a1339c+Subproject commit bcadebb7bc3bdc4d617e4c96bb5a56ba823038e0diff --git a/fixtures/scenes/mat-env/rough.esmaterial b/fixtures/scenes/mat-env/rough.esmaterialnew file mode 100644index 000000000..d91eb6cfa--- /dev/null+++ b/fixtures/scenes/mat-env/rough.esmaterial@@ -0,0 +1,11 @@+{+ "version": "1.0",+ "type": "material",+ "shader": "builtin:model",+ "blendMode": 0,+ "depthTest": false,+ "properties": {+ "u_metallic": 1,+ "u_roughness": 1+ }+}diff --git a/fixtures/scenes/reflection-room.esscene b/fixtures/scenes/reflection-room.essceneindex ff313f394..a463b7384 100644--- a/fixtures/scenes/reflection-room.esscene+++ b/fixtures/scenes/reflection-room.esscene@@ -105,7 +105,7 @@{"type": "MeshLightmap","data": {- "lightmap": "reflection-room_lightmap.png",+ "lightmap": "/scenes/reflection-room_lightmap.png","scaleOffset": {"x": 0.3515625,"y": 0.3515625,@@ -156,7 +156,7 @@{"type": "MeshLightmap","data": {- "lightmap": "reflection-room_lightmap.png",+ "lightmap": "/scenes/reflection-room_lightmap.png","scaleOffset": {"x": 0.3515625,"y": 0.3515625,@@ -207,7 +207,7 @@{"type": "MeshLightmap","data": {- "lightmap": "reflection-room_lightmap.png",+ "lightmap": "/scenes/reflection-room_lightmap.png","scaleOffset": {"x": 0.28125,"y": 0.28125,@@ -258,7 +258,7 @@{"type": "MeshLightmap","data": {- "lightmap": "reflection-room_lightmap.png",+ "lightmap": "/scenes/reflection-room_lightmap.png","scaleOffset": {"x": 0.28125,"y": 0.28125,@@ -309,7 +309,7 @@{"type": "MeshLightmap","data": {- "lightmap": "reflection-room_lightmap.png",+ "lightmap": "/scenes/reflection-room_lightmap.png","scaleOffset": {"x": 0.28125,"y": 0.28125,@@ -361,7 +361,7 @@{"type": "MeshLightmap","data": {- "lightmap": "reflection-room_lightmap.png",+ "lightmap": "/scenes/reflection-room_lightmap.png","scaleOffset": {"x": 0.1640625,"y": 0.1640625,diff --git a/tools/render-host/host.ts b/tools/render-host/host.tsindex 9a0b33c39..4843e7185 100644--- a/tools/render-host/host.ts+++ b/tools/render-host/host.ts@@ -251,7 +251,7 @@ function replicateScene(scene: SceneData, spec: ReplicateSpec): SceneData {*/async function loadScene(sceneUrl: string, manifestUrl?: string, replicate?: ReplicateSpec | null,-): Promise<number> {+): Promise<SceneLoadReport> {if (!app) throw new Error('loadScene before boot');const res = await fetch(sceneUrl);if (!res.ok) throw new Error(`scene fetch failed: ${res.status} ${sceneUrl}`);@@ -260,12 +260,14 @@ async function loadScene(const uuidToUrl = await fetchManifest(manifestUrl);const assets = app.getResource(Assets);let resolved: SceneData = raw;+ let missing: string[] = [];if (assets) {assets.baseUrl = ''; // manifest urls are root-relativeassets.setAssetRefResolver((ref: string) =>ref.startsWith(UUID_PREFIX) ? (uuidToUrl.get(ref.slice(UUID_PREFIX.length)) ?? null) : ref,);const result = await assets.preloadSceneAssets(raw);+ missing = result.missing.map((m) => m.ref);resolved = JSON.parse(JSON.stringify(raw)) as SceneData; // resolveSceneAssetPaths mutatesassets.resolveSceneAssetPaths(resolved, result);}@@ -285,7 +287,16 @@ async function loadScene(const entityMap = map as unknown as Map<number, number>;await loadSpine(app, raw, entityMap, toUrl);await loadDragonBones(app, raw, entityMap, toUrl);- return map.size;+ return { entities: map.size, missing };+}++/**+ * What a scene load leaves behind. `missing` names every ref the preload could not+ * turn into an asset: a frame drawn without one is not the frame the scene declares.+ */+interface SceneLoadReport {+ entities: number;+ missing: string[];}async function fetchManifest(manifestUrl?: string): Promise<Map<string, string>> {diff --git a/tools/render-host/run.mjs b/tools/render-host/run.mjsindex b69253e78..6e204a05c 100644--- a/tools/render-host/run.mjs+++ b/tools/render-host/run.mjs@@ -200,13 +200,17 @@ function finish(result, server) {// which no pixel in the frame can show.const pickOk = !result.pick || result.pick.hit === result.pick.want;const renderedOk = result.capture?.rendered ?? false;- const ok = result.ok && renderedOk && (result.expect?.ok ?? true) && (result.count?.ok ?? true) &&+ // A scene that could not load an asset it names draws a frame nobody declared, so+ // its pixels answer a different question — say which asset instead.+ const assetsOk = (result.missingAssets?.length ?? 0) === 0;+ const ok = result.ok && renderedOk && assetsOk && (result.expect?.ok ?? true) && (result.count?.ok ?? true) &&(result.seam?.ok ?? true) &&(result.resize?.ok ?? true) && (result.preview?.ok ?? true) &&(result.meshPreview?.ok ?? true) && (result.grid?.ok ?? true) &&(result.draws?.ok ?? true) && (result.counters?.ok ?? true) &&deviceLossOk && meshOk && pickOk;- console.log(`\n[verify:render] ${ok ? 'PASS' : 'FAIL'} — ${SCENE} (${BACKEND})`);+ const why = assetsOk ? '' : `: could not load ${result.missingAssets.join(', ')}`;+ console.log(`\n[verify:render] ${ok ? 'PASS' : 'FAIL'} — ${SCENE} (${BACKEND})${why}`);console.log('DRIVE_RESULT ' + JSON.stringify(result));try {server?.close();@@ -252,7 +256,7 @@ app.whenReady().then(async () => {// ESTELLA_VERIFY_SCALE = {"copies":N,"cols":C,"spacing":[x,y]}: the fixture holds ONE// of the thing being measured and this lays N of it out on a grid — a scale scene as a// FILE would be a megabyte of JSON in every clone, for a pure function of those two.- const entityCount = await exec(+ const { entities: entityCount, missing: missingAssets } = await exec(`window.__estellaHeadless.api.loadScene(${JSON.stringify(SCENE)}, ${JSON.stringify(MANIFEST)}`+ `${SCALE ? ', ' + JSON.stringify(JSON.parse(SCALE)) : ''})`,);@@ -843,7 +847,7 @@ app.whenReady().then(async () => {};`);}- finish({ ok: true, entityCount, drawCalls, draws, counters, profile, capture, expect, count, seam, resize, preview, meshPreview, grid, deviceLoss, meshResident, meshAsset, meshMaterial, meshPrefab, setField, animator, pick, cameraTarget }, server);+ finish({ ok: true, entityCount, missingAssets, drawCalls, draws, counters, profile, capture, expect, count, seam, resize, preview, meshPreview, grid, deviceLoss, meshResident, meshAsset, meshMaterial, meshPrefab, setField, animator, pick, cameraTarget }, server);} catch (e) {finish({ ok: false, error: String((e && e.stack) || e) }, server);}