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.

refactor(sdk): the material format version gets a name, like its siblings have

yhh9a3d7a0cdaa1
diff --git a/desktop/src/material/shaderCatalog.ts b/desktop/src/material/shaderCatalog.ts
index 4ed863206..9e7cfb88d 100644
--- a/desktop/src/material/shaderCatalog.ts
+++ b/desktop/src/material/shaderCatalog.ts
@@ -11,7 +11,7 @@
* Reflection is the SAME call the inspector makes, so there is no second list.
*/
import {
- BUILTIN_SHADER_TEMPLATES, builtinShaderTemplate, reflectEsshader,
+ BUILTIN_SHADER_TEMPLATES, builtinShaderTemplate, reflectEsshader, MATERIAL_FORMAT_VERSION,
type MaterialAssetData, type ShaderParam,
} from 'esengine';
import { BUILTIN_SHADER_PREFIX } from './materialInspectorModel';
@@ -26,7 +26,7 @@ export function newMaterialDocument(templateId: string): MaterialAssetData | nul
const template = builtinShaderTemplate(templateId);
if (!template) return null;
return {
- version: '1.0',
+ version: MATERIAL_FORMAT_VERSION,
type: 'material',
shader: `${BUILTIN_SHADER_PREFIX}${templateId}`,
blendMode: 0,
diff --git a/docs/astro/src/data/apiStability.generated.json b/docs/astro/src/data/apiStability.generated.json
index db731b298..1081ef42e 100644
--- a/docs/astro/src/data/apiStability.generated.json
+++ b/docs/astro/src/data/apiStability.generated.json
@@ -3,10 +3,10 @@
"counts": {
"public": 112,
"beta": 60,
- "experimental": 1485,
+ "experimental": 1486,
"deprecated": 3
},
- "total": 1657,
+ "total": 1658,
"subsystems": [
{
"id": "ecs",
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index cf84ddfe4..0b5c6410b 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/index
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 112 public · 53 beta · 1370 experimental · 3 deprecated
+Symbols: 112 public · 53 beta · 1371 experimental · 3 deprecated
## ABI_LAYOUT_HASH — const @experimental
```
@@ -4028,6 +4028,11 @@ code: string
(typeof LoopMode)[keyof typeof LoopMode]
```
+## MATERIAL_FORMAT_VERSION — const @experimental
+```
+"1.0"
+```
+
## ManifestModel — class @experimental
```
allAssets: () => AddressableManifestAsset[]
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index 3e49d1030..85098ec17 100644
--- a/sdk/etc/index.native.api.md
+++ b/sdk/etc/index.native.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/index.native
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 112 public · 58 beta · 1389 experimental · 3 deprecated
+Symbols: 112 public · 58 beta · 1390 experimental · 3 deprecated
## ABI_LAYOUT_HASH — const @experimental
```
@@ -4036,6 +4036,11 @@ code: string
(typeof LoopMode)[keyof typeof LoopMode]
```
+## MATERIAL_FORMAT_VERSION — const @experimental
+```
+"1.0"
+```
+
## ManifestModel — class @experimental
```
allAssets: () => AddressableManifestAsset[]
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index 5b3b45c9c..1d1085616 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/index.node
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 112 public · 55 beta · 1369 experimental · 3 deprecated
+Symbols: 112 public · 55 beta · 1370 experimental · 3 deprecated
## ANCHOR_AXES — const @experimental
```
@@ -4023,6 +4023,11 @@ code: string
(typeof LoopMode)[keyof typeof LoopMode]
```
+## MATERIAL_FORMAT_VERSION — const @experimental
+```
+"1.0"
+```
+
## ManifestModel — class @experimental
```
allAssets: () => AddressableManifestAsset[]
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index f8b2e4cce..cbb5acb1b 100644
--- a/sdk/etc/minigame.api.md
+++ b/sdk/etc/minigame.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/minigame
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 112 public · 53 beta · 1390 experimental · 3 deprecated
+Symbols: 112 public · 53 beta · 1391 experimental · 3 deprecated
## ANCHOR_AXES — const @experimental
```
@@ -4023,6 +4023,11 @@ code: string
(typeof LoopMode)[keyof typeof LoopMode]
```
+## MATERIAL_FORMAT_VERSION — const @experimental
+```
+"1.0"
+```
+
## ManifestModel — class @experimental
```
allAssets: () => AddressableManifestAsset[]
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index 96278c8ea..11b4fe874 100644
--- a/sdk/etc/wechat.api.md
+++ b/sdk/etc/wechat.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/wechat
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 112 public · 53 beta · 1380 experimental · 3 deprecated
+Symbols: 112 public · 53 beta · 1381 experimental · 3 deprecated
## ANCHOR_AXES — const @experimental
```
@@ -4030,6 +4030,11 @@ code: string
(typeof LoopMode)[keyof typeof LoopMode]
```
+## MATERIAL_FORMAT_VERSION — const @experimental
+```
+"1.0"
+```
+
## ManifestModel — class @experimental
```
allAssets: () => AddressableManifestAsset[]
diff --git a/sdk/src/core-render.ts b/sdk/src/core-render.ts
index 5dd3869f8..d19a22425 100644
--- a/sdk/src/core-render.ts
+++ b/sdk/src/core-render.ts
@@ -78,6 +78,7 @@ export {
shutdownMaterialAPI,
isTextureRef,
CullMode,
+ MATERIAL_FORMAT_VERSION,
type ShaderHandle,
type MaterialHandle,
type MaterialOptions,
diff --git a/sdk/src/render/material.ts b/sdk/src/render/material.ts
index f41e2b94a..b143d2677 100644
--- a/sdk/src/render/material.ts
+++ b/sdk/src/render/material.ts
@@ -89,6 +89,10 @@ export interface MaterialOptions {
switches?: Record<string, boolean>;
}
+/** The `version` a `.esmaterial` this build writes carries, named the way its
+ * sibling formats name theirs. */
+export const MATERIAL_FORMAT_VERSION = '1.0';
+
export interface MaterialAssetData {
version: string;
type: 'material';
@@ -672,7 +676,7 @@ export const Material = {
if (isInstance) {
const asset: MaterialAssetData = {
- version: '1.0', type: 'material', shader: shaderPath, instanceOf: parentPath, properties,
+ version: MATERIAL_FORMAT_VERSION, type: 'material', shader: shaderPath, instanceOf: parentPath, properties,
};
if (data.overrides.has('blendMode')) asset.blendMode = data.blendMode;
if (data.overrides.has('depthTest')) asset.depthTest = data.depthTest;
@@ -682,7 +686,7 @@ export const Material = {
}
const asset: MaterialAssetData = {
- version: '1.0',
+ version: MATERIAL_FORMAT_VERSION,
type: 'material',
shader: shaderPath,
blendMode: data.blendMode,