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(anim): a clip can say what shape a mesh is in

esengine19ba5d64aab1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 924d04a21..1d57ebaec 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,9 +26,13 @@ published separately; it ships inside the editor.
The weights are a **budget on what is live**, not on what a mesh carries: the
eight heaviest are blended and the rest read as zero, which is what an
- untouched weight already means. Three pixel gates hold it — the same quad, the
+ untouched weight already means. Four pixel gates hold it — the same quad, the
same two points, and the weight the only thing that differs.
+ A `weights` animation channel comes with the model too: it becomes a track per
+ primitive that node draws, one channel per target, and the clip that raises the
+ example robot's banner now furls it as it rises.
+
- **A controller is a stack of machines, not one.** One state machine can say a
character is running or that it is waving, never both. A `.esanimator` now
carries layers over its base one — each a machine with its own clock, its own
diff --git a/examples/model-import/assets/models/robot.esprefab b/examples/model-import/assets/models/robot.esprefab
index 22dee6f78..ef6a02879 100644
--- a/examples/model-import/assets/models/robot.esprefab
+++ b/examples/model-import/assets/models/robot.esprefab
@@ -105,7 +105,7 @@
"type": "MeshMorph",
"data": {
"weights": [
- 0.6
+ 0
]
}
}
diff --git a/examples/model-import/assets/models/robot.gltf b/examples/model-import/assets/models/robot.gltf
index 9415624a3..436a22fa1 100644
--- a/examples/model-import/assets/models/robot.gltf
+++ b/examples/model-import/assets/models/robot.gltf
@@ -5,8 +5,8 @@
},
"buffers": [
{
- "byteLength": 360,
- "uri": "data:application/octet-stream;base64,AADwwgAAcEIAAAAAAADwQgAAcEIAAAAAAADwwgAAcMIAAAAAAADwQgAAcMIAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AACAPwAAgD8AAAIAAQABAAIAAwAAAHDCAACgQQAAAAAAAHBCAACgQQAAAAAAAHDCAACgwQAAAAAAAHBCAACgwQAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAIA/AACAPwAAAgABAAEAAgADAAAAAAAAAIA+AAAAAAAA3EIAAAAAAAAAAAAAIEMAAAAAAAAAAAAAAAAAAAAAAABwwgAAwEAAAAAAAAAAAAAAAAAAAAAAAABwwgAAwMAAAAAA"
+ "byteLength": 368,
+ "uri": "data:application/octet-stream;base64,AADwwgAAcEIAAAAAAADwQgAAcEIAAAAAAADwwgAAcMIAAAAAAADwQgAAcMIAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AACAPwAAgD8AAAIAAQABAAIAAwAAAHDCAACgQQAAAAAAAHBCAACgQQAAAAAAAHDCAACgwQAAAAAAAHBCAACgwQAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAIA/AACAPwAAAgABAAEAAgADAAAAAAAAAIA+AAAAAAAA3EIAAAAAAAAAAAAAIEMAAAAAAAAAAAAAAAAAAAAAAABwwgAAwEAAAAAAAAAAAAAAAAAAAAAAAABwwgAAwMAAAAAAAAAAAAAAgD8="
}
],
"bufferViews": [
@@ -64,6 +64,11 @@
"buffer": 0,
"byteOffset": 312,
"byteLength": 48
+ },
+ {
+ "buffer": 0,
+ "byteOffset": 360,
+ "byteLength": 8
}
],
"accessors": [
@@ -168,6 +173,18 @@
6.0,
0.0
]
+ },
+ {
+ "bufferView": 11,
+ "componentType": 5126,
+ "count": 2,
+ "type": "SCALAR",
+ "min": [
+ 0.0
+ ],
+ "max": [
+ 1.0
+ ]
}
],
"images": [
@@ -298,7 +315,7 @@
1
],
"weights": [
- 0.6
+ 0.0
]
}
],
@@ -320,6 +337,13 @@
"node": 2,
"path": "translation"
}
+ },
+ {
+ "sampler": 1,
+ "target": {
+ "node": 2,
+ "path": "weights"
+ }
}
],
"samplers": [
@@ -327,6 +351,11 @@
"input": 8,
"output": 9,
"interpolation": "LINEAR"
+ },
+ {
+ "input": 8,
+ "output": 11,
+ "interpolation": "LINEAR"
}
]
}
diff --git a/examples/model-import/assets/models/robot_Raise.estimeline b/examples/model-import/assets/models/robot_Raise.estimeline
index 7bde2913a..347566a93 100644
--- a/examples/model-import/assets/models/robot_Raise.estimeline
+++ b/examples/model-import/assets/models/robot_Raise.estimeline
@@ -68,6 +68,33 @@
]
}
]
+ },
+ {
+ "type": "property",
+ "name": "Banner",
+ "childPath": "Banner",
+ "component": "MeshMorph",
+ "channels": [
+ {
+ "property": "weights.0",
+ "keyframes": [
+ {
+ "time": 0,
+ "value": 0,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ },
+ {
+ "time": 0.25,
+ "value": 1,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ }
+ ]
+ }
+ ]
}
]
}
diff --git a/fixtures/scenes/mesh-morph-anim.esscene b/fixtures/scenes/mesh-morph-anim.esscene
new file mode 100644
index 000000000..2b1f7bc2e
--- /dev/null
+++ b/fixtures/scenes/mesh-morph-anim.esscene
@@ -0,0 +1,83 @@
+{
+ "version": 4,
+ "name": "MeshMorphAnimated",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 10
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 1,
+ "orthoSize": 100,
+ "isActive": true,
+ "priority": 0
+ }
+ }
+ ]
+ },
+ {
+ "id": 1,
+ "name": "Quad",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "scenes/morph-quad.esmesh",
+ "color": {
+ "r": 0,
+ "g": 1,
+ "b": 0,
+ "a": 1
+ },
+ "enabled": true
+ }
+ },
+ {
+ "type": "MeshMorph",
+ "data": {
+ "weights": [
+ 0
+ ]
+ }
+ },
+ {
+ "type": "TimelinePlayer",
+ "data": {
+ "timeline": "scenes/morph-quad_Furl.estimeline",
+ "playing": true,
+ "speed": 1,
+ "wrapMode": "once"
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/fixtures/scenes/morph-quad_Furl.estimeline b/fixtures/scenes/morph-quad_Furl.estimeline
new file mode 100644
index 000000000..da4108800
--- /dev/null
+++ b/fixtures/scenes/morph-quad_Furl.estimeline
@@ -0,0 +1,35 @@
+{
+ "version": "1.2",
+ "type": "timeline",
+ "duration": 0.5,
+ "wrapMode": "once",
+ "tracks": [
+ {
+ "type": "property",
+ "name": "Quad",
+ "childPath": "",
+ "component": "MeshMorph",
+ "channels": [
+ {
+ "property": "weights.0",
+ "keyframes": [
+ {
+ "time": 0,
+ "value": 0,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ },
+ {
+ "time": 0.5,
+ "value": 1,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/pipeline/src/assets/fbxImport.ts b/pipeline/src/assets/fbxImport.ts
index 05c816851..0b0ae051c 100644
--- a/pipeline/src/assets/fbxImport.ts
+++ b/pipeline/src/assets/fbxImport.ts
@@ -543,7 +543,8 @@ function buildAnimations(scene: FbxScene, payload: Uint8Array, nodes: ImportedNo
const path = paths.get(target.node);
if (path === undefined) continue;
const entry = byNode.get(path)
- ?? { node: nodeNameFor(nodes, target.node), channels: new Map() };
+ ?? { node: nodeNameFor(nodes, target.node), childPath: path,
+ component: 'Transform', channels: new Map() };
for (const property of ['translation', 'rotation', 'scale'] as const) {
const channel = target[property];
const spec = ANIMATED_PATHS[property]!;
diff --git a/pipeline/src/assets/gltfImport.ts b/pipeline/src/assets/gltfImport.ts
index 8c02e1b05..8a4902188 100644
--- a/pipeline/src/assets/gltfImport.ts
+++ b/pipeline/src/assets/gltfImport.ts
@@ -739,7 +739,48 @@ const INTERPOLATION: Record<string, string> = {
* node, since a track drives one component on one entity and the runtime reads
* and writes that component once per track.
*/
+/**
+ * The shape tracks a `weights` channel becomes: one per primitive that node
+ * draws and carries targets. The entity is the one the prefab put the MeshMorph
+ * on — the node itself where it draws a single mesh, a child named after the
+ * mesh where it draws several.
+ */
+function morphTracks(drawn: ImportedMesh[], path: string, label: string,
+ times: Float32Array, values: Float32Array,
+ interpolation: string): AnimatedNode[] {
+ return drawn.filter((m) => (m.data.morph?.names.length ?? 0) > 0).map((mesh) => {
+ const targets = mesh.data.morph!.names.length;
+ const channels = new Map<string, OutKeyframe[]>();
+ // `weights.<i>` and not the name: the component holds a list, and entry i
+ // is target i — the same positional addressing the weights themselves use.
+ samplerKeyframes(times, values, targets, interpolation)
+ .forEach((keyframes, i) => channels.set(`weights.${i}`, keyframes));
+ return {
+ node: label, component: 'MeshMorph',
+ childPath: drawn.length === 1 ? path : `${path ? `${path}/` : ''}${mesh.name}`,
+ channels,
+ };
+ });
+}
+
+/** What a node draws, as the meshes this import produced for it. */
+function drawnBy(nodes: ImportedNode[], meshes: ImportedMesh[], target: number): ImportedMesh[] {
+ const node = findNode(nodes, target);
+ return (node?.meshes ?? []).map((i) => meshes[i]).filter((m): m is ImportedMesh => !!m);
+}
+
+/** The imported node a source index became, anywhere in the tree. */
+function findNode(nodes: ImportedNode[], index: number): ImportedNode | undefined {
+ for (const node of nodes) {
+ if (node.index === index) return node;
+ const hit = findNode(node.children, index);
+ if (hit) return hit;
+ }
+ return undefined;
+}
+
function readAnimations(json: GltfJson, src: GltfBytes, nodes: ImportedNode[],
+ meshes: ImportedMesh[],
stem: string, warnings: string[]): ImportedAnimation[] {
const animations = json.animations ?? [];
if (animations.length === 0) return [];
@@ -757,31 +798,51 @@ function readAnimations(json: GltfJson, src: GltfBytes, nodes: ImportedNode[],
for (const channel of animation.channels ?? []) {
const target = channel.target?.node;
- const spec = ANIMATED_PATHS[channel.target?.path ?? ''];
+ const kind = channel.target?.path ?? '';
+ const spec = ANIMATED_PATHS[kind];
if (target === undefined || !paths.has(target)) continue;
- if (!spec) {
- warnings.push(`${name}: "${channel.target?.path}" channels are not imported`
- + ' (morph target weights need blend shapes)');
+ if (!spec && kind !== 'weights') {
+ warnings.push(`${name}: "${kind}" channels are not imported`);
continue;
}
const sampler = animation.samplers?.[channel.sampler];
if (!sampler) continue;
+ const path = paths.get(target)!;
+ const label = nodeNameFor(nodes, target);
+ const interpolation = INTERPOLATION[sampler.interpolation ?? 'LINEAR'] ?? 'linear';
+
+ // A weights channel drives the SHAPE of whatever that node draws, and
+ // one node may draw several primitives — each with its own targets and
+ // its own entity. The channel is one statement about all of them.
+ const drawn = spec ? [] : drawnBy(nodes, meshes, target);
+ if (!spec && !drawn.some((m) => (m.data.morph?.names.length ?? 0) > 0)) {
+ warnings.push(`${name}: "${label}" is animated by weights and draws nothing with`
+ + ' morph targets — that channel moves nothing');
+ continue;
+ }
+
const times = readAccessor(src, sampler.input);
const values = readAccessor(src, sampler.output);
if (times.length === 0 || values.length === 0) continue;
+ duration = Math.max(duration, times[times.length - 1] ?? 0);
+
+ if (!spec) {
+ for (const track of morphTracks(drawn, path, label, times, values, interpolation)) {
+ byNode.set(`MeshMorph ${track.childPath}`, track);
+ }
+ continue;
+ }
if (skinned.has(target)) drivesSkin = true;
const comps = spec.channels.length;
- const frames = samplerKeyframes(times, values, comps,
- INTERPOLATION[sampler.interpolation ?? 'LINEAR'] ?? 'linear');
+ const frames = samplerKeyframes(times, values, comps, interpolation);
if (spec.property === 'rotation') alignQuaternionSigns(frames);
- duration = Math.max(duration, times[times.length - 1] ?? 0);
- const path = paths.get(target)!;
- const entry = byNode.get(path)
- ?? { node: nodeNameFor(nodes, target), channels: new Map<string, OutKeyframe[]>() };
+ const entry = byNode.get(`Transform ${path}`)
+ ?? { node: label, childPath: path, component: 'Transform',
+ channels: new Map<string, OutKeyframe[]>() };
spec.channels.forEach((property, c) => entry.channels.set(property, frames[c]!));
- byNode.set(path, entry);
+ byNode.set(`Transform ${path}`, entry);
}
if (byNode.size === 0) {
@@ -1096,6 +1157,6 @@ export async function importGltfMeshes(
const nodes = readNodes(json, meshIndexOf, warnings);
return {
meshes, textures, externalFiles, nodes, warnings,
- animations: readAnimations(json, src, nodes, stem, warnings),
+ animations: readAnimations(json, src, nodes, meshes, stem, warnings),
};
}
\ No newline at end of file
diff --git a/pipeline/src/assets/modelImport.ts b/pipeline/src/assets/modelImport.ts
index cde346ed8..aca9dafb0 100644
--- a/pipeline/src/assets/modelImport.ts
+++ b/pipeline/src/assets/modelImport.ts
@@ -247,13 +247,18 @@ export function samplerKeyframes(times: ArrayLike<number>, values: ArrayLike<num
export interface AnimatedNode {
/** The node's own name — the track's label. */
node: string;
+ /** The entity the track writes, under the prefab root. */
+ childPath: string;
+ /** The component whose fields the channels below name. */
+ component: string;
channels: Map<string, OutKeyframe[]>;
}
/**
* An animation as an `.estimeline` document. Channels are grouped per target
- * node, since a track drives one component on one entity and the runtime reads
- * and writes that component once per track.
+ * entity AND component, since a track drives one component on one entity and the
+ * runtime reads and writes that component once per track — a node whose shape
+ * and placement both move is two tracks.
*
* @param byNode childPath → the node's channels, in the order tracks are written.
*/
@@ -265,8 +270,9 @@ export function timelineDocument(duration: number,
duration,
// Neither format says anything about looping, and the import does not guess.
wrapMode: 'once',
- tracks: [...byNode].map(([childPath, entry]) => ({
- type: 'property', name: entry.node, childPath, component: 'Transform',
+ tracks: [...byNode.values()].map((entry) => ({
+ type: 'property', name: entry.node, childPath: entry.childPath,
+ component: entry.component,
channels: [...entry.channels].map(([property, keyframes]) => ({ property, keyframes })),
})),
};
diff --git a/pipeline/tests/gltf-import.test.ts b/pipeline/tests/gltf-import.test.ts
index 6d45f62ab..944ff2e66 100644
--- a/pipeline/tests/gltf-import.test.ts
+++ b/pipeline/tests/gltf-import.test.ts
@@ -717,13 +717,15 @@ describe('glTF animation import', () => {
expect(result.warnings.some(w => /moves nothing/.test(w))).toBe(true);
});
- it('reports a morph-weight channel rather than dropping it', async () => {
+ it('reports a weights channel aimed at geometry with no shapes', async () => {
const result = await importGltfMeshes(animatedGltf({
times: [0, 1], components: 1, path: 'weights', values: [0, 1],
}), 'robot');
+ // Not dropped in silence, and not a track either: the channel is about a
+ // shape the mesh it draws does not have.
expect(result.animations).toHaveLength(0);
- expect(result.warnings.some(w => /weights/.test(w))).toBe(true);
+ expect(result.warnings.some(w => /draws nothing with morph targets/.test(w))).toBe(true);
});
});
@@ -1034,6 +1036,39 @@ describe('glTF morph targets', () => {
expect(morph.deltas[18 + 2 * 6]).toBe(3);
});
+ it('turns a weights channel into a track per shape, on the entity that holds them', async () => {
+ const doc = JSON.parse(new TextDecoder().decode(morphGltf({ names: ['Smile', 'Blink'] })));
+ // Two keyframes moving the SECOND target only: a reader that mixed the two up
+ // would still find a track, driving the wrong shape.
+ const raw = Buffer.from(doc.buffers[0].uri.split(',')[1], 'base64');
+ const extra = Buffer.from(new Float32Array([0, 1, /* weights */ 0, 0, 0, 1]).buffer);
+ doc.buffers[0].uri = 'data:application/octet-stream;base64,'
+ + Buffer.concat([raw, extra]).toString('base64');
+ doc.buffers[0].byteLength = raw.length + extra.length;
+ doc.bufferViews.push({ buffer: 0, byteOffset: raw.length, byteLength: 8 });
+ doc.bufferViews.push({ buffer: 0, byteOffset: raw.length + 8, byteLength: 16 });
+ doc.accessors.push({ bufferView: doc.bufferViews.length - 2, componentType: 5126, count: 2, type: 'SCALAR' });
+ doc.accessors.push({ bufferView: doc.bufferViews.length - 1, componentType: 5126, count: 4, type: 'SCALAR' });
+ doc.animations = [{
+ name: 'Express',
+ samplers: [{ input: doc.accessors.length - 2, output: doc.accessors.length - 1 }],
+ channels: [{ sampler: 0, target: { node: 0, path: 'weights' } }],
+ }];
+
+ const { animations, warnings } = await importGltfMeshes(
+ new TextEncoder().encode(JSON.stringify(doc)), 'face');
+
+ expect(warnings.join('\n')).not.toMatch(/moves nothing/);
+ const tracks = (animations[0]!.document as { tracks: Record<string, unknown>[] }).tracks;
+ expect(tracks).toHaveLength(1);
+ expect(tracks[0]!.component).toBe('MeshMorph');
+ // One channel per target, addressed the way a weight is — by position.
+ const channels = tracks[0]!.channels as { property: string; keyframes: { value: number }[] }[];
+ expect(channels.map((c) => c.property)).toEqual(['weights.0', 'weights.1']);
+ expect(channels[0]!.keyframes.map((k) => k.value)).toEqual([0, 0]);
+ expect(channels[1]!.keyframes.map((k) => k.value)).toEqual([0, 1]);
+ });
+
it('leaves geometry with no targets without a morph section', async () => {
const { meshes } = await importGltfMeshes(gltf(withInlineImage()), 'model');
expect(meshes[0]!.data.morph).toBeUndefined();
diff --git a/sdk/src/ecs/bridge/BuiltinBridge.ts b/sdk/src/ecs/bridge/BuiltinBridge.ts
index e28edaa16..23c9cad13 100644
--- a/sdk/src/ecs/bridge/BuiltinBridge.ts
+++ b/sdk/src/ecs/bridge/BuiltinBridge.ts
@@ -133,7 +133,7 @@ export function materializeNumberVectors(
* metadata rather than carried on the component definition: that definition is
* a public type, and how a field crosses THIS boundary is not part of it.
*/
-function numberListFieldsOf(cppName: string): readonly string[] {
+export function numberListFieldsOf(cppName: string): readonly string[] {
return (COMPONENT_META[cppName]?.numberListFields ?? []) as readonly string[];
}
@@ -827,18 +827,9 @@ export class BuiltinBridge {
try {
const methods = this.getBuiltinMethods(component._cppName);
isNew = !methods.has(entity);
- const payload = convertForWasm(merged as Record<string, unknown>, component.colorKeys);
- const vectors = materializeEntityVectors(
- payload, component.entityFields ?? [],
- this.module_ as unknown as { VectorEntity?: new () => WasmVector } | null);
- vectors.push(...materializeNumberVectors(
- payload, numberListFieldsOf(component._cppName),
- this.module_ as unknown as { VectorFloat?: new () => WasmVector } | null));
- try {
- methods.add(entity, payload);
- } finally {
- for (const v of vectors) v.delete();
- }
+ this.replace(entity, component._cppName,
+ convertForWasm(merged as Record<string, unknown>, component.colorKeys),
+ component.entityFields ?? []);
} catch (e) {
handleWasmError(e, `insertBuiltin(${component._name}, entity=${entity})`);
}
@@ -853,6 +844,24 @@ export class BuiltinBridge {
return { merged, isNew: isNew || !tracked };
}
+ /**
+ * Hand a component's whole value to C++, converting the fields embind cannot
+ * take as a JS array. The write `insert` performs, without its structural
+ * bookkeeping — so a replace cannot marshal differently from an add.
+ */
+ replace(entity: Entity, cppName: string, payload: Record<string, unknown>,
+ entityFields: readonly string[] = []): void {
+ const module = this.module_ as unknown as
+ { VectorEntity?: new () => WasmVector; VectorFloat?: new () => WasmVector } | null;
+ const vectors = materializeEntityVectors(payload, entityFields, module);
+ vectors.push(...materializeNumberVectors(payload, numberListFieldsOf(cppName), module));
+ try {
+ this.getBuiltinMethods(cppName).add(entity, payload);
+ } finally {
+ for (const v of vectors) v.delete();
+ }
+ }
+
get<T>(entity: Entity, component: BuiltinComponentDef<T>): T {
if (!this.cppRegistry_) {
throw new Error('C++ Registry not connected');
diff --git a/sdk/src/ecs/world.ts b/sdk/src/ecs/world.ts
index 7f974badc..df1c6661e 100644
--- a/sdk/src/ecs/world.ts
+++ b/sdk/src/ecs/world.ts
@@ -9,7 +9,8 @@ import { Entity, entityGeneration, entityIndex, makeEntity, INVALID_ENTITY } fro
import { AnyComponentDef, ComponentDef, ComponentData, BuiltinComponentDef, isBuiltinComponent, getComponentRegistry, getUserComponents, getComponent, Disabled, Name, Parent, Children, type ParentData, type ChildrenData } from './component';
import type { CppRegistry, ESEngineModule } from '../wasm';
import { handleWasmError } from '../wasm/wasmError';
-import { BuiltinBridge, convertFromWasm, convertForWasm, type BridgeConnectOptions, type BuiltinMethods, type CompositionDelta } from './bridge/BuiltinBridge';
+import { BuiltinBridge, convertFromWasm, convertForWasm, type BridgeConnectOptions,
+ type BuiltinMethods, type CompositionDelta } from './bridge/BuiltinBridge';
import { ScriptStorage } from './ScriptStorage';
import type { PoolMemory, ScriptPool } from './ScriptPool';
import { NameIndex } from './NameIndex';
@@ -719,10 +720,12 @@ export class World {
delete wasmData[k];
}
}
- this.builtin_.getBuiltinMethods(component._cppName).add(
- entity,
- convertForWasm(wasmData, component.colorKeys)
- );
+ // Through the bridge's own write, so a replace marshals the
+ // way an add does: a list field crosses as the vector embind
+ // registered, never as the JS array a document holds.
+ this.builtin_.replace(entity, component._cppName,
+ convertForWasm(wasmData, component.colorKeys),
+ component.entityFields ?? []);
} catch (e) {
handleWasmError(e, `set(${component._name}, entity=${entity})`);
}
diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjs
index e9077ccde..f36b1927f 100644
--- a/tools/renderScenes.mjs
+++ b/tools/renderScenes.mjs
@@ -115,6 +115,10 @@ export const SCENES = [
// DIFFERENT copy of the deform. Through the other source, the same shape: the
// two must move the quad alike or one of them is not deforming at all.
{ id: "mesh-morph-material", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mesh-morph-mat.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.75,\"y\":0.5,\"rgb\":[0,0,255],\"tol\":30},{\"x\":0.25,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":20}]" } },
+ // A clip driving the weight, which is what an imported `weights` channel
+ // becomes. The shape has to cross the boundary as a LIST — a weight written
+ // into a component the runtime hands back as an embind vector goes nowhere.
+ { id: "mesh-morph-animated", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_PLAY: "1", ESTELLA_VERIFY_SCENE: "/scenes/mesh-morph-anim.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "30", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.75,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":30},{\"x\":0.25,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":20}]" } },
// A mesh casting on a mesh: a floor 200 units below a blocker, sun leaning 0.5 in
// x, so the shadow lands 100 along +x and x 75..175 is floor the light cannot see.
// The blocker itself stays lit — shadowing one's own caster is the classic bug.