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(editor): importing a model produces what a scene can use

esengine468d729b2922
diff --git a/desktop/electron/importAssets.ts b/desktop/electron/importAssets.ts
index 4f17e08de..969b4f190 100644
--- a/desktop/electron/importAssets.ts
+++ b/desktop/electron/importAssets.ts
@@ -15,6 +15,7 @@ import { resolveInRoot, META_EXT } from './projectFs';
import { capture } from './fileJournal';
import { EXT_TO_TYPE, metaTypeFor, metaTypeForFile, mintMeta, writeMeta, adoptOrphan } from '../../pipeline/src/assets/assetMeta';
import { CONTENT_TYPED_EXTENSIONS } from '../../tools/assetMetaTable.js';
+import { importModel, isModelSource } from './importModel';
/** The supported import extensions (no leading dot) — used by the file dialog filter.
* The content-typed ones are offered too: a Spine JSON skeleton is a `.json`, and a
@@ -96,6 +97,8 @@ export interface ImportResult {
imported: string[];
/** Base names skipped (unknown / unsupported extension). */
skipped: string[];
+ /** What a model import could not carry across — reported, never dropped. */
+ warnings?: string[];
}
/**
@@ -112,6 +115,16 @@ export async function importAssets(root: string, destDir: string, sources: strin
await mkdir(absDir, { recursive: true });
const imported: string[] = [];
const skipped: string[] = [];
+ const warnings: string[] = [];
+ // A model produces the assets a scene references; the source itself is not one
+ // of them, so importing one without this leaves a file nothing can draw.
+ const produce = async (abs: string, dir: string, originDir?: string): Promise<void> => {
+ if (!isModelSource(abs)) return;
+ const result = await importModel(root, dir, abs, originDir);
+ imported.push(...result.products);
+ warnings.push(...result.warnings.map((w) => `${path.basename(abs)}: ${w}`));
+ };
+
for (const src of sources) {
const type = await metaTypeForFile(src);
if (!type) {
@@ -126,6 +139,10 @@ export async function importAssets(root: string, destDir: string, sources: strin
await capture(inside, 'write');
await adoptOrphan(path.resolve(root, inside)); // 'has-meta' = already registered, keep its uuid
imported.push(inside);
+ // Beside the source, not in the browser's folder: a model's products
+ // belong with it, and re-importing it must land on the same files.
+ await produce(path.resolve(root, inside), path.posix.dirname(inside) === '.'
+ ? '' : path.posix.dirname(inside));
continue;
}
const name = uniqueName(absDir, path.basename(src));
@@ -135,6 +152,7 @@ export async function importAssets(root: string, destDir: string, sources: strin
await copyFile(src, absDest);
await writeMeta(absDest, type);
imported.push(rel);
+ await produce(absDest, destDir, path.dirname(src));
}
- return { imported, skipped };
+ return { imported, skipped, ...(warnings.length > 0 ? { warnings } : {}) };
}
diff --git a/desktop/electron/importModel.ts b/desktop/electron/importModel.ts
new file mode 100644
index 000000000..4ac7bf2ea
--- /dev/null
+++ b/desktop/electron/importModel.ts
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file Model import: a `.gltf`/`.glb` in the project produces the assets a
+ * scene can actually reference.
+ *
+ * The engine loads none of the source formats — a Mesh2D reads `.esmesh` — so a
+ * model that is only copied in leaves the user with a file nothing can draw.
+ * This is the same import the CLI runs, at the moment the file arrives.
+ */
+import { copyFile, mkdir, writeFile } from 'node:fs/promises';
+import { existsSync, readFileSync } from 'node:fs';
+import path from 'node:path';
+import { isInsideRoot } from '../../pipeline/src/fs/pathSandbox';
+import { resolveInRoot } from './projectFs';
+import { capture } from './fileJournal';
+import { adoptOrphan } from '../../pipeline/src/assets/assetMeta';
+import {
+ importGltfMeshes, encodeImportedMesh, assembleGltfPrefab,
+} from '../../pipeline/src/assets/gltfImport';
+
+export interface ModelImportResult {
+ /** Project-relative paths of everything written, in the order it was produced. */
+ products: string[];
+ /** What the source says that this engine cannot draw — reported, never dropped. */
+ warnings: string[];
+}
+
+export const MODEL_EXTENSIONS = ['.gltf', '.glb'];
+
+export function isModelSource(file: string): boolean {
+ return MODEL_EXTENSIONS.includes(path.extname(file).toLowerCase());
+}
+
+/**
+ * Import `absSource` (already inside the project) into `destDir`, writing the
+ * meshes, the images it carries, and the prefab that assembles them.
+ *
+ * @param originDir Where the source's own relative uris resolve from. A copied
+ * model no longer sits beside its images, and reading them from where it
+ * landed finds nothing.
+ */
+export async function importModel(root: string, destDir: string, absSource: string,
+ originDir?: string): Promise<ModelImportResult> {
+ const absDir = resolveInRoot(root, destDir);
+ await mkdir(absDir, { recursive: true });
+ const sourceDir = originDir ?? path.dirname(absSource);
+ const stem = path.basename(absSource).replace(/\.(gltf|glb)$/i, '');
+ const projectRef = (abs: string): string =>
+ path.relative(path.resolve(root), abs).split(path.sep).join('/');
+
+ const { meshes, textures, nodes, warnings } = importGltfMeshes(
+ new Uint8Array(readFileSync(absSource)), stem,
+ (uri) => {
+ const abs = path.join(sourceDir, decodeURIComponent(uri));
+ return existsSync(abs) ? new Uint8Array(readFileSync(abs)) : null;
+ },
+ );
+
+ const products: string[] = [];
+ const write = async (name: string, bytes: Uint8Array | string): Promise<string> => {
+ const rel = destDir ? `${destDir}/${name}` : name;
+ await capture(rel, 'write');
+ await writeFile(path.join(absDir, name), bytes);
+ await adoptOrphan(path.join(absDir, name)); // keeps the uuid a re-import must not change
+ products.push(rel);
+ return rel;
+ };
+
+ // An image the source points at is left where it lies when that is already in
+ // the project; one from outside is copied in, named for the model so a second
+ // import of a different model cannot land on it.
+ const externalRefs = new Map<string, string>();
+ const external = (uri: string): string => externalRefs.get(uri) ?? uri;
+ for (const mesh of meshes) {
+ const image = mesh.material?.baseColorTexture;
+ if (!image?.external || externalRefs.has(image.file)) continue;
+ const abs = path.join(sourceDir, decodeURIComponent(image.file));
+ if (!existsSync(abs)) continue;
+ if (isInsideRoot(root, abs)) {
+ externalRefs.set(image.file, projectRef(abs));
+ continue;
+ }
+ const name = `${stem}_${path.basename(abs)}`;
+ const rel = destDir ? `${destDir}/${name}` : name;
+ await capture(rel, 'write');
+ await copyFile(abs, path.join(absDir, name));
+ await adoptOrphan(path.join(absDir, name));
+ products.push(rel);
+ externalRefs.set(image.file, rel);
+ }
+
+ for (const mesh of meshes) await write(`${mesh.name}.esmesh`, encodeImportedMesh(mesh));
+ for (const texture of textures) await write(texture.name, texture.bytes);
+ if (meshes.length > 0) {
+ const prefab = assembleGltfPrefab(stem, meshes, {
+ refs: { prefix: destDir ? `${destDir}/` : '', external },
+ nodes,
+ });
+ await write(`${stem}.esprefab`, `${JSON.stringify(prefab, null, 2)}\n`);
+ }
+ return { products, warnings };
+}
diff --git a/desktop/src/i18n/messages/content.ts b/desktop/src/i18n/messages/content.ts
index 9fa3a4e68..10d0fcdf8 100644
--- a/desktop/src/i18n/messages/content.ts
+++ b/desktop/src/i18n/messages/content.ts
@@ -153,6 +153,7 @@ export const contentMessages = defineMessages({
'cb.skippedOne': { en: 'Skipped {count} unsupported file', zh: '已跳过 {count} 个不支持的文件' },
'cb.skippedMany': { en: 'Skipped {count} unsupported files', zh: '已跳过 {count} 个不支持的文件' },
'cb.importFailed': { en: 'Import failed: {error}', zh: '导入失败:{error}' },
+ 'cb.importNotes': { en: '{first} (+{rest} more)', zh: '{first}(另有 {rest} 条)' },
// — Create-entity picker (CreatePopover) —
'cb.createEntity': { en: 'Create entity', zh: '创建实体' },
diff --git a/desktop/src/panels/ContentBrowser.tsx b/desktop/src/panels/ContentBrowser.tsx
index 555ab0ab6..f5b6daaeb 100644
--- a/desktop/src/panels/ContentBrowser.tsx
+++ b/desktop/src/panels/ContentBrowser.tsx
@@ -783,7 +783,9 @@ export function ContentBrowser() {
// Shared post-import handling (dialog import + OS drag-drop): refresh, select the
// last new asset, and report imported / skipped counts.
- const applyImportResult = (res: { imported: string[]; skipped: string[] } | null) => {
+ const applyImportResult = (
+ res: { imported: string[]; skipped: string[]; warnings?: string[] } | null,
+ ) => {
if (!res) return;
refreshFs();
if (res.imported.length) {
@@ -795,6 +797,13 @@ export function ContentBrowser() {
const n = res.skipped.length;
Toasts.push(t(n > 1 ? 'cb.skippedMany' : 'cb.skippedOne', { count: n }), 'warn');
}
+ // What an import could not carry across (a model's PBR channels, a skipped
+ // primitive). Silence here is how half a model goes missing unnoticed.
+ const notes = res.warnings ?? [];
+ if (notes.length) {
+ Toasts.push(notes.length === 1 ? notes[0]!
+ : t('cb.importNotes', { first: notes[0]!, rest: notes.length - 1 }), 'warn');
+ }
};
const importAssets = async () => {
diff --git a/desktop/src/project/assetTypes.ts b/desktop/src/project/assetTypes.ts
index 611da4ca2..d3c4a2cef 100644
--- a/desktop/src/project/assetTypes.ts
+++ b/desktop/src/project/assetTypes.ts
@@ -18,7 +18,7 @@
*/
import {
Folder, Film, Image, FileImage, PersonStanding, Music,
- Box, Component, Blend, FileCode2, Clapperboard, Grid3x3, File, Workflow, Gamepad2, GitBranch, ListTree, Languages, Images, Video, Waypoints, Sparkles, Plug, Type,
+ Box, Boxes, Component, Blend, FileCode2, Clapperboard, Grid3x3, File, Workflow, Gamepad2, GitBranch, ListTree, Languages, Images, Video, Waypoints, Sparkles, Plug, Type,
type LucideIcon,
} from 'lucide-react';
import { ContributionRegistry, type Disposable, type Owner } from '@/contrib/ContributionRegistry';
@@ -71,7 +71,11 @@ export const ASSET_TYPES: Record<BuiltinAssetType, AssetTypeDef> = {
// different asset — a baked page + metrics for BitmapText — and stay separate.
font: { extensions: ['ttf', 'otf', 'woff', 'woff2'], badge: 'FNT', icon: Type, tint: '#9a9fc4' },
// Geometry that lives on the GPU rather than in a component (.esmesh).
- mesh: { extensions: ['esmesh', 'gltf', 'glb'], badge: 'MSH', icon: Box, tint: '#8fa9b5' },
+ mesh: { extensions: ['esmesh'], badge: 'MSH', icon: Box, tint: '#8fa9b5' },
+ // The model a mesh was imported FROM. Its own type, because the engine loads
+ // none of these — offering one where a mesh is asked for is offering a ref
+ // that cannot resolve.
+ model: { extensions: ['gltf', 'glb'], badge: 'MDL', icon: Boxes, tint: '#8fa9b5' },
video: { extensions: ['mp4', 'm4v', 'mov'], badge: 'VID', icon: Video, tint: '#c08fb5' },
prefab: { extensions: ['esprefab'], badge: 'PFB', icon: Component, tint: '#c2a274' },
// .esmaterial is the real extension (the SDK MaterialAssetLoader only loads it);
diff --git a/desktop/src/types.ts b/desktop/src/types.ts
index 8c7301b4f..e60d3e293 100644
--- a/desktop/src/types.ts
+++ b/desktop/src/types.ts
@@ -255,6 +255,7 @@ export type BuiltinAssetType =
| 'locale'
| 'font'
| 'mesh'
+ | 'model'
| 'file';
/** A built-in asset type, or one a plugin contributed. */
diff --git a/desktop/tests/import-model.test.ts b/desktop/tests/import-model.test.ts
new file mode 100644
index 000000000..7bdbc6ac0
--- /dev/null
+++ b/desktop/tests/import-model.test.ts
@@ -0,0 +1,140 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file Importing a model produces the assets a scene can reference. The engine
+ * loads none of the source formats, so a `.glb` that only lands in the
+ * project is a file nothing can draw — these cover what has to come with it.
+ */
+import { describe, it, expect, beforeEach, afterEach } from 'vitest';
+import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync, existsSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import path from 'node:path';
+import { importAssets } from '../electron/importAssets';
+
+let root: string;
+let outside: string;
+
+beforeEach(() => {
+ root = mkdtempSync(path.join(tmpdir(), 'estella-model-'));
+ outside = mkdtempSync(path.join(tmpdir(), 'estella-src-'));
+});
+
+afterEach(() => {
+ rmSync(root, { recursive: true, force: true });
+ rmSync(outside, { recursive: true, force: true });
+});
+
+const meta = (abs: string): { uuid: string; type: string } =>
+ JSON.parse(readFileSync(`${abs}.meta`, 'utf8'));
+
+/** One triangle, one material — with an image uri when `image` names one. */
+function gltf(image?: string): string {
+ const positions = new Float32Array([0, 0, 0, 1, 0, 0, 0, 1, 0]);
+ const uvs = new Float32Array([0, 0, 1, 0, 0, 1]);
+ const indices = new Uint16Array([0, 1, 2]);
+ const bytes = Buffer.concat([
+ Buffer.from(positions.buffer), Buffer.from(uvs.buffer), Buffer.from(indices.buffer),
+ ]);
+ return JSON.stringify({
+ asset: { version: '2.0' },
+ buffers: [{ byteLength: bytes.length, uri: `data:application/octet-stream;base64,${bytes.toString('base64')}` }],
+ bufferViews: [
+ { buffer: 0, byteOffset: 0, byteLength: 36 },
+ { buffer: 0, byteOffset: 36, byteLength: 24 },
+ { buffer: 0, byteOffset: 60, byteLength: 6 },
+ ],
+ accessors: [
+ { bufferView: 0, componentType: 5126, count: 3, type: 'VEC3' },
+ { bufferView: 1, componentType: 5126, count: 3, type: 'VEC2' },
+ { bufferView: 2, componentType: 5123, count: 3, type: 'SCALAR' },
+ ],
+ ...(image ? { images: [{ uri: image }], textures: [{ source: 0 }] } : {}),
+ materials: [{
+ pbrMetallicRoughness: {
+ baseColorFactor: [1, 0.5, 0.25, 1], metallicFactor: 0,
+ ...(image ? { baseColorTexture: { index: 0 } } : {}),
+ },
+ }],
+ meshes: [{ primitives: [{ attributes: { POSITION: 0, TEXCOORD_0: 1 }, indices: 2, material: 0, mode: 4 }] }],
+ nodes: [{ name: 'Body', mesh: 0, translation: [3, 0, 0] }],
+ scenes: [{ nodes: [0] }],
+ scene: 0,
+ });
+}
+
+const prefabOf = (abs: string): { entities: { components: { type: string; data: Record<string, string> }[] }[] } =>
+ JSON.parse(readFileSync(abs, 'utf8'));
+
+describe('importing a model', () => {
+ it('writes the mesh and the prefab beside the copied source, each registered', async () => {
+ const src = path.join(outside, 'robot.gltf');
+ writeFileSync(src, gltf());
+ const res = await importAssets(root, 'assets/models', [src]);
+
+ expect(res.imported).toEqual([
+ 'assets/models/robot.gltf',
+ 'assets/models/robot.esmesh',
+ 'assets/models/robot.esprefab',
+ ]);
+ expect(meta(path.join(root, 'assets/models/robot.esmesh')).type).toBe('mesh');
+ expect(meta(path.join(root, 'assets/models/robot.esprefab')).type).toBe('prefab');
+
+ const prefab = prefabOf(path.join(root, 'assets/models/robot.esprefab'));
+ expect(prefab.entities[0]!.components[1]!.data.mesh).toBe('assets/models/robot.esmesh');
+ });
+
+ it('produces beside an in-project source, not in the browser’s folder', async () => {
+ const abs = path.join(root, 'assets/sub/tree.gltf');
+ mkdirSync(path.dirname(abs), { recursive: true });
+ writeFileSync(abs, gltf());
+ const res = await importAssets(root, 'assets/elsewhere', [abs]);
+ expect(res.imported).toContain('assets/sub/tree.esmesh');
+ expect(existsSync(path.join(root, 'assets/elsewhere/tree.esmesh'))).toBe(false);
+ });
+
+ it('brings an outside image in, named for the model', async () => {
+ writeFileSync(path.join(outside, 'skin.png'), 'PNG');
+ const src = path.join(outside, 'robot.gltf');
+ writeFileSync(src, gltf('skin.png'));
+ await importAssets(root, 'assets/models', [src]);
+
+ const copied = path.join(root, 'assets/models/robot_skin.png');
+ expect(existsSync(copied)).toBe(true);
+ expect(meta(copied).type).toBe('texture');
+ const prefab = prefabOf(path.join(root, 'assets/models/robot.esprefab'));
+ expect(prefab.entities[0]!.components[1]!.data.texture).toBe('assets/models/robot_skin.png');
+ });
+
+ it('leaves an image that is already in the project where it lies', async () => {
+ const abs = path.join(root, 'assets/models/robot.gltf');
+ mkdirSync(path.join(root, 'assets/models/textures'), { recursive: true });
+ writeFileSync(path.join(root, 'assets/models/textures/skin.png'), 'PNG');
+ writeFileSync(abs, gltf('textures/skin.png'));
+ await importAssets(root, 'assets/models', [abs]);
+
+ const prefab = prefabOf(path.join(root, 'assets/models/robot.esprefab'));
+ expect(prefab.entities[0]!.components[1]!.data.texture)
+ .toBe('assets/models/textures/skin.png');
+ expect(existsSync(path.join(root, 'assets/models/robot_skin.png'))).toBe(false);
+ });
+
+ it('keeps a product’s identity across a re-import', async () => {
+ const abs = path.join(root, 'assets/models/robot.gltf');
+ mkdirSync(path.dirname(abs), { recursive: true });
+ writeFileSync(abs, gltf());
+ await importAssets(root, 'assets/models', [abs]);
+ const first = meta(path.join(root, 'assets/models/robot.esmesh')).uuid;
+
+ await importAssets(root, 'assets/models', [abs]);
+ expect(meta(path.join(root, 'assets/models/robot.esmesh')).uuid).toBe(first);
+ });
+
+ it('reports what the source says and this engine cannot draw', async () => {
+ const src = path.join(outside, 'metal.gltf');
+ const doc = JSON.parse(gltf()) as { materials: { pbrMetallicRoughness: { metallicFactor: number } }[] };
+ doc.materials[0]!.pbrMetallicRoughness.metallicFactor = 1;
+ writeFileSync(src, JSON.stringify(doc));
+ const res = await importAssets(root, 'assets/models', [src]);
+ expect(res.warnings?.join('\n')).toContain('metallic-roughness');
+ });
+});
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index 7f8e15d4a..a4f07a246 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -2624,7 +2624,7 @@ readonly ["texture-compression-astc", "texture-compression-bc", "texture-compres
| 'texture' | 'material' | 'shader' | 'spine-atlas' | 'spine-skeleton'
| 'dragonbones-atlas' | 'dragonbones-skeleton'
| 'bitmap-font' | 'font' | 'prefab' | 'json' | 'audio' | 'video' | 'scene' | 'anim-clip'
- | 'tilemap' | 'tileset' | 'timeline'
+ | 'tilemap' | 'tileset' | 'timeline' | 'mesh'
| 'unknown'
```
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index a903fe6aa..96814c2d3 100644
--- a/sdk/etc/index.native.api.md
+++ b/sdk/etc/index.native.api.md
@@ -2632,7 +2632,7 @@ readonly ["texture-compression-astc", "texture-compression-bc", "texture-compres
| 'texture' | 'material' | 'shader' | 'spine-atlas' | 'spine-skeleton'
| 'dragonbones-atlas' | 'dragonbones-skeleton'
| 'bitmap-font' | 'font' | 'prefab' | 'json' | 'audio' | 'video' | 'scene' | 'anim-clip'
- | 'tilemap' | 'tileset' | 'timeline'
+ | 'tilemap' | 'tileset' | 'timeline' | 'mesh'
| 'unknown'
```
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index 3637145e5..120cabbc8 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -2619,7 +2619,7 @@ readonly ["texture-compression-astc", "texture-compression-bc", "texture-compres
| 'texture' | 'material' | 'shader' | 'spine-atlas' | 'spine-skeleton'
| 'dragonbones-atlas' | 'dragonbones-skeleton'
| 'bitmap-font' | 'font' | 'prefab' | 'json' | 'audio' | 'video' | 'scene' | 'anim-clip'
- | 'tilemap' | 'tileset' | 'timeline'
+ | 'tilemap' | 'tileset' | 'timeline' | 'mesh'
| 'unknown'
```
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index 6f4ad6f66..79efa5823 100644
--- a/sdk/etc/minigame.api.md
+++ b/sdk/etc/minigame.api.md
@@ -2619,7 +2619,7 @@ readonly ["texture-compression-astc", "texture-compression-bc", "texture-compres
| 'texture' | 'material' | 'shader' | 'spine-atlas' | 'spine-skeleton'
| 'dragonbones-atlas' | 'dragonbones-skeleton'
| 'bitmap-font' | 'font' | 'prefab' | 'json' | 'audio' | 'video' | 'scene' | 'anim-clip'
- | 'tilemap' | 'tileset' | 'timeline'
+ | 'tilemap' | 'tileset' | 'timeline' | 'mesh'
| 'unknown'
```
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index 821ca421c..eea722cf2 100644
--- a/sdk/etc/wechat.api.md
+++ b/sdk/etc/wechat.api.md
@@ -2619,7 +2619,7 @@ readonly ["texture-compression-astc", "texture-compression-bc", "texture-compres
| 'texture' | 'material' | 'shader' | 'spine-atlas' | 'spine-skeleton'
| 'dragonbones-atlas' | 'dragonbones-skeleton'
| 'bitmap-font' | 'font' | 'prefab' | 'json' | 'audio' | 'video' | 'scene' | 'anim-clip'
- | 'tilemap' | 'tileset' | 'timeline'
+ | 'tilemap' | 'tileset' | 'timeline' | 'mesh'
| 'unknown'
```
diff --git a/sdk/src/assetTypes.ts b/sdk/src/assetTypes.ts
index adff601d6..bb88f2a3c 100644
--- a/sdk/src/assetTypes.ts
+++ b/sdk/src/assetTypes.ts
@@ -10,7 +10,7 @@ export type EditorAssetType =
| 'texture' | 'material' | 'shader' | 'spine-atlas' | 'spine-skeleton'
| 'dragonbones-atlas' | 'dragonbones-skeleton'
| 'bitmap-font' | 'font' | 'prefab' | 'json' | 'audio' | 'video' | 'scene' | 'anim-clip'
- | 'tilemap' | 'tileset' | 'timeline'
+ | 'tilemap' | 'tileset' | 'timeline' | 'mesh'
| 'unknown';
export type AssetBuildTransform = (content: string, context: unknown) => string;
@@ -69,6 +69,10 @@ const ASSET_TYPE_REGISTRY: readonly AssetTypeEntry[] = [
{ extensions: ['ttf', 'otf', 'woff', 'woff2'], contentType: 'binary', editorType: 'font', addressableType: 'font', wechatPackInclude: true, hasTransitiveDeps: false },
{ extensions: ['esprefab'], contentType: 'json', editorType: 'prefab', addressableType: 'prefab', wechatPackInclude: true, hasTransitiveDeps: true },
{ extensions: ['esscene'], contentType: 'json', editorType: 'scene', addressableType: null, wechatPackInclude: false, hasTransitiveDeps: false },
+ // GPU geometry (MeshAssetLoader). Its own channel table makes it
+ // self-describing, so it names no other asset; the source it was imported
+ // from (.gltf/.glb) is not shipped and is deliberately absent here.
+ { extensions: ['esmesh'], contentType: 'binary', editorType: 'mesh', addressableType: 'binary', wechatPackInclude: true, hasTransitiveDeps: false },
{ extensions: ['esanim'], contentType: 'json', editorType: 'anim-clip', addressableType: null, wechatPackInclude: true, hasTransitiveDeps: true },
{ extensions: ['tmj'], contentType: 'json', editorType: 'tilemap', addressableType: 'json', wechatPackInclude: true, hasTransitiveDeps: true },
// Tileset palette (TilesetAssetLoader). Fs-read as JSON at runtime — so it
@@ -114,6 +118,7 @@ const MIME_MAP: Record<string, string> = {
esmaterial: 'application/json',
esshader: 'text/plain',
esprefab: 'application/json',
+ esmesh: 'application/octet-stream',
esanim: 'application/json',
estimeline: 'application/json',
estileset: 'application/json',
diff --git a/tools/assetMetaTable.js b/tools/assetMetaTable.js
index e17d173ab..09d896027 100644
--- a/tools/assetMetaTable.js
+++ b/tools/assetMetaTable.js
@@ -61,10 +61,11 @@ export const EXT_TO_TYPE = Object.freeze({
// only be made by the Content Browser's own button) and a graph written by
// any other hand is never adopted by the scan, which types orphans by name.
'.esmatgraph': 'materialgraph',
- // Import-only sources: `estella import-gltf` writes .esmesh products beside
- // them, and those are what a scene references.
- '.gltf': 'mesh',
- '.glb': 'mesh',
+ // Import-only sources: importing one writes .esmesh (+ images + a prefab)
+ // beside it, and THOSE are what a scene references. Typed apart from the
+ // products for that reason — the engine loads no model format.
+ '.gltf': 'model',
+ '.glb': 'model',
'.esmesh': 'mesh',
'.esanim': 'animclip',
'.esanimclip': 'animclip',