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.

test(animation): the crossfade reaches the pixels, through a real skin

esenginea9239eb64cc1
diff --git a/fixtures/scenes/skinned-fade.esanimator b/fixtures/scenes/skinned-fade.esanimator
new file mode 100644
index 000000000..d89cc238c
--- /dev/null
+++ b/fixtures/scenes/skinned-fade.esanimator
@@ -0,0 +1,42 @@
+{
+ "parameters": [
+ {
+ "name": "bend",
+ "type": "float",
+ "default": 0
+ }
+ ],
+ "initialState": "Flat",
+ "states": [
+ {
+ "name": "Flat",
+ "motion": {
+ "kind": "timeline",
+ "clip": "skinned-fade_Flat.estimeline",
+ "loop": true
+ },
+ "transitions": [
+ {
+ "to": "Bent",
+ "conditions": [
+ {
+ "param": "bend",
+ "op": "gt",
+ "value": 0
+ }
+ ],
+ "duration": 1.0
+ }
+ ]
+ },
+ {
+ "name": "Bent",
+ "motion": {
+ "kind": "timeline",
+ "clip": "skinned-fade_Bent.estimeline",
+ "loop": true
+ },
+ "transitions": []
+ }
+ ]
+}
\ No newline at end of file
diff --git a/fixtures/scenes/skinned-fade.esmesh b/fixtures/scenes/skinned-fade.esmesh
new file mode 100644
index 000000000..31f790bdf
Binary files /dev/null and b/fixtures/scenes/skinned-fade.esmesh differ
diff --git a/fixtures/scenes/skinned-fade.esmesh.meta b/fixtures/scenes/skinned-fade.esmesh.meta
new file mode 100644
index 000000000..90653d470
--- /dev/null
+++ b/fixtures/scenes/skinned-fade.esmesh.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "e4adc279-27d8-4383-8b4d-c3b009b67a31",
+ "version": "2.0",
+ "type": "mesh",
+ "importer": {}
+}
diff --git a/fixtures/scenes/skinned-fade.esprefab b/fixtures/scenes/skinned-fade.esprefab
new file mode 100644
index 000000000..d344015d9
--- /dev/null
+++ b/fixtures/scenes/skinned-fade.esprefab
@@ -0,0 +1,92 @@
+{
+ "version": "2",
+ "name": "skinned-fade",
+ "rootEntityId": "n0",
+ "entities": [
+ {
+ "prefabEntityId": "n0",
+ "name": "Rig",
+ "parent": null,
+ "children": [
+ "n1",
+ "n2",
+ "n3"
+ ],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "TimelinePlayer",
+ "data": {
+ "timeline": "skinned-fade_Flat.estimeline",
+ "playing": false
+ }
+ }
+ ]
+ },
+ {
+ "prefabEntityId": "n1",
+ "name": "Bone0",
+ "parent": "n0",
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ }
+ ]
+ },
+ {
+ "prefabEntityId": "n2",
+ "name": "Bone1",
+ "parent": "n0",
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 60,
+ "y": 0,
+ "z": 0
+ }
+ }
+ }
+ ]
+ },
+ {
+ "prefabEntityId": "n3",
+ "name": "Body",
+ "parent": "n0",
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "skinned-fade.esmesh",
+ "enabled": true
+ }
+ },
+ {
+ "type": "MeshSkin",
+ "data": {
+ "joints": [
+ "n1",
+ "n2"
+ ]
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/fixtures/scenes/skinned-fade.esprefab.meta b/fixtures/scenes/skinned-fade.esprefab.meta
new file mode 100644
index 000000000..8f0ee691c
--- /dev/null
+++ b/fixtures/scenes/skinned-fade.esprefab.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "ab33f63a-bd29-40e1-9d63-35527f9ee0c7",
+ "version": "2.0",
+ "type": "prefab",
+ "importer": {}
+}
diff --git a/fixtures/scenes/skinned-fade.esscene b/fixtures/scenes/skinned-fade.esscene
new file mode 100644
index 000000000..1eefa560e
--- /dev/null
+++ b/fixtures/scenes/skinned-fade.esscene
@@ -0,0 +1,144 @@
+{
+ "version": 4,
+ "name": "SkinnedFade",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 60,
+ "y": 20,
+ "z": 10
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 1,
+ "orthoSize": 100,
+ "isActive": true,
+ "priority": 0
+ }
+ }
+ ]
+ },
+ {
+ "id": 1,
+ "name": "Rig",
+ "parent": null,
+ "children": [
+ 2,
+ 3,
+ 4
+ ],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0.0,
+ "y": 0.0,
+ "z": 0.0
+ }
+ }
+ },
+ {
+ "type": "Animator",
+ "data": {
+ "controller": "scenes/skinned-fade.esanimator",
+ "currentState": "",
+ "enabled": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 2,
+ "name": "Bone0",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0.0,
+ "y": 0.0,
+ "z": 0.0
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 3,
+ "name": "Bone1",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 60,
+ "y": 0,
+ "z": 0
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 4,
+ "name": "Body",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0.0,
+ "y": 0.0,
+ "z": 0.0
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "scenes/skinned-fade.esmesh",
+ "color": {
+ "r": 0,
+ "g": 1,
+ "b": 0,
+ "a": 1
+ },
+ "enabled": true
+ }
+ },
+ {
+ "type": "MeshSkin",
+ "data": {
+ "joints": [
+ 2,
+ 3
+ ]
+ }
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/fixtures/scenes/skinned-fade.gltf b/fixtures/scenes/skinned-fade.gltf
new file mode 100644
index 000000000..ea98f8bdf
--- /dev/null
+++ b/fixtures/scenes/skinned-fade.gltf
@@ -0,0 +1,223 @@
+{
+ "asset": {
+ "version": "2.0",
+ "generator": "estella crossfade fixture"
+ },
+ "buffers": [
+ {
+ "byteLength": 370,
+ "uri": "data:application/octet-stream;base64,AAAAAAAAoMEAAAAAAAAAAAAAoEEAAAAAAABwQgAAoMEAAAAAAABwQgAAoEEAAAAAAADwQgAAoMEAAAAAAADwQgAAoEEAAAAAAAACAAEAAQACAAMAAgAEAAMAAwAEAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAAAAAAAAgD8AAAAAAABwwgAAAAAAAAAAAACAPw=="
+ },
+ {
+ "byteLength": 72,
+ "uri": "data:application/octet-stream;base64,AAAAAAAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAAAAAAA8wQ1P/MENT8AAAAAAAAAAPMENT/zBDU/"
+ }
+ ],
+ "bufferViews": [
+ {
+ "buffer": 0,
+ "byteOffset": 0,
+ "byteLength": 72
+ },
+ {
+ "buffer": 0,
+ "byteOffset": 72,
+ "byteLength": 24
+ },
+ {
+ "buffer": 0,
+ "byteOffset": 98,
+ "byteLength": 48
+ },
+ {
+ "buffer": 0,
+ "byteOffset": 146,
+ "byteLength": 96
+ },
+ {
+ "buffer": 0,
+ "byteOffset": 242,
+ "byteLength": 128
+ },
+ {
+ "buffer": 1,
+ "byteOffset": 0,
+ "byteLength": 8
+ },
+ {
+ "buffer": 1,
+ "byteOffset": 8,
+ "byteLength": 32
+ },
+ {
+ "buffer": 1,
+ "byteOffset": 40,
+ "byteLength": 32
+ }
+ ],
+ "accessors": [
+ {
+ "bufferView": 0,
+ "componentType": 5126,
+ "count": 6,
+ "type": "VEC3",
+ "min": [
+ 0,
+ -20,
+ 0
+ ],
+ "max": [
+ 120,
+ 20,
+ 0
+ ]
+ },
+ {
+ "bufferView": 1,
+ "componentType": 5123,
+ "count": 12,
+ "type": "SCALAR"
+ },
+ {
+ "bufferView": 2,
+ "componentType": 5123,
+ "count": 6,
+ "type": "VEC4"
+ },
+ {
+ "bufferView": 3,
+ "componentType": 5126,
+ "count": 6,
+ "type": "VEC4"
+ },
+ {
+ "bufferView": 4,
+ "componentType": 5126,
+ "count": 2,
+ "type": "MAT4"
+ },
+ {
+ "bufferView": 5,
+ "componentType": 5126,
+ "count": 2,
+ "type": "SCALAR",
+ "min": [
+ 0.0
+ ],
+ "max": [
+ 1.0
+ ]
+ },
+ {
+ "bufferView": 6,
+ "componentType": 5126,
+ "count": 2,
+ "type": "VEC4"
+ },
+ {
+ "bufferView": 7,
+ "componentType": 5126,
+ "count": 2,
+ "type": "VEC4"
+ }
+ ],
+ "meshes": [
+ {
+ "name": "Arm",
+ "primitives": [
+ {
+ "attributes": {
+ "POSITION": 0,
+ "JOINTS_0": 2,
+ "WEIGHTS_0": 3
+ },
+ "indices": 1,
+ "mode": 4
+ }
+ ]
+ }
+ ],
+ "nodes": [
+ {
+ "name": "Rig",
+ "children": [
+ 1,
+ 2,
+ 3
+ ]
+ },
+ {
+ "name": "Bone0"
+ },
+ {
+ "name": "Bone1",
+ "translation": [
+ 60,
+ 0,
+ 0
+ ]
+ },
+ {
+ "name": "Body",
+ "mesh": 0,
+ "skin": 0
+ }
+ ],
+ "scenes": [
+ {
+ "nodes": [
+ 0
+ ]
+ }
+ ],
+ "scene": 0,
+ "skins": [
+ {
+ "joints": [
+ 1,
+ 2
+ ],
+ "inverseBindMatrices": 4
+ }
+ ],
+ "animations": [
+ {
+ "name": "Flat",
+ "samplers": [
+ {
+ "input": 5,
+ "output": 6,
+ "interpolation": "LINEAR"
+ }
+ ],
+ "channels": [
+ {
+ "sampler": 0,
+ "target": {
+ "node": 2,
+ "path": "rotation"
+ }
+ }
+ ]
+ },
+ {
+ "name": "Bent",
+ "samplers": [
+ {
+ "input": 5,
+ "output": 7,
+ "interpolation": "LINEAR"
+ }
+ ],
+ "channels": [
+ {
+ "sampler": 0,
+ "target": {
+ "node": 2,
+ "path": "rotation"
+ }
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/fixtures/scenes/skinned-fade.gltf.meta b/fixtures/scenes/skinned-fade.gltf.meta
new file mode 100644
index 000000000..14ba40008
--- /dev/null
+++ b/fixtures/scenes/skinned-fade.gltf.meta
@@ -0,0 +1,8 @@
+{
+ "uuid": "d63c357f-d90b-47f6-a61e-eb42f460f6eb",
+ "version": "2.0",
+ "type": "model",
+ "importer": {
+ "scale": 1
+ }
+}
diff --git a/fixtures/scenes/skinned-fade.textures.json b/fixtures/scenes/skinned-fade.textures.json
new file mode 100644
index 000000000..0967ef424
--- /dev/null
+++ b/fixtures/scenes/skinned-fade.textures.json
@@ -0,0 +1 @@
+{}
diff --git a/fixtures/scenes/skinned-fade_Bent.estimeline b/fixtures/scenes/skinned-fade_Bent.estimeline
new file mode 100644
index 000000000..8888436fb
--- /dev/null
+++ b/fixtures/scenes/skinned-fade_Bent.estimeline
@@ -0,0 +1,92 @@
+{
+ "version": "1.2",
+ "type": "timeline",
+ "duration": 1,
+ "wrapMode": "once",
+ "tracks": [
+ {
+ "type": "property",
+ "name": "Bone1",
+ "childPath": "Bone1",
+ "component": "Transform",
+ "channels": [
+ {
+ "property": "rotation.x",
+ "keyframes": [
+ {
+ "time": 0,
+ "value": 0,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ },
+ {
+ "time": 1,
+ "value": 0,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ }
+ ]
+ },
+ {
+ "property": "rotation.y",
+ "keyframes": [
+ {
+ "time": 0,
+ "value": 0,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ },
+ {
+ "time": 1,
+ "value": 0,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ }
+ ]
+ },
+ {
+ "property": "rotation.z",
+ "keyframes": [
+ {
+ "time": 0,
+ "value": 0.7071067690849304,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ },
+ {
+ "time": 1,
+ "value": 0.7071067690849304,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ }
+ ]
+ },
+ {
+ "property": "rotation.w",
+ "keyframes": [
+ {
+ "time": 0,
+ "value": 0.7071067690849304,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ },
+ {
+ "time": 1,
+ "value": 0.7071067690849304,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/fixtures/scenes/skinned-fade_Bent.estimeline.meta b/fixtures/scenes/skinned-fade_Bent.estimeline.meta
new file mode 100644
index 000000000..2409e6b80
--- /dev/null
+++ b/fixtures/scenes/skinned-fade_Bent.estimeline.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "8fb5d824-25b2-4dbd-804d-524a47ae7fc8",
+ "version": "2.0",
+ "type": "animation",
+ "importer": {}
+}
diff --git a/fixtures/scenes/skinned-fade_Flat.estimeline b/fixtures/scenes/skinned-fade_Flat.estimeline
new file mode 100644
index 000000000..563dbabb2
--- /dev/null
+++ b/fixtures/scenes/skinned-fade_Flat.estimeline
@@ -0,0 +1,92 @@
+{
+ "version": "1.2",
+ "type": "timeline",
+ "duration": 1,
+ "wrapMode": "once",
+ "tracks": [
+ {
+ "type": "property",
+ "name": "Bone1",
+ "childPath": "Bone1",
+ "component": "Transform",
+ "channels": [
+ {
+ "property": "rotation.x",
+ "keyframes": [
+ {
+ "time": 0,
+ "value": 0,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ },
+ {
+ "time": 1,
+ "value": 0,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ }
+ ]
+ },
+ {
+ "property": "rotation.y",
+ "keyframes": [
+ {
+ "time": 0,
+ "value": 0,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ },
+ {
+ "time": 1,
+ "value": 0,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ }
+ ]
+ },
+ {
+ "property": "rotation.z",
+ "keyframes": [
+ {
+ "time": 0,
+ "value": 0,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ },
+ {
+ "time": 1,
+ "value": 0,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ }
+ ]
+ },
+ {
+ "property": "rotation.w",
+ "keyframes": [
+ {
+ "time": 0,
+ "value": 1,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ },
+ {
+ "time": 1,
+ "value": 1,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/fixtures/scenes/skinned-fade_Flat.estimeline.meta b/fixtures/scenes/skinned-fade_Flat.estimeline.meta
new file mode 100644
index 000000000..108bc0efd
--- /dev/null
+++ b/fixtures/scenes/skinned-fade_Flat.estimeline.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "3db4d297-f7f4-426a-8c0f-cfe86a022120",
+ "version": "2.0",
+ "type": "animation",
+ "importer": {}
+}
diff --git a/sdk/src/asset/loaders/AnimatorControllerAssetLoader.ts b/sdk/src/asset/loaders/AnimatorControllerAssetLoader.ts
index 3dd2358ef..cbd309fba 100644
--- a/sdk/src/asset/loaders/AnimatorControllerAssetLoader.ts
+++ b/sdk/src/asset/loaders/AnimatorControllerAssetLoader.ts
@@ -12,7 +12,33 @@ import type {
AssetLoader, LoadContext, AnimatorControllerResult, RegistryAssetLoader,
} from '../AssetLoader';
import type { RegistryEra } from '../registryAssets';
-import type { AnimatorControllerDef } from '../../animation/Animator';
+import type { AnimatorControllerDef, AnimatorState } from '../../animation/Animator';
+import { isBlend1D, type AnimatorMotion } from '../../animation/motion';
+import { resolveDocumentRef } from '../documentRef';
+
+/**
+ * Motion kinds whose `clip` names an ASSET, and the type it loads as. A sprite
+ * clip and a spine animation are names their own runtime already holds, so they
+ * are absent rather than mapped to nothing.
+ */
+const MOTION_ASSET_TYPES: Readonly<Record<string, string>> = {
+ timeline: 'timeline',
+};
+
+/** Every motion in the graph, descending through blends and sub-machines. */
+function* motionsOf(states: readonly AnimatorState[]): Generator<AnimatorMotion> {
+ for (const state of states) {
+ if (state.motion) yield* flatten(state.motion);
+ if (state.stateMachine) yield* motionsOf(state.stateMachine.states);
+ }
+}
+
+function* flatten(motion: AnimatorMotion): Generator<AnimatorMotion> {
+ yield motion;
+ if (isBlend1D(motion)) {
+ for (const stop of motion.thresholds) yield* flatten(stop.motion);
+ }
+}
export class AnimatorControllerAssetLoader implements AssetLoader<AnimatorControllerResult> {
readonly type = 'animatorcontroller';
@@ -21,10 +47,34 @@ export class AnimatorControllerAssetLoader implements AssetLoader<AnimatorContro
readonly registry: RegistryAssetLoader<AnimatorControllerResult> = {
prepare: async (path: string, ctx: LoadContext): Promise<RegistryEra<AnimatorControllerResult>> => {
const text = await ctx.loadText(ctx.catalog.getBuildPath(path));
+ const def = JSON.parse(text) as AnimatorControllerDef;
+ await acquireMotionAssets(def, path, ctx);
return {
- published: JSON.parse(text) as AnimatorControllerDef,
+ published: def,
value: { controllerId: path },
};
},
};
}
+
+/**
+ * Load what the graph's motions play, resolving each ref IN PLACE. Discovery
+ * walks components, and a clip named inside a controller is not one; resolving
+ * is what makes the driver's lookup hit, since a motion asks for its clip by the
+ * name it carries and that has to be the name it was registered under.
+ */
+async function acquireMotionAssets(
+ def: AnimatorControllerDef, path: string, ctx: LoadContext,
+): Promise<void> {
+ const wanted = new Map<string, string>();
+ for (const motion of motionsOf(def.states)) {
+ if (isBlend1D(motion)) continue;
+ const type = MOTION_ASSET_TYPES[motion.kind];
+ if (!type || !motion.clip) continue;
+ motion.clip = resolveDocumentRef(path, motion.clip);
+ wanted.set(motion.clip, type);
+ }
+ // Leases are recorded against the scope loading this controller, which is
+ // what releases them when the scene that wanted it goes.
+ await Promise.all([...wanted].map(([ref, type]) => ctx.acquireAsset(type, ref)));
+}
diff --git a/tools/render-host/host.ts b/tools/render-host/host.ts
index 65bea96be..c7a9e865e 100644
--- a/tools/render-host/host.ts
+++ b/tools/render-host/host.ts
@@ -23,7 +23,7 @@ import {
finishDeviceRecovery, getContextLossGuardInfo, decodeImagePixels, captureFramePixels,
RenderTexture, Camera, Sprite,
EditorView, EditorGrid, installEditorGrid, editorViewHalfHeight, setEditorViewHalfHeight,
- ProfileRecorder,
+ ProfileRecorder, AnimatorController, Timeline,
} from 'esengine';
import type { App, SceneData, SceneEntityData, PrefabData, RenderSurfaceSource } from 'esengine';
import type { ESEngineModule } from 'esengine/wasm';
@@ -489,6 +489,48 @@ const api = {
app!.world.set(entity, comp, data);
},
+ /**
+ * Writes one animator parameter, the door gameplay uses. Not setField: a
+ * parameter is not a component field, it is per-entity state the controller
+ * keeps, and a crossfade gate has no other way to make a transition fire.
+ */
+ setAnimatorParam(id: number, param: string, value: number | boolean): void {
+ const entity = requireEntity(id);
+ const ctrl = app!.getResource(AnimatorController);
+ if (typeof value === 'boolean') ctrl.setBool(entity, param, value);
+ else ctrl.setFloat(entity, param, value);
+ },
+
+ /**
+ * What the animator on this entity actually resolved to. A crossfade gate
+ * that only reads pixels cannot tell "the graph did not move" from "the
+ * controller never loaded", and those want different fixes.
+ */
+ animatorReport(id: number): {
+ controller: string; state: string; controllerLoaded: boolean;
+ timelineDriver: boolean; clips: Record<string, boolean>;
+ } {
+ const entity = requireEntity(id);
+ const def = getComponent('Animator');
+ if (!def) throw new Error('animatorReport: this build has no Animator component');
+ const data = app!.world.get(entity, def) as { controller: string; currentState: string };
+ const ctrl = app!.getResource(AnimatorController);
+ const graph = ctrl.getController(data.controller);
+ const timeline = app!.getResource(Timeline);
+ const clips: Record<string, boolean> = {};
+ for (const state of graph?.states ?? []) {
+ const clip = (state.motion as { clip?: string } | undefined)?.clip;
+ if (clip) clips[clip] = !!timeline.getAsset(clip);
+ }
+ return {
+ controller: data.controller,
+ state: data.currentState,
+ controllerLoaded: !!graph,
+ timelineDriver: ctrl.hasMotionDriver('timeline'),
+ clips,
+ };
+ },
+
getEntity(id: number): { id: number; name: string; components: string[] } | null {
const node = sceneRaw?.entities?.find((e) => e.id === id);
if (!node) return null;
diff --git a/tools/render-host/run.mjs b/tools/render-host/run.mjs
index e7c6bf1a8..5a23d8d4a 100644
--- a/tools/render-host/run.mjs
+++ b/tools/render-host/run.mjs
@@ -24,6 +24,7 @@
* scale the finished image (1 = design, 2 = integer)
* ESTELLA_VERIFY_PREFAB .esprefab instantiated into the scene after load
* ESTELLA_VERIFY_SET_FIELD one inspector field written after load (JSON)
+ * ESTELLA_VERIFY_ANIMATOR drive an animator to a point in time (JSON)
* ESTELLA_VERIFY_PICK hit-test a viewport point, asserting the entity (JSON)
* ESTELLA_VERIFY_ORBIT turn the editor eye before capture ("yaw,pitch" degrees)
* ESTELLA_VERIFY_COUNTERS engine counters the drawn frame must report (JSON)
@@ -208,6 +209,7 @@ app.whenReady().then(async () => {
let meshMaterial = null;
let meshPrefab = null;
let setField = null;
+ let animator = null;
let pick = null;
await exec('window.__estellaHeadless.ready');
// ESTELLA_VERIFY_SCALE = {"copies":N,"cols":C,"spacing":[x,y]}: the fixture holds ONE
@@ -337,6 +339,25 @@ app.whenReady().then(async () => {
})()`);
}
+ // ESTELLA_VERIFY_ANIMATOR={"entity","param","value","warmup","frames"}: settle,
+ // write one animator parameter, advance a FIXED number of frames. A crossfade
+ // is a stretch of time, so a gate wanting a point inside one must stop at it.
+ if (process.env.ESTELLA_VERIFY_ANIMATOR) {
+ const spec = JSON.parse(process.env.ESTELLA_VERIFY_ANIMATOR);
+ animator = await exec(`(async () => {
+ const api = window.__estellaHeadless.api;
+ api.setRunMode(true);
+ await api.step(${Number(spec.warmup ?? 2)}, 1 / 60);
+ api.setAnimatorParam(${JSON.stringify(spec.entity)},
+ ${JSON.stringify(spec.param)}, ${JSON.stringify(spec.value)});
+ const before = api.animatorReport(${JSON.stringify(spec.entity)});
+ await api.step(${Number(spec.frames ?? 1)}, 1 / 60);
+ const after = api.animatorReport(${JSON.stringify(spec.entity)});
+ return { param: ${JSON.stringify(spec.param)}, frames: ${Number(spec.frames ?? 1)},
+ before, after };
+ })()`);
+ }
+
// ESTELLA_VERIFY_SET_FIELD={"entity","component","key","value"} writes one
// inspector field the way the editor's own door does, then waits: an asset
// assigned after load is COLD, and reaching the World is an async load away.
@@ -741,7 +762,7 @@ app.whenReady().then(async () => {
};
`);
}
- finish({ ok: true, entityCount, drawCalls, draws, counters, profile, capture, expect, seam, resize, preview, meshPreview, grid, deviceLoss, meshResident, meshAsset, meshMaterial, meshPrefab, setField, pick, cameraTarget }, server);
+ finish({ ok: true, entityCount, drawCalls, draws, counters, profile, capture, expect, seam, resize, preview, meshPreview, grid, deviceLoss, meshResident, meshAsset, meshMaterial, meshPrefab, setField, animator, pick, cameraTarget }, server);
} catch (e) {
finish({ ok: false, error: String((e && e.stack) || e) }, server);
}
diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjs
index c8883089b..b1a9b7a7e 100644
--- a/tools/renderScenes.mjs
+++ b/tools/renderScenes.mjs
@@ -83,6 +83,9 @@ export const SCENES = [
// A two-bone arm. Bone 1 binds at x=60 and the scene puts it 60 higher, so
// the half bound to it rises by exactly that and the half bound to bone 0 does
// not: the elbow is where the geometry says, not where a whole-mesh move puts it.
+ { id: "skin-fade-start", tier: "pr", env: {"ESTELLA_VERIFY_SCENE": "/scenes/skinned-fade.esscene", "ESTELLA_VERIFY_MANIFEST": "/scenes/skinned-fade.textures.json", "ESTELLA_VERIFY_W": "256", "ESTELLA_VERIFY_H": "256", "ESTELLA_VERIFY_ANIMATOR": "{\"entity\": 1, \"param\": \"bend\", \"value\": 1, \"warmup\": 2, \"frames\": 1}", "ESTELLA_VERIFY_EXPECT": "[{\"x\": 0.3, \"y\": 0.6, \"rgb\": [0, 255, 0], \"tol\": 40}, {\"x\": 0.75, \"y\": 0.6, \"rgb\": [0, 255, 0], \"tol\": 40}, {\"x\": 0.75, \"y\": 0.45, \"rgb\": [0, 0, 0], \"tol\": 25}, {\"x\": 0.45, \"y\": 0.3, \"rgb\": [0, 0, 0], \"tol\": 25}]"} },
+ { id: "skin-fade-mid", tier: "pr", env: {"ESTELLA_VERIFY_SCENE": "/scenes/skinned-fade.esscene", "ESTELLA_VERIFY_MANIFEST": "/scenes/skinned-fade.textures.json", "ESTELLA_VERIFY_W": "256", "ESTELLA_VERIFY_H": "256", "ESTELLA_VERIFY_ANIMATOR": "{\"entity\": 1, \"param\": \"bend\", \"value\": 1, \"warmup\": 2, \"frames\": 31}", "ESTELLA_VERIFY_EXPECT": "[{\"x\": 0.3, \"y\": 0.6, \"rgb\": [0, 255, 0], \"tol\": 40}, {\"x\": 0.75, \"y\": 0.6, \"rgb\": [0, 0, 0], \"tol\": 25}, {\"x\": 0.75, \"y\": 0.45, \"rgb\": [0, 255, 0], \"tol\": 40}, {\"x\": 0.45, \"y\": 0.3, \"rgb\": [0, 0, 0], \"tol\": 25}]"} },
+ { id: "skin-fade-end", tier: "pr", env: {"ESTELLA_VERIFY_SCENE": "/scenes/skinned-fade.esscene", "ESTELLA_VERIFY_MANIFEST": "/scenes/skinned-fade.textures.json", "ESTELLA_VERIFY_W": "256", "ESTELLA_VERIFY_H": "256", "ESTELLA_VERIFY_ANIMATOR": "{\"entity\": 1, \"param\": \"bend\", \"value\": 1, \"warmup\": 2, \"frames\": 90}", "ESTELLA_VERIFY_EXPECT": "[{\"x\": 0.3, \"y\": 0.6, \"rgb\": [0, 255, 0], \"tol\": 40}, {\"x\": 0.75, \"y\": 0.6, \"rgb\": [0, 0, 0], \"tol\": 25}, {\"x\": 0.75, \"y\": 0.45, \"rgb\": [0, 0, 0], \"tol\": 25}, {\"x\": 0.45, \"y\": 0.3, \"rgb\": [0, 255, 0], \"tol\": 40}]"} },
{ id: "mesh-skin", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mesh-skin.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.35,\"y\":0.6,\"rgb\":[0,255,0],\"tol\":30},{\"x\":0.75,\"y\":0.35,\"rgb\":[0,255,0],\"tol\":30},{\"x\":0.75,\"y\":0.60,\"rgb\":[0,0,0],\"tol\":20}]" } },
// The same arm, drawn by a MATERIAL — a program is compiled per vertex source
// and there was no skinned one, so a skinned mesh fell back to the engine's