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: include non-scene-referenced spine atlases in texture packing

esengine07920163e193
diff --git a/editor/src/builder/TextureAtlas.ts b/editor/src/builder/TextureAtlas.ts
index 1cee79847..0bdb41d36 100644
--- a/editor/src/builder/TextureAtlas.ts
+++ b/editor/src/builder/TextureAtlas.ts
@@ -195,14 +195,15 @@ export class TextureAtlasPacker {
async pack(
imagePaths: string[],
sceneDataList: Array<{ name: string; data: Record<string, unknown> }>,
- maxSize: number = 2048
+ maxSize: number = 2048,
+ allAssetPaths?: string[]
): Promise<AtlasResult> {
const result: AtlasResult = { pages: [], frameMap: new Map() };
const eligiblePaths = imagePaths.filter(p => isPackableImage(p));
if (eligiblePaths.length === 0) return result;
- const spineTextures = await this.collectSpineTextures(sceneDataList);
+ const spineTextures = await this.collectSpineTextures(sceneDataList, allAssetPaths);
const nineSliceTextures = this.collectNineSliceTextures(sceneDataList);
const images: Array<{ path: string; width: number; height: number; data: Uint8Array }> = [];
@@ -347,9 +348,11 @@ export class TextureAtlasPacker {
}
private async collectSpineTextures(
- sceneDataList: Array<{ name: string; data: Record<string, unknown> }>
+ sceneDataList: Array<{ name: string; data: Record<string, unknown> }>,
+ allAssetPaths?: string[]
): Promise<Set<string>> {
const atlasPaths = new Set<string>();
+
for (const { data } of sceneDataList) {
const entities = data.entities as Array<{
components: Array<{ type: string; data: Record<string, unknown> }>;
@@ -367,6 +370,14 @@ export class TextureAtlasPacker {
}
}
+ if (allAssetPaths) {
+ for (const p of allAssetPaths) {
+ if (/\.atlas$/i.test(p)) {
+ atlasPaths.add(p);
+ }
+ }
+ }
+
const result = new Set<string>();
for (const atlasRelPath of atlasPaths) {
const fullPath = joinPath(this.projectDir_, atlasRelPath);
diff --git a/editor/src/builder/WeChatBuilder.ts b/editor/src/builder/WeChatBuilder.ts
index 65c9cd99a..de0227367 100644
--- a/editor/src/builder/WeChatBuilder.ts
+++ b/editor/src/builder/WeChatBuilder.ts
@@ -527,7 +527,7 @@ async function initSpineModule() {
}
const packer = new TextureAtlasPacker(this.fs_!, this.projectDir_, this.assetLibrary_);
- const atlasResult = await packer.pack(imagePaths, sceneDataList);
+ const atlasResult = await packer.pack(imagePaths, sceneDataList, 2048, [...assetPaths]);
for (let i = 0; i < atlasResult.pages.length; i++) {
const atlasPath = joinPath(outputDir, `atlas_${i}.png`);