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.

fix(playable): a playable samples its textures as their .meta says - the page was handed no manifest, so no texture's wrap, filter, colour space or 9-slice border reached it and each took the defaults: a ground or a wall whose picture repeats drew one copy and smeared its edge over the rest, right in the editor and in a web export and wrong in the playable; the import settings of what is inlined ride in the page and the host hands them to the runtime

yhh5e1ce94d4810
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1bb6d2a7d..11eed0cac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -33,6 +33,7 @@ published separately; it ships inside the editor.
### Fixed
+- **A playable samples its textures as their import settings say.** A single-file playable was handed no manifest, which is the only way a texture's `.meta` reaches a package, so its wrap mode, its filter, whether it is colour and its 9-slice border were all lost and every texture took the defaults. A ground or a wall whose picture repeats then drew one copy of it and smeared its last row of pixels over everything past the first tile: cliffs came out one flat colour with level stripes along the waterline, while the same scene was right in the editor and in a web export. The settings of the textures a playable inlines now ride in the page and reach the runtime the way they reach every other package.
- **A cloud's shadow dims the sun, not the sky.** Sky Atmosphere's **Cloud Shadows** and a custom sky's `groundShadow` multiplied every surface in the frame by the shadow, after it was lit: ambient light, reflections, other lights and emission were dimmed with the sun, and an unlit or emissive object went dark under a cloud. Measured against a reference island lit the same way, its ground came out 25 to 35 levels darker than the reference, and lit by the sky alone it was black. Now the sky draws a cloud shadow map before the scene, into one tile of the sun's shadow atlas (16 km round the camera, `u_cloudShadowExtentKm`), and the first directional light is dimmed by it where each surface is shaded, as Unreal's atmosphere sun reads its clouds' shadow map; nothing else is. The cloud shadow criteria now light their floor by a sun and add a floor nothing lights, which must keep its colour under the clouds; they and 56 shadow and sun criteria pass on WebGL2 and WebGPU. With the atlas full (High quality's four cascades fill it) the sun gives up its farthest cascade to the map. The map holds the light left at the camera's own height, exact below the cloud layer and an estimate inside it.
- **A package that ships texture recipes draws them.** An export carried its `.esimage` files and drew its ground and its walls with no texture, saying only in the console that nothing there draws recipes. The call that installs the drawer had ended up in a part of the built SDK that was not marked as having an effect, and the bundler dropped it; and a playable ad, whose entry is the whole SDK, never imported the drawer at all. Both are put right, and a check now bundles a game that imports it and looks for it.
- **A cleared asset field no longer stops a game.** An empty string in an asset field of an engine component (a material cleared to nothing) was taken for a path to load, came back from the load still a string, was written back as one and asked for again, without end: a field of plants put it on every cell it grew, and the packaged game stopped answering half a minute in. An empty string is no asset now, and a path nothing resolves keeps its placeholder.
diff --git a/pipeline/src/export/exportPlayable.ts b/pipeline/src/export/exportPlayable.ts
index dd7fa9d9d..b01c0000f 100644
--- a/pipeline/src/export/exportPlayable.ts
+++ b/pipeline/src/export/exportPlayable.ts
@@ -42,6 +42,7 @@ import { makeZip } from '../../../build-tools/utils/zip.js';
import { planSideModules, spineRefusalMessage, sideModuleFiles } from '../bundle/sideModuleScan';
import type { Physics3DBackend } from 'esengine';
import { forcedSideModules, moduleChoices, moduleForAsset } from '../bundle/engineInstalls';
+import { textureImportSettingsFrom, type ParsedTextureImportSettings } from '../../../sdk/src/asset/textureImportSettings';
import type { ModuleChoice, ProjectFeatures, ProjectPackaging } from '../project/format';
export interface ExportPlayableResult {
@@ -277,6 +278,9 @@ export async function exportPlayable(opts: {
const pathMap: Record<string, string> = {};
const optimizationAssets: PlayableOptimizationAsset[] = [];
let manifestEntries: CookManifest['entries'] = [];
+ // How each texture is sampled and sliced, as its .meta says: the one thing of the manifest a single file needs. Without it every
+ // texture of a playable took the defaults, so a ground whose layers repeat drew one copy of each and smeared its edge over the rest.
+ const textureImports: Record<string, { path: string; type: 'texture'; size: number; labels: string[]; textureImport: ParsedTextureImportSettings }> = {};
try {
const manifest = JSON.parse(await readFile(path.join(cookDir, 'assets.manifest.json'), 'utf8')) as CookManifest;
manifestEntries = manifest.entries;
@@ -288,6 +292,8 @@ export async function exportPlayable(opts: {
for (const e of manifest.entries) {
const buf = await readFile(path.join(cookDir, e.path));
const key = `@uuid:${e.uuid}`;
+ const textureImport = textureImportSettingsFrom((e as { importer?: Record<string, unknown> }).importer);
+ if (textureImport) textureImports[e.uuid.toLowerCase()] = { path: e.sourcePath ?? e.path, type: 'texture', size: 0, labels: [], textureImport };
const dataUrl = `data:${mimeOf(e.path)};base64,${buf.toString('base64')}`;
pathMap[e.sourcePath ?? e.path] = key;
// The data URL, not the file: base64 is what the asset costs the package.
@@ -399,6 +405,9 @@ export async function exportPlayable(opts: {
span('wasm/side-modules', `window.__SIDE_MODULES__=${JSON.stringify(sideModules)};`);
const afterAssets =
`window.__GAME_PATHMAP__=${JSON.stringify(pathMap)};` +
+ (Object.keys(textureImports).length > 0
+ ? `window.__GAME_MANIFEST__=${JSON.stringify({ version: '2.0', groups: { main: { bundleMode: 'local', labels: [], assets: textureImports } } })};`
+ : '') +
span(`scenes/${sceneName}.json`, `window.__GAME_SCENES__=${JSON.stringify(scenes)};`) +
`window.__GAME_FIRST__=${JSON.stringify(sceneName)};` +
`window.__GAME_RUNTIME__=${JSON.stringify(playableRuntimeFields(withAudioLoadTypes(opts.runtime ?? DEFAULT_RUNTIME_CONFIG, cook.audioLoadTypes, cook.audioEncoded)))};` +
diff --git a/pipeline/src/runtime/playableHost.ts b/pipeline/src/runtime/playableHost.ts
index 766e0c711..ea83e3101 100644
--- a/pipeline/src/runtime/playableHost.ts
+++ b/pipeline/src/runtime/playableHost.ts
@@ -32,6 +32,8 @@ declare const __ENGINE_WASM__: PackedBytes;
declare const __SIDE_MODULES__: Record<string, { glue: PackedBytes; wasm: PackedBytes }>;
declare const __GAME_ASSETS__: Record<string, string>;
declare const __GAME_PATHMAP__: Record<string, string>;
+/** The texture import settings of what is inlined, in the manifest's own shape; absent from a page with none and from older exports. */
+declare const __GAME_MANIFEST__: Parameters<typeof initPlayableRuntime>[0]['manifest'];
declare const __GAME_SCENES__: Array<{ name: string; data: SceneData }>;
declare const __GAME_FIRST__: string;
/** The project's settings, in the same shape game.config.json carries them —
@@ -151,6 +153,7 @@ async function boot(): Promise<void> {
assets: __GAME_ASSETS__,
// Older exports predate the path map; the runtime treats it as optional.
assetPathMap: typeof __GAME_PATHMAP__ !== 'undefined' ? __GAME_PATHMAP__ : undefined,
+ manifest: typeof __GAME_MANIFEST__ !== 'undefined' ? __GAME_MANIFEST__ : undefined,
scenes: __GAME_SCENES__,
firstScene: __GAME_FIRST__,
// Everything the config APPLIES to a live app: physics, the mixer, the theme.
diff --git a/pipeline/tests/export-playable.test.ts b/pipeline/tests/export-playable.test.ts
index f8eb6c356..8ccbb696d 100644
--- a/pipeline/tests/export-playable.test.ts
+++ b/pipeline/tests/export-playable.test.ts
@@ -230,6 +230,36 @@ describe('exportGame (playable)', () => {
expect(html).not.toContain('screen.orientation');
}, 60_000);
+ // How a texture is sampled is in its .meta, and the manifest is the only way that reaches a package. A playable was handed none:
+ // every texture took the defaults, so a wall or a ground whose picture repeats drew one copy and smeared its edge over the rest,
+ // while the same scene was right in the editor and in a web export.
+ it("carries each texture's import settings to the page", async () => {
+ const TILED = 'eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee';
+ writeFileSync(path.join(root, 'assets', 'tiled.png'), solidPng(8, 8, [90, 90, 90, 255]));
+ writeFileSync(path.join(root, 'assets', 'tiled.png.meta'),
+ JSON.stringify({ uuid: TILED, version: '2.0', type: 'texture', importer: { wrapMode: 'repeat', filterMode: 'nearest', sRGB: false } }));
+ writeFileSync(path.join(root, 'scenes', 'tiled.esscene'),
+ JSON.stringify({ version: '1.0', name: 'Tiled', entities: [{ id: 0, components: [{ type: 'Sprite', data: { texture: `@uuid:${TILED}` } }] }] }));
+ writeFileSync(path.join(root, 'scenes', 'tiled.esscene.meta'), meta('ffffffff-ffff-4fff-8fff-ffffffffffff', 'scene'));
+ const outDir = path.join(root, 'dist-tiled');
+ const res = await exportGame({
+ root, entryScene: 'scenes/tiled.esscene', hostsDir: HOSTS, packagesDir: OFFICIAL_PACKAGES, scriptsEntry: 'src/main.ts',
+ sdkDistDir: path.join(root, '_sdk'), wasmDir: path.join(root, '_wasm'), outDir, title: 'Tiled', platform: 'playable', minify: false,
+ });
+ expect(res.ok).toBe(true);
+ const html = readFileSync(path.join(outDir, 'index.html'), 'utf8');
+ const at = html.indexOf('window.__GAME_MANIFEST__=');
+ expect(at).toBeGreaterThan(0);
+ const json = html.slice(at + 'window.__GAME_MANIFEST__='.length);
+ const manifest = JSON.parse(json.slice(0, json.indexOf(';window.'))) as { groups: { main: { assets: Record<string, { path: string; textureImport: unknown }> } } };
+ expect(manifest.groups.main.assets[TILED]).toEqual({
+ path: 'assets/tiled.png', type: 'texture', size: 0, labels: [],
+ textureImport: { filter: 'nearest', wrap: 'repeat', srgb: false },
+ });
+ // And the host hands it on: the runtime reads nothing it was not given.
+ expect(inlinedText(html, '__GAME_BUNDLE__')).toContain('__GAME_MANIFEST__');
+ }, 60_000);
+
// A texture recipe is drawn by esengine/image, which the whole entry does not carry: it is imported for the asset that needs
// it. A playable shipped six recipes and drew its ground and its walls with no texture, with nothing in the build saying so.
it('imports the module an asset needs and the entry does not carry', async () => {
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index d7af27a22..2430cdb50 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -4766,4 +4766,6 @@ export const NOTED = {
{"note": "A sound or a piece of music can ship as its recipe."},
"perf(audio): a piece of music is made in less than half the time - a note's sample loop asked for an exponential and a sine again every sample and read each pitch, loudness and filter corner through a curve; what does not change is worked out before the loop, a decay is a product kept up sample by sample and a ringing mode a point carried round a circle: a minute of music in 2.4 s where it took 5.3, two samples in five million off by one step of sixteen bits":
{"note": "A sound or a piece of music can ship as its recipe."},
+ "fix(playable): a playable samples its textures as their .meta says - the page was handed no manifest, so no texture's wrap, filter, colour space or 9-slice border reached it and each took the defaults: a ground or a wall whose picture repeats drew one copy and smeared its edge over the rest, right in the editor and in a web export and wrong in the playable; the import settings of what is inlined ride in the page and the host hands them to the runtime":
+ {"note": "A playable samples its textures as their import settings say."},
};