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
feat(anim): a constraint is an edit like any other
esengine62f7aab6b627
diff --git a/desktop b/desktopindex 47ff62d88..3acf1b56c 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit 47ff62d881cbed9a8cbbd421676c405856f7a00d+Subproject commit 3acf1b56c1a85cd3cd822cc4c4c54998490cd6f1diff --git a/docs/astro/src/data/apiStability.generated.json b/docs/astro/src/data/apiStability.generated.jsonindex 54ea4d2b6..0db91b948 100644--- a/docs/astro/src/data/apiStability.generated.json+++ b/docs/astro/src/data/apiStability.generated.json@@ -3,10 +3,10 @@"counts": {"public": 114,"beta": 101,- "experimental": 1870,+ "experimental": 1873,"deprecated": 3},- "total": 2085,+ "total": 2088,"subsystems": [{"id": "ecs",diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex 786045e67..2dc9dc34f 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: 114 public · 94 beta · 1709 experimental · 3 deprecated+Symbols: 114 public · 94 beta · 1712 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```@@ -10655,6 +10655,11 @@ TransformData(config: AssetGroupsConfig | null | undefined): string | undefined```+## addAnimatorIK — function @experimental+```+(def: AnimatorControllerDef, kind: AnimatorIKKind): AnimatorControllerDef+```+## addAnimatorLayer — function @experimental```(def: AnimatorControllerDef, name: string): AnimatorControllerDef@@ -13115,6 +13120,11 @@ PrefabsPlugin(compData: SceneComponentData, entityMap: Map<number, Entity>, external?: ReadonlyMap<number, Entity>): void```+## removeAnimatorIK — function @experimental+```+(def: AnimatorControllerDef, index: number): AnimatorControllerDef+```+## removeAnimatorLayer — function @experimental```(def: AnimatorControllerDef, index: number): AnimatorControllerDef@@ -13945,6 +13955,11 @@ UIVisibilityPlugin(id: string): void```+## updateAnimatorIK — function @experimental+```+(def: AnimatorControllerDef, index: number, patch: Partial<AnimatorIK>): AnimatorControllerDef+```+## updateAnimatorLayer — function @experimental```(def: AnimatorControllerDef, index: number, patch: Pick<Partial<AnimatorLayer>, "name" | "weight" | "blend" | "mask">): AnimatorControllerDefdiff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex c8e155c5a..b90e6f1a0 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: 114 public · 99 beta · 1728 experimental · 3 deprecated+Symbols: 114 public · 99 beta · 1731 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```@@ -10848,6 +10848,11 @@ TransformData(config: AssetGroupsConfig | null | undefined): string | undefined```+## addAnimatorIK — function @experimental+```+(def: AnimatorControllerDef, kind: AnimatorIKKind): AnimatorControllerDef+```+## addAnimatorLayer — function @experimental```(def: AnimatorControllerDef, name: string): AnimatorControllerDef@@ -13358,6 +13363,11 @@ PrefabsPlugin(compData: SceneComponentData, entityMap: Map<number, Entity>, external?: ReadonlyMap<number, Entity>): void```+## removeAnimatorIK — function @experimental+```+(def: AnimatorControllerDef, index: number): AnimatorControllerDef+```+## removeAnimatorLayer — function @experimental```(def: AnimatorControllerDef, index: number): AnimatorControllerDef@@ -14188,6 +14198,11 @@ UIVisibilityPlugin(id: string): void```+## updateAnimatorIK — function @experimental+```+(def: AnimatorControllerDef, index: number, patch: Partial<AnimatorIK>): AnimatorControllerDef+```+## updateAnimatorLayer — function @experimental```(def: AnimatorControllerDef, index: number, patch: Pick<Partial<AnimatorLayer>, "name" | "weight" | "blend" | "mask">): AnimatorControllerDefdiff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex f0646996d..aa01a50cb 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: 114 public · 96 beta · 1708 experimental · 3 deprecated+Symbols: 114 public · 96 beta · 1711 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -10650,6 +10650,11 @@ TransformData(config: AssetGroupsConfig | null | undefined): string | undefined```+## addAnimatorIK — function @experimental+```+(def: AnimatorControllerDef, kind: AnimatorIKKind): AnimatorControllerDef+```+## addAnimatorLayer — function @experimental```(def: AnimatorControllerDef, name: string): AnimatorControllerDef@@ -13120,6 +13125,11 @@ PrefabsPlugin(compData: SceneComponentData, entityMap: Map<number, Entity>, external?: ReadonlyMap<number, Entity>): void```+## removeAnimatorIK — function @experimental+```+(def: AnimatorControllerDef, index: number): AnimatorControllerDef+```+## removeAnimatorLayer — function @experimental```(def: AnimatorControllerDef, index: number): AnimatorControllerDef@@ -13950,6 +13960,11 @@ UIVisibilityPlugin(id: string): void```+## updateAnimatorIK — function @experimental+```+(def: AnimatorControllerDef, index: number, patch: Partial<AnimatorIK>): AnimatorControllerDef+```+## updateAnimatorLayer — function @experimental```(def: AnimatorControllerDef, index: number, patch: Pick<Partial<AnimatorLayer>, "name" | "weight" | "blend" | "mask">): AnimatorControllerDefdiff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex 19db19dc0..57f54069c 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: 114 public · 94 beta · 1730 experimental · 3 deprecated+Symbols: 114 public · 94 beta · 1733 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -10904,6 +10904,11 @@ TransformData(config: AssetGroupsConfig | null | undefined): string | undefined```+## addAnimatorIK — function @experimental+```+(def: AnimatorControllerDef, kind: AnimatorIKKind): AnimatorControllerDef+```+## addAnimatorLayer — function @experimental```(def: AnimatorControllerDef, name: string): AnimatorControllerDef@@ -13379,6 +13384,11 @@ PrefabsPlugin(compData: SceneComponentData, entityMap: Map<number, Entity>, external?: ReadonlyMap<number, Entity>): void```+## removeAnimatorIK — function @experimental+```+(def: AnimatorControllerDef, index: number): AnimatorControllerDef+```+## removeAnimatorLayer — function @experimental```(def: AnimatorControllerDef, index: number): AnimatorControllerDef@@ -14209,6 +14219,11 @@ UIVisibilityPlugin(id: string): void```+## updateAnimatorIK — function @experimental+```+(def: AnimatorControllerDef, index: number, patch: Partial<AnimatorIK>): AnimatorControllerDef+```+## updateAnimatorLayer — function @experimental```(def: AnimatorControllerDef, index: number, patch: Pick<Partial<AnimatorLayer>, "name" | "weight" | "blend" | "mask">): AnimatorControllerDefdiff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex 094c0afad..8e4909365 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: 114 public · 94 beta · 1720 experimental · 3 deprecated+Symbols: 114 public · 94 beta · 1723 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -10678,6 +10678,11 @@ TransformData(config: AssetGroupsConfig | null | undefined): string | undefined```+## addAnimatorIK — function @experimental+```+(def: AnimatorControllerDef, kind: AnimatorIKKind): AnimatorControllerDef+```+## addAnimatorLayer — function @experimental```(def: AnimatorControllerDef, name: string): AnimatorControllerDef@@ -13143,6 +13148,11 @@ PrefabsPlugin(compData: SceneComponentData, entityMap: Map<number, Entity>, external?: ReadonlyMap<number, Entity>): void```+## removeAnimatorIK — function @experimental+```+(def: AnimatorControllerDef, index: number): AnimatorControllerDef+```+## removeAnimatorLayer — function @experimental```(def: AnimatorControllerDef, index: number): AnimatorControllerDef@@ -13973,6 +13983,11 @@ UIVisibilityPlugin(id: string): void```+## updateAnimatorIK — function @experimental+```+(def: AnimatorControllerDef, index: number, patch: Partial<AnimatorIK>): AnimatorControllerDef+```+## updateAnimatorLayer — function @experimental```(def: AnimatorControllerDef, index: number, patch: Pick<Partial<AnimatorLayer>, "name" | "weight" | "blend" | "mask">): AnimatorControllerDefdiff --git a/sdk/src/animation/animatorGraph.ts b/sdk/src/animation/animatorGraph.tsindex 5d2637a0e..34f61b772 100644--- a/sdk/src/animation/animatorGraph.ts+++ b/sdk/src/animation/animatorGraph.ts@@ -15,6 +15,7 @@import { ANIMATOR_FORMAT_VERSION } from './Animator';import { animatorLayer } from './Animator';+import type { AnimatorIK, AnimatorIKKind } from './animatorIK';import type {AnimatorControllerDef,AnimatorLayer,@@ -261,3 +262,33 @@ export function moveLayer(next.splice(dest, 0, next.splice(from, 1)[0]!);return { ...def, layers: next };}++// — IK constraints —++/** A new constraint, off until an author names what it reaches for: an empty tip+ * resolves to nothing, so it is inert rather than wrong. */+export function addIK(def: AnimatorControllerDef, kind: AnimatorIKKind): AnimatorControllerDef {+ const ik: AnimatorIK = { kind, tip: '', target: '' };+ return { ...def, ik: [...(def.ik ?? []), ik] };+}++export function removeIK(def: AnimatorControllerDef, index: number): AnimatorControllerDef {+ if (!def.ik?.[index]) return def;+ return { ...def, ik: def.ik.filter((_, i) => i !== index) };+}++/**+ * Patch one constraint. Changing `kind` drops the fields the other kind owns —+ * a pole on a look-at and an axis on a two-bone are fields nothing reads, and+ * leaving them makes a file that answers a question it was not asked.+ */+export function updateIK(+ def: AnimatorControllerDef, index: number, patch: Partial<AnimatorIK>,+): AnimatorControllerDef {+ const current = def.ik?.[index];+ if (!current) return def;+ const merged = { ...current, ...patch };+ if (merged.kind === 'look-at') delete merged.pole;+ else delete merged.axis;+ return { ...def, ik: def.ik!.map((x, i) => (i === index ? merged : x)) };+}diff --git a/sdk/src/animation/index.ts b/sdk/src/animation/index.tsindex 113d15aca..07edc48f9 100644--- a/sdk/src/animation/index.ts+++ b/sdk/src/animation/index.ts@@ -101,6 +101,9 @@ export {removeLayer as removeAnimatorLayer,updateLayer as updateAnimatorLayer,moveLayer as moveAnimatorLayer,+ addIK as addAnimatorIK,+ removeIK as removeAnimatorIK,+ updateIK as updateAnimatorIK,addParam as addAnimatorParam,removeParam as removeAnimatorParam,updateParam as updateAnimatorParam,diff --git a/sdk/src/core-content.ts b/sdk/src/core-content.tsindex fd3d716f0..5670a0e5d 100644--- a/sdk/src/core-content.ts+++ b/sdk/src/core-content.ts@@ -504,6 +504,9 @@ export {removeAnimatorLayer,updateAnimatorLayer,moveAnimatorLayer,+ addAnimatorIK,+ removeAnimatorIK,+ updateAnimatorIK,addAnimatorParam,removeAnimatorParam,updateAnimatorParam,diff --git a/sdk/tests/animator-graph.test.ts b/sdk/tests/animator-graph.test.tsindex 0cf6bc184..8ab2ce8c8 100644--- a/sdk/tests/animator-graph.test.ts+++ b/sdk/tests/animator-graph.test.ts@@ -13,6 +13,7 @@ import {addParam, removeParam, updateParam,addLayer as addAnimatorLayer, removeLayer as removeAnimatorLayer,updateLayer as updateAnimatorLayer, moveLayer as moveAnimatorLayer,+ addIK as addAnimatorIK, removeIK as removeAnimatorIK, updateIK as updateAnimatorIK,} from '../src/animation/animatorGraph';import { animatorLayerCount, ANIMATOR_FORMAT_VERSION } from '../src/animation/Animator';import type { AnimatorControllerDef } from '../src/animation/Animator';@@ -173,3 +174,39 @@ describe('editing a controller with layers', () => {expect(def.states.map(s => s.name)).toEqual(['Idle']);});});++describe('editing a controller’s constraints', () => {+ const base = (): AnimatorControllerDef => ({+ version: ANIMATOR_FORMAT_VERSION, parameters: [],+ states: [{ name: 'Idle', transitions: [] }], initialState: 'Idle',+ });++ it('adds one that reaches for nothing until an author says what', () => {+ const def = addAnimatorIK(base(), 'two-bone');+ expect(def.ik).toHaveLength(1);+ expect(def.ik![0]).toEqual({ kind: 'two-bone', tip: '', target: '' });+ });++ it('drops the field the other kind owns when the kind changes', () => {+ // A pole on a look-at is a field nothing reads; leaving it writes a file+ // that answers a question it was not asked.+ let def = addAnimatorIK(base(), 'two-bone');+ def = updateAnimatorIK(def, 0, { tip: 'Hand', target: 'Goal', pole: 'Elbow' });+ expect(def.ik![0]!.pole).toBe('Elbow');++ def = updateAnimatorIK(def, 0, { kind: 'look-at', axis: 'x' });+ expect(def.ik![0]!.pole).toBeUndefined();+ expect(def.ik![0]!.axis).toBe('x');+ expect(def.ik![0]!.tip).toBe('Hand');++ def = updateAnimatorIK(def, 0, { kind: 'two-bone' });+ expect(def.ik![0]!.axis).toBeUndefined();+ });++ it('removes one, and refuses an index it has not got', () => {+ const def = addAnimatorIK(base(), 'look-at');+ expect(removeAnimatorIK(def, 0).ik).toEqual([]);+ expect(removeAnimatorIK(def, 7)).toBe(def);+ expect(updateAnimatorIK(def, 7, { tip: 'x' })).toBe(def);+ });+});