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(modeling): a foot can be told where to land, a controller says which clip plays when, and surfaces can be subdivided and edges rounded

yhhf90e7f16ae6c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1b102b5b9..d30beec1d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,7 +22,7 @@ published separately; it ships inside the editor.
- **Glyphs can be put on the atlas before they are shown.** The first page of a novel is hundreds of new characters, all landing in one frame. `preloadGlyphs(app, label, text, { budgetMs })` makes them ahead of time, a slice a frame, drawn as that `Text` will draw them, and returns `progress`, `done` and `release()`. On a Snapdragon 8 Elite a book's 2992 characters at 28 px took 145 ms over 25 frames with the worst frame at 9.5 ms, after which the first page's frame went from 49 to 11 ms and no page made a new glyph. Preloaded glyphs hold their atlas pages (4 MB each, a few hundred characters at that size) until `release()`.
- **Voxel GI lights what the camera does not see, and bounces light more than once.** The cache now reads the sun's shadow map back into the world, so a surface the sun lights behind or beside the camera still sends light into the view. Each surface also gives off again the bounce light it received, so a corner or a floor in shade gets light that took two or more bounces to reach it. A ray now brings what it meets at full strength however far it went (it used to fade with distance, 40% at 4 m with 12 cm voxels). Each voxel is weighed by how much of it a surface covers, so a bright patch no longer lights like the whole voxel around it. Together these keep the result close to a path tracer's whatever the voxel size. In a sunlit test room the whole frame carries 0.95 of Cycles' light at the default size and 0.74 at 12 cm voxels; before, it was 0.54 at the default and darker the finer the grid. With the lit patch behind the camera, the walls went from no bounce light to 25–57%. A closed room the sun only lights from outside stays dark. Two inspector controls tune it: **Off-screen Sun Albedo** (the colour the shadow map cannot give, assumed) and **Multi-bounce**. A fine grid no longer drops every voxel: a count truncated by the cache's ageing had kept them below the two samples a ray asks for. The WebGL2 fallback does the same in its own passes: each voxel asks the sun's map whether a sunlit surface stands in it, and traces two rays through last frame's grid for the light it is given. In the test room it carries 1.00 of Cycles' light at the default size (it was 0.56) and 0.80 at 12 cm; with the lit patch behind the camera 0.20 (it was 0). Its voxel pass costs about 1.3 ms more at 720p on a desktop.
-**AI agents can build 3D models in the editor from steps.** The `modeling` tool group writes a `.esmodel`, the steps that build a model (boxes, cylinders and floor plans, then extrude, inset, bevel, slice, array, mirror, paint), and bakes the `.esmesh` a scene draws beside it. Changing one number rebuilds it and whatever draws it follows, Undo takes both files back, and `model_views` shows every side with its silhouette, so an agent can check a shape without a scene. Blockouts, buildings and hard-surface props; and with the `organic` step, creatures, plants and rocks, as one skin over parts that melt into each other, carve, mirror and roughen. `lathe` and `loft` make curved solids from a few points: vases, pipes, handles, hulls. A `rig` of joints gets its weights found over the surface and `animations` of a few keys play as ordinary clips, so a creature can walk. A `boolean` step cuts real holes through solids, and a `uv` step or `uvAtlas` lays out how a texture lands.
+**AI agents can build 3D models in the editor from steps.** The `modeling` tool group writes a `.esmodel`, the steps that build a model (boxes, cylinders and floor plans, then extrude, inset, bevel, slice, array, mirror, paint), and bakes the `.esmesh` a scene draws beside it. Changing one number rebuilds it and whatever draws it follows, Undo takes both files back, and `model_views` shows every side with its silhouette, so an agent can check a shape without a scene. Blockouts, buildings and hard-surface props; and with the `organic` step, creatures, plants and rocks, as one skin over parts that melt into each other, carve, mirror and roughen. `lathe` and `loft` make curved solids from a few points: vases, pipes, handles, hulls. A `rig` of joints gets its weights found over the surface and `animations` of a few keys play as ordinary clips, so a creature can walk, with feet told where to land and a `controller` choosing which clip plays when. `subdivide` and a rounded `bevel` smooth what polygons leave hard. A `boolean` step cuts real holes through solids, and a `uv` step or `uvAtlas` lays out how a texture lands.
- **A model of many parts that moves: `CompositeBatch`.** Put it on the root of a ship, a vehicle or a moving platform assembled from many meshes, and while the game runs its parts are drawn in a few draws parented to the root: a mesh repeated four times or more (a deck plank, a rail post) as one instanced set that copies no vertices, every other part merged by draw state into chunks of the root's own space. Moving, turning or scaling the root moves the whole model and merges nothing again. Adding, removing, re-meshing or re-placing a part re-merges only its chunk within half a second (`CompositeBatchingRes.refresh(root)` looks at once), and a part that keeps moving inside the model is let go to draw itself. The root reports what it drew, and so does `get_stats`. On a model of 2,004 parts, the meshes handed to the renderer went from 2,003 to 5 and the CPU frame from 3.3 ms to 1.2–1.4 ms; a model of about a hundred parts costs the same either way. A part under a composite is never also statically batched.
diff --git a/desktop b/desktop
index cdcaa2259..702401b6a 160000
--- a/desktop
+++ b/desktop
@@ -1 +1 @@
-Subproject commit cdcaa22598ba02447f7ade755f3ac845ae3fc844
+Subproject commit 702401b6a3ac85c5f84288ba97beafffea6309a3
diff --git a/pipeline/src/modeling/index.ts b/pipeline/src/modeling/index.ts
index b527f3772..e6f7e1a88 100644
--- a/pipeline/src/modeling/index.ts
+++ b/pipeline/src/modeling/index.ts
@@ -13,4 +13,4 @@ export { needsPreparing, prepareModeling } from './booleans';
export { bakeModel, type BakedModel, type ModelReport } from './modelBake';
export type { FaceSelector } from './polyMesh';
export { DEFAULT_MODEL_VIEWS, MODEL_VIEWS, renderModelSheet, renderRigSheet, type ModelSheet, type ModelViewName, type RigViewOptions } from './modelViews';
-export { posedPositions, prefabOf, timelineOf, type AnimationSource, type RigSource } from './rig';
+export { controllerOf, jointPositions, posedPositions, prefabOf, timelineOf, type AnimationSource, type ControllerSource, type RigSource } from './rig';
diff --git a/pipeline/src/modeling/modelOps.ts b/pipeline/src/modeling/modelOps.ts
index 8d70a2cc3..58283e204 100644
--- a/pipeline/src/modeling/modelOps.ts
+++ b/pipeline/src/modeling/modelOps.ts
@@ -11,7 +11,7 @@
import {
add, boundsOf, collectEdges, compact, cross, dot, edgeKey, faceCenter, faceNormal, length, normalize, scale,
selectEdges, selectFaces, sub,
- type EdgeSelector, type Face, type FaceSelector, type PolyMesh, type Vec3,
+ type Edge, type EdgeSelector, type Face, type FaceSelector, type PolyMesh, type Vec3,
} from './polyMesh';
const EPS = 1e-6;
@@ -540,17 +540,47 @@ export function weld(mesh: PolyMesh, p: { distance?: number }): PolyMesh {
* edge slides along the other. Three or more new vertices round a vertex close with a
* cap; two are the edge the strips share, which is the mitre.
*/
-export function bevel(mesh: PolyMesh, p: { edges: EdgeSelector | 'all'; width: number; tag?: string }): PolyMesh {
+export function bevel(mesh: PolyMesh, p: { edges: EdgeSelector | 'all'; width: number; round?: number; tag?: string }): PolyMesh {
if (p.width <= 0) throw new Error(`width ${p.width} must be positive`);
+ const passes = p.round ?? 0;
+ if (!Number.isInteger(passes) || passes < 0 || passes > 3) throw new Error(`round ${passes} must be a whole number, 0..3`);
const chosen = selectEdges(mesh, p.edges === 'all' ? {} : p.edges);
if (chosen.length === 0) throw new Error(`\`edges\` ${JSON.stringify(p.edges)} matched no edge between two faces. Open rims cannot be bevelled, and edges closer to flat than \`sharp\` (default 10 degrees) are left out`);
+ // Rounded by cutting corners again: each pass takes a quarter off both sides of every corner the last one left, which closes on a curve.
+ let out = chamferEdges(mesh, chosen, p.width, p.tag);
+ let width = p.width * Math.SQRT2;
+ const firstNew = mesh.faces.length;
+ for (let pass = 0; pass < passes; pass++) {
+ width /= 4;
+ const corners = cornerEdges(out, firstNew);
+ const before = out.faces.length;
+ out = chamferEdges(out, corners, width, p.tag, true);
+ // Faces keep their order through a pass and its new ones go on the end, so the bevel's own run from the same place.
+ void before;
+ width *= 2;
+ }
+ return compact(out);
+}
+
+/** The edges where a bevel's own faces (those from @p firstNew on) meet anything at an angle: what the next rounding pass cuts. */
+function cornerEdges(mesh: PolyMesh, firstNew: number): Edge[] {
+ const flat = Math.cos((2 * Math.PI) / 180);
+ return [...collectEdges(mesh).values()].filter((e) => e.faces.length === 2 && e.faces.some((f) => f >= firstNew)
+ && dot(faceNormal(mesh, mesh.faces[e.faces[0]!]!), faceNormal(mesh, mesh.faces[e.faces[1]!]!)) < flat);
+}
+
+/** How far along an edge a rounding pass may cut: both ends must leave something of it, whatever size of sliver a corner left. */
+const ROUND_LIMIT = 0.45;
+
+/** @p fit keeps every cut on its edge instead of refusing one that overruns: a user's width is checked on the first pass, and later ones are the kernel's own. */
+function chamferEdges(mesh: PolyMesh, chosen: readonly Edge[], width: number, tag?: string, fit = false): PolyMesh {
+ const p = { tag };
const edges = collectEdges(mesh);
for (const edge of edges.values()) {
if (edge.faces.length > 2) throw new Error(`an edge at ${JSON.stringify(roundVec(mesh.positions[edge.a]!))} is shared by ${edge.faces.length} faces; weld or separate them first`);
}
const isChosen = new Set(chosen.map((e) => edgeKey(e.a, e.b)));
const positions = mesh.positions.slice();
- const width = p.width;
// How far each end of an edge is eaten, to refuse a bevel wider than the edge. The most any face at that end asks: two faces share it.
const eaten = new Map<string, number>();
@@ -574,7 +604,8 @@ export function bevel(mesh: PolyMesh, p: { edges: EdgeSelector | 'all'; width: n
if (known !== undefined) return known;
const lean = dot(along, across);
// An edge running away from the chamfer, or nearly along it, has no distance that is `width` across: fall back on `width`.
- const t = lean > 0.05 ? width / lean : width;
+ const wanted = lean > 0.05 ? width / lean : width;
+ const t = fit ? Math.min(wanted, length(sub(mesh.positions[far]!, mesh.positions[v]!)) * ROUND_LIMIT) : wanted;
eat(v, far, t);
const at = positions.length;
positions.push(add(mesh.positions[v]!, scale(along, t)));
@@ -594,7 +625,13 @@ export function bevel(mesh: PolyMesh, p: { edges: EdgeSelector | 'all'; width: n
const inNext = normalize(cross(n, toNext)), inPrev = normalize(cross(toPrev, n));
let run: number[];
if (nextChosen && prevChosen) {
- const q = offsetCorner(at, n, toNext, toPrev, width, width);
+ let q = offsetCorner(at, n, toNext, toPrev, width, width);
+ if (fit) {
+ // Shrunk toward the corner until it is within both edges' share.
+ const room = ROUND_LIMIT * Math.min(length(sub(mesh.positions[next]!, at)), length(sub(mesh.positions[prev]!, at)));
+ const along = Math.max(dot(sub(q, at), toNext), dot(sub(q, at), toPrev), length(sub(q, at)));
+ if (along > room) q = add(at, scale(sub(q, at), room / along));
+ }
eat(v, next, dot(sub(q, at), toNext));
eat(v, prev, dot(sub(q, at), toPrev));
run = [positions.length];
@@ -611,7 +648,7 @@ export function bevel(mesh: PolyMesh, p: { edges: EdgeSelector | 'all'; width: n
});
// Refused before any face is built: an overrun edge is a bow-tie, and it would look like a rendering bug.
- for (const [key, t] of eaten) {
+ if (!fit) for (const [key, t] of eaten) {
const [a, b] = key.split('>').map(Number) as [number, number];
const needs = t + (eaten.get(`${b}>${a}`) ?? 0);
const long = length(sub(mesh.positions[a]!, mesh.positions[b]!));
diff --git a/pipeline/src/modeling/modelSource.ts b/pipeline/src/modeling/modelSource.ts
index 1074dfa9e..8bfbe67b0 100644
--- a/pipeline/src/modeling/modelSource.ts
+++ b/pipeline/src/modeling/modelSource.ts
@@ -17,7 +17,8 @@ import { organic } from './organic';
import { booleanOp } from './booleans';
import { uvStep } from './modelUv';
import { lathe, loft } from './surfaces';
-import { checkAnimations, checkRig, type AnimationSource, type RigSource } from './rig';
+import { subdivide } from './subdivide';
+import { checkAnimations, checkController, checkRig, type AnimationSource, type ControllerSource, type RigSource } from './rig';
import { compact, type Face, type FaceSelector, type PolyMesh, type Vec3 } from './polyMesh';
export const MODEL_SOURCE_VERSION = 1;
@@ -42,6 +43,8 @@ export interface ModelSource {
rig?: RigSource;
/** Clips moving the rig's joints, each written as an `.estimeline`. */
animations?: AnimationSource[];
+ /** Which clip plays when: an `.esanimator` the prefab's Animator runs. */
+ controller?: ControllerSource;
steps: ModelStep[];
}
@@ -74,9 +77,10 @@ export const MODEL_OPS: Record<string, OpSpec> = {
mirror: { params: { faces: 'faces', axis: 'axis', at: 'number', keep: 'boolean', tag: 'string' }, required: ['axis'], run: ops.mirror as OpSpec['run'], says: 'adds a reflection across `axis` = `at`' },
extrude: { params: { faces: 'faces', distance: 'number', direction: 'vec3', individual: 'boolean', tag: 'string', sideTag: 'string' }, required: ['faces', 'distance'], run: ops.extrude as OpSpec['run'], says: 'pushes faces out along their normals, walls joining them to where they were; negative recesses' },
inset: { params: { faces: 'faces', amount: 'number', tag: 'string' }, required: ['faces', 'amount'], run: ops.inset as OpSpec['run'], says: 'adds a smaller copy inside each face; `tag` names that copy' },
- bevel: { params: { edges: 'edges', width: 'number', tag: 'string' }, required: ['edges', 'width'], run: ops.bevel as OpSpec['run'], says: 'chamfers edges flat, mitring where they meet' },
+ bevel: { params: { edges: 'edges', width: 'number', round: 'integer', tag: 'string' }, required: ['edges', 'width'], run: ops.bevel as OpSpec['run'], says: 'chamfers edges, mitring where they meet; `round` 1..3 rounds them off' },
slice: { params: { faces: 'faces', axis: 'axis', at: 'number|numbers' }, required: ['axis', 'at'], run: ops.slice as OpSpec['run'], says: 'cuts faces across planes, making the seams a window sits between' },
boolean: { params: { operation: 'operation', with: 'faces', from: 'faces', keep: 'boolean', tag: 'string', color: 'color' }, required: ['operation', 'with'], run: booleanOp as unknown as OpSpec['run'], says: 'cuts or joins closed solids: subtract `with` from `from` makes a real hole' },
+ subdivide: { params: { faces: 'faces', levels: 'integer', crease: 'number' }, required: [], run: subdivide as unknown as OpSpec['run'], says: 'rounds whole shells into smooth surfaces, keeping edges sharper than `crease` degrees' },
uv: { params: { faces: 'faces', mode: 'uvmode', axis: 'string', at: 'vec3', scale: 'number|vec2only', repeat: 'number|vec2only', offset: 'vec2', rotate: 'number' }, required: ['mode'], run: uvStep as unknown as OpSpec['run'], says: 'sets how faces take a texture: box, planar, cylinder or sphere' },
delete: { params: { faces: 'faces' }, required: ['faces'], run: ops.deleteFaces as OpSpec['run'], says: 'removes faces, leaving a hole' },
paint: { params: { faces: 'faces', color: 'color' }, required: ['faces', 'color'], run: ops.paint as OpSpec['run'], says: 'sets vertex colour: linear [r, g, b] in 0..1, multiplied into the material' },
@@ -252,8 +256,8 @@ export function validateModelSource(raw: unknown): ModelSource {
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) throw new ModelBuildError('a model source must be an object with `steps`', null, null, null);
const source = raw as Record<string, unknown>;
for (const key of Object.keys(source)) {
- if (!['version', 'smoothAngle', 'uvScale', 'uvAtlas', 'rig', 'animations', 'steps'].includes(key)) {
- throw new ModelBuildError(`unknown field "${key}"; a model source has version, smoothAngle, uvScale, uvAtlas, rig, animations, steps`, null, null, null);
+ if (!['version', 'smoothAngle', 'uvScale', 'uvAtlas', 'rig', 'animations', 'controller', 'steps'].includes(key)) {
+ throw new ModelBuildError(`unknown field "${key}"; a model source has version, smoothAngle, uvScale, uvAtlas, rig, animations, controller, steps`, null, null, null);
}
}
if (source.version !== undefined && source.version !== MODEL_SOURCE_VERSION) {
@@ -277,6 +281,10 @@ export function validateModelSource(raw: unknown): ModelSource {
const bad = checkAnimations(source.animations, source.rig);
if (bad) throw new ModelBuildError(bad, null, null, null);
}
+ if (source.controller !== undefined) {
+ const bad = checkController(source.controller, source.animations);
+ if (bad) throw new ModelBuildError(bad, null, null, null);
+ }
if (!Array.isArray(source.steps)) throw new ModelBuildError('`steps` must be an array', null, null, null);
const ids = new Set<string>();
source.steps.forEach((step: Partial<ModelStep> | null, index: number) => {
@@ -338,7 +346,7 @@ export type ModelEdit =
| { op: 'set'; step: string | number; fields: Record<string, unknown> }
| { op: 'insert'; step: ModelStep; before?: string | number; after?: string | number }
| { op: 'remove'; step: string | number }
- | { op: 'settings'; fields: Pick<ModelSource, 'smoothAngle' | 'uvScale' | 'uvAtlas' | 'rig' | 'animations'> };
+ | { op: 'settings'; fields: Pick<ModelSource, 'smoothAngle' | 'uvScale' | 'uvAtlas' | 'rig' | 'animations' | 'controller'> };
function indexOfStep(source: ModelSource, ref: string | number): number {
const i = typeof ref === 'number' ? ref : source.steps.findIndex((s) => s.id === ref);
diff --git a/pipeline/src/modeling/rig.ts b/pipeline/src/modeling/rig.ts
index 8b4cb4d1c..c232f82f0 100644
--- a/pipeline/src/modeling/rig.ts
+++ b/pipeline/src/modeling/rig.ts
@@ -8,8 +8,8 @@
* close through the air and far apart over the skin, and only the second is
* whether one should drag the other.
*/
-import { PREFAB_FORMAT_VERSION, TIMELINE_FORMAT_VERSION } from 'esengine';
-import { add, boundsOf, cross, dot, length, scale, sub, type PolyMesh, type Vec3 } from './polyMesh';
+import { ANIMATOR_FORMAT_VERSION, PREFAB_FORMAT_VERSION, TIMELINE_FORMAT_VERSION } from 'esengine';
+import { add, boundsOf, cross, dot, length, normalize, scale, sub, type PolyMesh, type Vec3 } from './polyMesh';
export const MAX_RIG_JOINTS = 64;
const DEG = Math.PI / 180;
@@ -33,6 +33,16 @@ export interface AnimationTrack {
rotate?: readonly (readonly number[])[];
/** [time, x, y, z] from where the joint rests. */
move?: readonly (readonly number[])[];
+ /**
+ * [time, x, y, z] where this joint must be, in the model's own space: the foot of a two-bone limb,
+ * whose parent and grandparent turn to put it there. `rotate` on the same track then holds it at
+ * that orientation in the model's space, and left out it stays level with the ground.
+ */
+ reach?: readonly (readonly number[])[];
+ /** The way the middle joint of a `reach` bends: forward for a knee, back for an elbow. Default the way it already bends, else +Z. */
+ pole?: Vec3;
+ /** Straight lines between keys, for a foot sliding along the ground: a curve would dip through it. */
+ linear?: boolean;
/** Shifts the keys by this fraction of the clip: the other leg, half a stride behind. */
phase?: number;
}
@@ -298,7 +308,8 @@ function checkKeys(keys: unknown, duration: number, label: string): string | nul
export function checkAnimations(raw: unknown, rig: unknown): string | null {
if (!Array.isArray(raw)) return 'animations must be an array';
if (!rig) return 'animations move joints, and this source has no rig';
- const names = new Set(resolveJoints(rig as RigSource).map((j) => j.name));
+ const jointList = resolveJoints(rig as RigSource);
+ const names = new Set(jointList.map((j) => j.name));
const seen = new Set<string>();
for (const [i, a] of (raw as Record<string, unknown>[]).entries()) {
if (typeof a !== 'object' || a === null) return `animation ${i} must be an object`;
@@ -311,18 +322,36 @@ export function checkAnimations(raw: unknown, rig: unknown): string | null {
if (!Array.isArray(a.tracks) || a.tracks.length === 0) return `animation "${a.name}" needs tracks`;
const tracked = new Set<string>();
for (const t of a.tracks as Record<string, unknown>[]) {
- for (const key of Object.keys(t)) if (!['joint', 'rotate', 'move', 'phase'].includes(key)) return `animation "${a.name}": a track has an unknown field "${key}"; it takes joint, rotate, move, phase`;
+ for (const key of Object.keys(t)) if (!['joint', 'rotate', 'move', 'reach', 'pole', 'linear', 'phase'].includes(key)) return `animation "${a.name}": a track has an unknown field "${key}"; it takes joint, rotate, move, reach, pole, linear, phase`;
if (!names.has(t.joint as string)) return `animation "${a.name}": no joint "${String(t.joint)}"; there are ${[...names].join(', ')}`;
if (tracked.has(t.joint as string)) return `animation "${a.name}": two tracks for joint "${t.joint as string}"; put their keys in one`;
tracked.add(t.joint as string);
- if (t.rotate === undefined && t.move === undefined) return `animation "${a.name}": the track for "${t.joint as string}" has neither rotate nor move`;
- for (const kind of ['rotate', 'move'] as const) {
+ if (t.rotate === undefined && t.move === undefined && t.reach === undefined) return `animation "${a.name}": the track for "${t.joint as string}" has none of rotate, move, reach`;
+ if (t.reach !== undefined) {
+ if (t.move !== undefined) return `animation "${a.name}": "${t.joint as string}" has both reach and move; reach already says where it goes`;
+ const chain = jointList.find((j) => j.name === t.joint)!;
+ const lower = chain.parent >= 0 ? jointList[chain.parent]! : null;
+ if (!lower || lower.parent < 0) return `animation "${a.name}": reach needs two bones above the joint, and "${t.joint as string}" has fewer`;
+ }
+ if (t.pole !== undefined && (!vec3(t.pole) || t.reach === undefined)) return `animation "${a.name}": pole on "${t.joint as string}" must be [x, y, z], and goes with reach`;
+ if (t.linear !== undefined && typeof t.linear !== 'boolean') return `animation "${a.name}": linear must be true or false`;
+ for (const kind of ['rotate', 'move', 'reach'] as const) {
if (t[kind] === undefined) continue;
const bad = checkKeys(t[kind], a.duration, `animation "${a.name}", ${t.joint as string}.${kind}`);
if (bad) return bad;
}
if (t.phase !== undefined && !isNum(t.phase)) return `animation "${a.name}": phase must be a number`;
}
+ // A reach decides its limb, so a rotate on the two joints it turns would be silently thrown away.
+ for (const t of a.tracks as AnimationTrack[]) {
+ if (!t.reach) continue;
+ const foot = jointList.find((j) => j.name === t.joint)!;
+ const lower = jointList[foot.parent]!, upper = jointList[lower.parent]!;
+ for (const taken of [lower, upper]) {
+ const clash = (a.tracks as AnimationTrack[]).find((o) => o.joint === taken.name && o.rotate);
+ if (clash) return `animation "${a.name}": "${taken.name}" has rotate keys, but the reach on "${t.joint}" decides how it turns`;
+ }
+ }
}
return null;
}
@@ -356,7 +385,7 @@ function rotateBy(q: Quat, v: Vec3): Vec3 {
}
/** A key track's value at @p time: a smooth line through the keys, passing through each exactly. */
-function sample(keys: readonly (readonly number[])[], time: number, duration: number, loop: boolean, phase: number): Vec3 {
+function sample(keys: readonly (readonly number[])[], time: number, duration: number, loop: boolean, phase: number, linear = false): Vec3 {
const shifted = keys.map((k) => [k[0]! + phase * duration, k[1]!, k[2]!, k[3]!] as const);
const wrap = (t: number): number => ((t % duration) + duration) % duration;
const list = (loop ? shifted.map((k) => [wrap(k[0]), k[1], k[2], k[3]] as const) : shifted).slice().sort((a, b) => a[0] - b[0]);
@@ -378,6 +407,7 @@ function sample(keys: readonly (readonly number[])[], time: number, duration: nu
const [p0, p1, p2, p3] = [at(i - 1), at(i), at(i + 1), at(i + 2)];
const span = p2[0]! - p1[0]!;
const u = span > 0 ? (t - p1[0]!) / span : 0;
+ if (linear) return [1, 2, 3].map((c) => p1[c]! + (p2[c]! - p1[c]!) * u) as unknown as Vec3;
const [u2, u3] = [u * u, u * u * u];
const v = [1, 2, 3].map((c) => {
const [a, b] = [p1[c]!, p2[c]!];
@@ -388,29 +418,99 @@ function sample(keys: readonly (readonly number[])[], time: number, duration: nu
return v as unknown as Vec3;
}
-/** Each joint's world rotation and origin at @p time; the bind pose with no animation. */
-function poseAt(joints: readonly RigJoint[], animation: AnimationSource | null, time: number): { q: Quat; origin: Vec3 }[] {
- const out: { q: Quat; origin: Vec3 }[] = [];
+const conjugate = (q: Quat): Quat => [-q[0], -q[1], -q[2], q[3]];
+
+/** The shortest rotation taking direction @p from onto @p to. */
+function rotationBetween(from: Vec3, to: Vec3): Quat {
+ const a = normalize(from), b = normalize(to);
+ const d = dot(a, b);
+ if (d > 1 - 1e-9) return [0, 0, 0, 1];
+ if (d < -1 + 1e-9) {
+ const side = normalize(cross(a, Math.abs(a[0]) < 0.9 ? [1, 0, 0] : [0, 1, 0]));
+ return [side[0], side[1], side[2], 0];
+ }
+ const c = cross(a, b);
+ const w = 1 + d;
+ const len = Math.hypot(c[0], c[1], c[2], w);
+ return [c[0] / len, c[1] / len, c[2] / len, w / len];
+}
+
+interface Pose {
+ /** Relative to the parent: what a clip writes. */
+ local: { q: Quat; offset: Vec3 }[];
+ /** In the model's space: what skinning reads. */
+ world: { q: Quat; origin: Vec3 }[];
+}
+
+function toWorld(joints: readonly RigJoint[], local: Pose['local']): Pose['world'] {
+ const world: Pose['world'] = [];
joints.forEach((j, i) => {
- const track = animation?.tracks.find((t) => t.joint === j.name);
- const loop = animation?.loop !== false;
- const euler = track?.rotate ? sample(track.rotate, time, animation!.duration, loop, track.phase ?? 0) : [0, 0, 0] as Vec3;
- const moved = track?.move ? sample(track.move, time, animation!.duration, loop, track.phase ?? 0) : [0, 0, 0] as Vec3;
- const local = eulerToQuat(euler[0], euler[1], euler[2]);
- const rest = j.parent >= 0 ? sub(j.at, joints[j.parent]!.at) : j.at;
- const offset = add(rest, moved);
- if (j.parent < 0) out[i] = { q: local, origin: offset };
+ const l = local[i]!;
+ if (j.parent < 0) world[i] = { q: l.q, origin: l.offset };
else {
- const p = out[j.parent]!;
- out[i] = { q: quatMul(p.q, local), origin: add(p.origin, rotateBy(p.q, offset)) };
+ const p = world[j.parent]!;
+ world[i] = { q: quatMul(p.q, l.q), origin: add(p.origin, rotateBy(p.q, l.offset)) };
}
});
- return out;
+ return world;
+}
+
+/** Each joint at @p time, with every `reach` solved; the bind pose with no animation. */
+function poseAt(joints: readonly RigJoint[], animation: AnimationSource | null, time: number): Pose {
+ const loop = animation?.loop !== false;
+ const at = (keys: readonly (readonly number[])[], t: AnimationTrack): Vec3 => sample(keys, time, animation!.duration, loop, t.phase ?? 0, t.linear === true);
+ const local: Pose['local'] = joints.map((j) => {
+ const track = animation?.tracks.find((t) => t.joint === j.name);
+ const euler = track?.rotate && !track.reach ? at(track.rotate, track) : [0, 0, 0] as Vec3;
+ const moved = track?.move ? at(track.move, track) : [0, 0, 0] as Vec3;
+ const rest = j.parent >= 0 ? sub(j.at, joints[j.parent]!.at) : j.at;
+ return { q: eulerToQuat(euler[0], euler[1], euler[2]), offset: add(rest, moved) };
+ });
+ let world = toWorld(joints, local);
+ for (const track of animation?.tracks ?? []) {
+ if (!track.reach) continue;
+ const foot = joints.findIndex((j) => j.name === track.joint);
+ const lower = joints[foot]!.parent, upper = joints[lower]!.parent, above = joints[upper]!.parent;
+ const target = at(track.reach, track);
+ const a = world[upper]!.origin, b = world[lower]!.origin, c = world[foot]!.origin;
+ const upperLen = length(sub(joints[lower]!.at, joints[upper]!.at)), lowerLen = length(sub(joints[foot]!.at, joints[lower]!.at));
+ const toTarget = sub(target, a);
+ const near = Math.abs(upperLen - lowerLen) + 1e-4, far = upperLen + lowerLen - 1e-4;
+ // Out of reach it stretches straight toward the target; the report cannot say so per frame, the strip shows it.
+ const span = Math.max(near, Math.min(far, length(toTarget)));
+ const along = normalize(toTarget);
+ const bent = sub(b, add(a, scale(along, dot(sub(b, a), along))));
+ const hint = track.pole ?? (length(bent) > upperLen * 0.01 ? bent : [0, 0, 1] as Vec3);
+ let side = sub(hint, scale(along, dot(hint, along)));
+ if (length(side) < 1e-6) side = sub([1, 0, 0], scale(along, along[0]));
+ const toKnee = (upperLen * upperLen - lowerLen * lowerLen + span * span) / (2 * span);
+ const out = Math.sqrt(Math.max(0, upperLen * upperLen - toKnee * toKnee));
+ const knee = add(add(a, scale(along, toKnee)), scale(normalize(side), out));
+ const end = add(a, scale(along, span));
+ const upperWorld = quatMul(rotationBetween(sub(b, a), sub(knee, a)), world[upper]!.q);
+ // Where the foot would now be, carried by the upper bone, is what the lower bone turns from.
+ const carried = rotateBy(rotationBetween(sub(b, a), sub(knee, a)), sub(c, b));
+ const lowerWorld = quatMul(rotationBetween(carried, sub(end, knee)), quatMul(rotationBetween(sub(b, a), sub(knee, a)), world[lower]!.q));
+ const held = track.rotate ? at(track.rotate, track) : [0, 0, 0] as Vec3;
+ const footWorld = eulerToQuat(held[0], held[1], held[2]);
+ const parentWorld = above >= 0 ? world[above]!.q : [0, 0, 0, 1] as Quat;
+ local[upper] = { ...local[upper]!, q: quatMul(conjugate(parentWorld), upperWorld) };
+ local[lower] = { ...local[lower]!, q: quatMul(conjugate(upperWorld), lowerWorld) };
+ local[foot] = { ...local[foot]!, q: quatMul(conjugate(lowerWorld), footWorld) };
+ world = toWorld(joints, local);
+ }
+ return { local, world };
+}
+
+/** Where each joint is in a pose: for checking a foot landed. */
+export function jointPositions(joints: readonly RigJoint[], animation: AnimationSource | null, time: number): Record<string, Vec3> {
+ const { world } = poseAt(joints, animation, time);
+ return Object.fromEntries(joints.map((j, i) => [j.name, world[i]!.origin]));
}
/** The surface's positions in a pose, skinned as the engine skins it. */
export function posedPositions(mesh: PolyMesh, joints: readonly RigJoint[], skin: SkinWeights, animation: AnimationSource | null, time: number): Vec3[] {
- const pose = poseAt(joints, animation, time);
+ const pose = poseAt(joints, animation, time).world;
return mesh.positions.map((p, v) => {
let out: Vec3 = [0, 0, 0];
for (let k = 0; k < 4; k++) {
@@ -426,7 +526,7 @@ export function posedPositions(mesh: PolyMesh, joints: readonly RigJoint[], skin
/** The bones as lines in a pose, for drawing over a view. */
export function boneLines(joints: readonly RigJoint[], animation: AnimationSource | null, time: number): [Vec3, Vec3][] {
- const pose = poseAt(joints, animation, time);
+ const pose = poseAt(joints, animation, time).world;
return joints.flatMap((j, i) => (j.parent >= 0 ? [[pose[j.parent]!.origin, pose[i]!.origin] as [Vec3, Vec3]] : []));
}
@@ -444,18 +544,29 @@ export function timelineOf(animation: AnimationSource, joints: readonly RigJoint
for (let at = i; at >= 0; at = joints[at]!.parent) parts.unshift(joints[at]!.name);
return parts.join('/');
};
- const tracks = animation.tracks.map((track) => {
+ // Every joint the clip turns, a reach's two bones among them: they have no keys of their own, only the solved pose.
+ const turned = new Set<number>();
+ const moved = new Set<number>();
+ for (const track of animation.tracks) {
const index = joints.findIndex((j) => j.name === track.joint);
- const joint = joints[index]!;
+ if (track.rotate || track.reach) turned.add(index);
+ if (track.move) moved.add(index);
+ if (track.reach) {
+ turned.add(joints[index]!.parent);
+ turned.add(joints[joints[index]!.parent]!.parent);
+ }
+ }
+ const poses = times.map((t) => poseAt(joints, animation, t).local);
+ const tracks = joints.flatMap((joint, index) => {
+ if (!turned.has(index) && !moved.has(index)) return [];
const channels: { property: string; keyframes: Keyframe[] }[] = [];
const push = (property: string, values: number[]): void => {
channels.push({ property, keyframes: values.map((value, f) => ({ time: times[f]!, value, inTangent: 0, outTangent: 0, interpolation: 'linear' })) });
};
- if (track.rotate) {
+ if (turned.has(index)) {
let last: Quat | null = null;
- const qs = times.map((t) => {
- const e = sample(track.rotate!, t, animation.duration, loop, track.phase ?? 0);
- let q = eulerToQuat(e[0], e[1], e[2]);
+ const qs = poses.map((pose) => {
+ let q = pose[index]!.q;
// The short way round between samples: the two signs of a quaternion are one rotation, and interpolated apart they spin the long way.
if (last && q[0] * last[0] + q[1] * last[1] + q[2] * last[2] + q[3] * last[3] < 0) q = [-q[0], -q[1], -q[2], -q[3]];
last = q;
@@ -463,12 +574,10 @@ export function timelineOf(animation: AnimationSource, joints: readonly RigJoint
});
['x', 'y', 'z', 'w'].forEach((c, k) => push(`rotation.${c}`, qs.map((q) => q[k]!)));
}
- if (track.move) {
- const rest = joint.parent >= 0 ? sub(joint.at, joints[joint.parent]!.at) : joint.at;
- const ps = times.map((t) => add(rest, sample(track.move!, t, animation.duration, loop, track.phase ?? 0)));
- ['x', 'y', 'z'].forEach((c, k) => push(`position.${c}`, ps.map((p) => p[k]!)));
+ if (moved.has(index)) {
+ ['x', 'y', 'z'].forEach((c, k) => push(`position.${c}`, poses.map((pose) => pose[index]!.offset[k]!)));
}
- return { type: 'property', name: joint.name, childPath: pathOf(index), component: 'Transform', channels };
+ return [{ type: 'property', name: joint.name, childPath: pathOf(index), component: 'Transform', channels }];
});
return { version: TIMELINE_FORMAT_VERSION, type: 'timeline', duration: animation.duration, wrapMode: loop ? 'loop' : 'once', tracks };
}
@@ -477,7 +586,7 @@ export function timelineOf(animation: AnimationSource, joints: readonly RigJoint
* The prefab that draws and moves it: the mesh on the root, the joints below it as
* entities named so a clip's paths find them, and a player for the first clip.
*/
-export function prefabOf(name: string, meshPath: string, joints: readonly RigJoint[], cullBackfaces: boolean, firstClip: string | null): Record<string, unknown> {
+export function prefabOf(name: string, meshPath: string, joints: readonly RigJoint[], cullBackfaces: boolean, firstClip: string | null, controller: string | null = null): Record<string, unknown> {
const idOf = (i: number): string => `j${i}`;
const entities: Record<string, unknown>[] = [{
prefabEntityId: 'root', name, parent: null,
@@ -487,7 +596,9 @@ export function prefabOf(name: string, meshPath: string, joints: readonly RigJoi
{ type: 'Transform', data: {} },
{ type: 'MeshRenderer', data: { mesh: meshPath, lit: true, opaque: true, cullBackfaces, enabled: true } },
{ type: 'MeshSkin', data: { joints: joints.map((_, i) => idOf(i)) } },
- ...(firstClip ? [{ type: 'TimelinePlayer', data: { timeline: firstClip, playing: true } }] : []),
+ // A controller decides what plays; a player beside it would fight it for the same joints.
+ ...(controller ? [{ type: 'Animator', data: { controller, enabled: true } }]
+ : firstClip ? [{ type: 'TimelinePlayer', data: { timeline: firstClip, playing: true } }] : []),
],
}];
joints.forEach((j, i) => {
@@ -501,6 +612,118 @@ export function prefabOf(name: string, meshPath: string, joints: readonly RigJoi
return { version: PREFAB_FORMAT_VERSION, name, rootEntityId: 'root', entities };
}
+// ---- Controller -----------------------------------------------------------------
+
+export interface ControllerTransition {
+ to: string;
+ /** Every one must hold. Left out, it leaves as soon as `afterClip` lets it. */
+ when?: readonly { param: string; op: 'gt' | 'lt' | 'eq' | 'neq' | 'true' | 'false' | 'trigger'; value?: number }[];
+ /** Seconds to cross-fade. */
+ blend?: number;
+ /** Only once the state's clip has finished. */
+ afterClip?: boolean;
+}
+
+export interface ControllerState {
+ name: string;
+ /** The animation it plays. */
+ clip?: string;
+ /** Or one chosen by a float: idle, walk, run as speed rises. */
+ blend?: { parameter: string; stops: readonly { value: number; clip: string }[] };
+ speed?: number;
+ transitions?: readonly ControllerTransition[];
+}
+
+export interface ControllerSource {
+ parameters?: readonly { name: string; type: 'float' | 'bool' | 'trigger'; default?: number | boolean }[];
+ initial: string;
+ states: readonly ControllerState[];
+ /** Checked from every state first: a hit reaction, a death. */
+ any?: readonly ControllerTransition[];
+}
+
+/** What is wrong with a source's `controller`, or null. */
+export function checkController(raw: unknown, animations: unknown): string | null {
+ const c = raw as Record<string, unknown>;
+ if (typeof raw !== 'object' || raw === null) return 'controller must be { parameters?, initial, states, any? }';
+ for (const key of Object.keys(c)) if (!['parameters', 'initial', 'states', 'any'].includes(key)) return `controller has an unknown field "${key}"; it takes parameters, initial, states, any`;
+ if (!Array.isArray(animations) || animations.length === 0) return 'a controller plays animations, and this source has none';
+ const clips = new Set((animations as AnimationSource[]).map((a) => a.name));
+ const params = new Map<string, string>();
+ for (const p of (c.parameters ?? []) as Record<string, unknown>[]) {
+ if (typeof p.name !== 'string' || !['float', 'bool', 'trigger'].includes(p.type as string)) return 'a controller parameter is { name, type: float | bool | trigger, default? }';
+ if (params.has(p.name)) return `there are two parameters called "${p.name}"`;
+ params.set(p.name, p.type as string);
+ }
+ if (!Array.isArray(c.states) || c.states.length === 0) return 'a controller needs states';
+ const states = new Set<string>();
+ for (const s of c.states as ControllerState[]) {
+ if (typeof s.name !== 'string' || !s.name) return 'every controller state needs a name';
+ if (states.has(s.name)) return `there are two states called "${s.name}"`;
+ states.add(s.name);
+ }
+ if (!states.has(c.initial as string)) return `initial ${JSON.stringify(c.initial)} is not a state; there are ${[...states].join(', ')}`;
+ const needClip = (clip: unknown, where: string): string | null => (clips.has(clip as string) ? null : `${where} plays ${JSON.stringify(clip)}, which is not an animation; there are ${[...clips].join(', ')}`);
+ const checkTransitions = (list: unknown, where: string): string | null => {
+ if (list === undefined) return null;
+ if (!Array.isArray(list)) return `${where}: transitions must be an array`;
+ for (const t of list as ControllerTransition[]) {
+ for (const key of Object.keys(t)) if (!['to', 'when', 'blend', 'afterClip'].includes(key)) return `${where}: a transition has an unknown field "${key}"; it takes to, when, blend, afterClip`;
+ if (!states.has(t.to)) return `${where}: a transition goes to "${t.to}", which is not a state; there are ${[...states].join(', ')}`;
+ for (const w of t.when ?? []) {
+ const type = params.get(w.param);
+ if (!type) return `${where}: a condition reads "${w.param}", which is not a parameter; declare it in parameters`;
+ if (!['gt', 'lt', 'eq', 'neq', 'true', 'false', 'trigger'].includes(w.op)) return `${where}: op ${JSON.stringify(w.op)} must be gt, lt, eq, neq, true, false or trigger`;
+ if (['gt', 'lt', 'eq', 'neq'].includes(w.op) && (type !== 'float' || !isNum(w.value))) return `${where}: ${w.op} compares a float parameter with a number \`value\``;
+ if ((w.op === 'true' || w.op === 'false') && type !== 'bool') return `${where}: ${w.op} reads a bool parameter, and "${w.param}" is a ${type}`;
+ if (w.op === 'trigger' && type !== 'trigger') return `${where}: trigger reads a trigger parameter, and "${w.param}" is a ${type}`;
+ }
+ }
+ return null;
+ };
+ for (const s of c.states as ControllerState[]) {
+ for (const key of Object.keys(s)) if (!['name', 'clip', 'blend', 'speed', 'transitions'].includes(key)) return `state "${s.name}" has an unknown field "${key}"; it takes name, clip, blend, speed, transitions`;
+ if ((s.clip === undefined) === (s.blend === undefined)) return `state "${s.name}" needs exactly one of clip, blend`;
+ if (s.clip !== undefined) { const bad = needClip(s.clip, `state "${s.name}"`); if (bad) return bad; }
+ if (s.blend) {
+ if (params.get(s.blend.parameter) !== 'float') return `state "${s.name}": a blend is chosen by a float parameter, and "${s.blend.parameter}" is not one`;
+ if (!Array.isArray(s.blend.stops) || s.blend.stops.length === 0) return `state "${s.name}": a blend needs stops`;
+ for (const stop of s.blend.stops) { const bad = needClip(stop.clip, `state "${s.name}"`); if (bad) return bad; }
+ }
+ const bad = checkTransitions(s.transitions, `state "${s.name}"`);
+ if (bad) return bad;
+ }
+ return checkTransitions(c.any, 'any');
+}
+
+/** A controller as an `.esanimator`. @p clipFile turns an animation's name into the file it plays, as written beside this one. */
+export function controllerOf(source: ControllerSource, animations: readonly AnimationSource[], clipFile: (name: string) => string): Record<string, unknown> {
+ const motionOf = (clip: string, speed?: number): Record<string, unknown> => ({
+ kind: 'timeline', clip: clipFile(clip),
+ loop: animations.find((a) => a.name === clip)?.loop !== false,
+ ...(speed !== undefined ? { speed } : {}),
+ });
+ const transition = (t: ControllerTransition): Record<string, unknown> => ({
+ to: t.to,
+ conditions: (t.when ?? []).map((w) => (w.value !== undefined ? { param: w.param, op: w.op, value: w.value } : { param: w.param, op: w.op })),
+ ...(t.blend !== undefined ? { duration: t.blend } : {}),
+ ...(t.afterClip ? { hasExitTime: true } : {}),
+ });
+ return {
+ version: ANIMATOR_FORMAT_VERSION,
+ parameters: (source.parameters ?? []).map((p) => ({ ...p })),
+ initialState: source.initial,
+ ...(source.any ? { anyStateTransitions: source.any.map(transition) } : {}),
+ states: source.states.map((s, i) => ({
+ name: s.name, x: 80 + (i % 4) * 220, y: 80 + Math.floor(i / 4) * 140,
+ motion: s.blend
+ ? { kind: 'blend1d', parameter: s.blend.parameter, thresholds: s.blend.stops.map((stop) => ({ value: stop.value, motion: motionOf(stop.clip, s.speed) })) }
+ : motionOf(s.clip!, s.speed),
+ transitions: (s.transitions ?? []).map(transition),
+ })),
+ };
+}
+
/** One bind matrix per joint: a joint's bind pose is unrotated, so each is only the way back to its rest position. */
export function bindMatrices(joints: readonly RigJoint[]): Float32Array {
const out = new Float32Array(joints.length * 16);
diff --git a/pipeline/src/modeling/subdivide.ts b/pipeline/src/modeling/subdivide.ts
new file mode 100644
index 000000000..19481cc00
--- /dev/null
+++ b/pipeline/src/modeling/subdivide.ts
@@ -0,0 +1,127 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file subdivide.ts — Catmull-Clark: a cage of a few polygons becomes a smooth surface.
+ *
+ * It acts on whole shells, because the new vertices on a shell's edges would
+ * leave cracks against any neighbour left out. `crease` keeps edges sharper
+ * than that angle hard, so a rounded body can keep a panel line.
+ */
+import {
+ add, collectEdges, compact, dot, edgeKey, faceCenter, faceNormal, scale, selectFaces,
+ type Face, type FaceSelector, type PolyMesh, type Vec3,
+} from './polyMesh';
+import { MAX_FACES } from './modelOps';
+
+export interface SubdivideParams {
+ faces?: FaceSelector;
+ levels?: number;
+ /** Degrees: edges sharper than this stay hard. Default none, everything rounds. */
+ crease?: number;
+}
+
+function shellsOf(mesh: PolyMesh): number[] {
+ const parent = mesh.positions.map((_, i) => i);
+ const find = (i: number): number => {
+ let at = i;
+ while (parent[at] !== at) { parent[at] = parent[parent[at]!]!; at = parent[at]!; }
+ return at;
+ };
+ for (const face of mesh.faces) for (let i = 1; i < face.v.length; i++) parent[find(face.v[i]!)] = find(face.v[0]!);
+ return mesh.faces.map((f) => find(f.v[0]!));
+}
+
+function once(mesh: PolyMesh, chosen: ReadonlySet<number>, creaseCos: number | null): { mesh: PolyMesh; chosen: Set<number> } {
+ const edges = collectEdges(mesh);
+ const facePoints = new Map<number, Vec3>();
+ const positions = mesh.positions.slice();
+ const faceIndex = new Map<number, number>();
+ for (const f of chosen) {
+ const c = faceCenter(mesh, mesh.faces[f]!);
+ facePoints.set(f, c);
+ faceIndex.set(f, positions.length);
+ positions.push(c);
+ }
+
+ // An edge is hard where it is a rim, or sharper than the crease: it then stays on its own line.
+ const hard = new Set<string>();
+ const edgePoint = new Map<string, number>();
+ for (const [key, edge] of edges) {
+ if (!edge.faces.some((f) => chosen.has(f))) continue;
+ const [pa, pb] = [mesh.positions[edge.a]!, mesh.positions[edge.b]!];
+ const mid = scale(add(pa, pb), 0.5);
+ const sharp = edge.faces.length !== 2
+ || (creaseCos !== null && dot(faceNormal(mesh, mesh.faces[edge.faces[0]!]!), faceNormal(mesh, mesh.faces[edge.faces[1]!]!)) < creaseCos);
+ if (sharp) hard.add(key);
+ const point = sharp ? mid : scale(add(add(pa, pb), add(facePoints.get(edge.faces[0]!)!, facePoints.get(edge.faces[1]!)!)), 0.25);
+ edgePoint.set(key, positions.length);
+ positions.push(point);
+ }
+
+ // Moved originals: the usual average where everything round it is smooth, along the line where it sits on one hard run, fixed at a corner.
+ const facesAt = new Map<number, number[]>();
+ const edgesAt = new Map<number, string[]>();
+ for (const f of chosen) {
+ for (const v of mesh.faces[f]!.v) {
+ const at = facesAt.get(v);
+ if (at) at.push(f); else facesAt.set(v, [f]);
+ }
+ }
+ for (const [key, edge] of edges) {
+ if (!edgePoint.has(key)) continue;
+ for (const v of [edge.a, edge.b]) {
+ const at = edgesAt.get(v);
+ if (at) at.push(key); else edgesAt.set(v, [key]);
+ }
+ }
+ for (const [v, around] of facesAt) {
+ const p = mesh.positions[v]!;
+ const keys = edgesAt.get(v)!;
+ const hardHere = keys.filter((k) => hard.has(k));
+ const midOf = (k: string): Vec3 => {
+ const e = edges.get(k)!;
+ return scale(add(mesh.positions[e.a]!, mesh.positions[e.b]!), 0.5);
+ };
+ if (hardHere.length > 2) continue;
+ if (hardHere.length === 2) {
+ positions[v] = add(scale(p, 0.5), scale(add(midOf(hardHere[0]!), midOf(hardHere[1]!)), 0.25));
+ continue;
+ }
+ if (hardHere.length === 1) continue;
+ const n = around.length;
+ let f: Vec3 = [0, 0, 0];
+ for (const g of around) f = add(f, facePoints.get(g)!);
+ let r: Vec3 = [0, 0, 0];
+ for (const k of keys) r = add(r, midOf(k));
+ positions[v] = add(add(scale(f, 1 / (n * n)), scale(r, 2 / (n * keys.length))), scale(p, (n - 3) / n));
+ }
+
+ const faces: Face[] = [];
+ const nextChosen = new Set<number>();
+ mesh.faces.forEach((face, f) => {
+ if (!chosen.has(f)) { faces.push(face); return; }
+ face.v.forEach((v, i) => {
+ const next = face.v[(i + 1) % face.v.length]!, prev = face.v[(i + face.v.length - 1) % face.v.length]!;
+ nextChosen.add(faces.length);
+ faces.push({ ...face, smooth: true, v: [v, edgePoint.get(edgeKey(v, next))!, faceIndex.get(f)!, edgePoint.get(edgeKey(prev, v))!] });
+ });
+ });
+ if (faces.length > MAX_FACES) throw new Error(`this would make ${faces.length} faces; a model holds at most ${MAX_FACES}. Use fewer levels`);
+ return { mesh: { positions, faces }, chosen: nextChosen };
+}
+
+export function subdivide(mesh: PolyMesh, p: SubdivideParams): PolyMesh {
+ const levels = p.levels ?? 2;
+ if (!Number.isInteger(levels) || levels < 1 || levels > 5) throw new Error(`levels ${levels} must be a whole number, 1..5`);
+ if (p.crease !== undefined && (p.crease <= 0 || p.crease >= 180)) throw new Error(`crease ${p.crease} must be degrees, between 0 and 180`);
+ const selector = p.faces ?? 'all';
+ const hit = selectFaces(mesh, selector);
+ if (hit.length === 0) throw new Error(`\`faces\` ${JSON.stringify(selector)} matched no face`);
+ const shells = shellsOf(mesh);
+ const wanted = new Set(hit.map((f) => shells[f]!));
+ let chosen = new Set(mesh.faces.flatMap((_, f) => (wanted.has(shells[f]!) ? [f] : [])));
+ const creaseCos = p.crease === undefined ? null : Math.cos((p.crease * Math.PI) / 180);
+ let out = mesh;
+ for (let level = 0; level < levels; level++) ({ mesh: out, chosen } = once(out, chosen, creaseCos));
+ return compact(out);
+}
diff --git a/pipeline/tests/modeling-motion-smooth.test.ts b/pipeline/tests/modeling-motion-smooth.test.ts
new file mode 100644
index 000000000..541812bdc
--- /dev/null
+++ b/pipeline/tests/modeling-motion-smooth.test.ts
@@ -0,0 +1,248 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/** Feet that land where they are told, the controller that picks a clip, and surfaces rounded off. */
+import { describe, expect, it } from 'vitest';
+import { bakeModel, controllerOf, jointPositions, timelineOf, validateModelSource, type AnimationSource, type BakedModel, type ModelStep, type RigSource } from '../src/modeling';
+
+const leg: ModelStep = { op: 'organic', resolution: 48, tag: 'leg', parts: [{ shape: 'chain', points: [[0, 2, 0, 0.15], [0, 0, 0, 0.12]] }] };
+/** A hip, a knee slightly forward, a foot: the chain a reach solves. */
+const rig: RigSource = { joints: [
+ { name: 'hips', at: [0, 2.2, 0] },
+ { name: 'thigh', at: [0, 2, 0], parent: 'hips' },
+ { name: 'shin', at: [0, 1, 0.02], parent: 'thigh' },
+ { name: 'foot', at: [0, 0, 0], parent: 'shin' },
+] };
+const bake = (animations: AnimationSource[]): BakedModel => bakeModel({ version: 1, rig, animations, steps: [leg] });
+const reach = (target: [number, number, number], extra: Record<string, unknown> = {}): AnimationSource => ({
+ name: 'r', duration: 1, loop: false, tracks: [{ joint: 'foot', reach: [[0, ...target]], ...extra }],
+});
+
+const gap = (a: readonly number[], b: readonly number[]): number => Math.hypot(a[0]! - b[0]!, a[1]! - b[1]!, a[2]! - b[2]!);
+const lengths = (p: Record<string, readonly number[]>): [number, number] => [gap(p.thigh!, p.shin!), gap(p.shin!, p.foot!)];
+
+describe('reach', () => {
+ it('puts the foot exactly where it was told, and the bones keep their lengths', () => {
+ const a = reach([0.3, 0.4, 0.5]);
+ const m = bake([a]);
+ const p = jointPositions(m.rig!.joints, a, 0);
+ expect(gap(p.foot!, [0.3, 0.4, 0.5])).toBeLessThan(1e-6);
+ const [rest1, rest2] = lengths(jointPositions(m.rig!.joints, null, 0));
+ const [now1, now2] = lengths(p);
+ expect(now1).toBeCloseTo(rest1, 5);
+ expect(now2).toBeCloseTo(rest2, 5);
+ expect(gap(p.thigh!, [0, 2, 0])).toBeLessThan(1e-6); // the hip did not move
+ });
+
+ it('the knee bends the way `pole` says', () => {
+ const forward = reach([0, 0.5, 0], { pole: [0, 0, 1] });
+ const back = { ...reach([0, 0.5, 0], { pole: [0, 0, -1] }), name: 'back' };
+ const m = bake([forward, back]);
+ expect(jointPositions(m.rig!.joints, forward, 0).shin![2]).toBeGreaterThan(0.3);
+ expect(jointPositions(m.rig!.joints, back, 0).shin![2]).toBeLessThan(-0.3);
+ });
+
+ it('without a pole it keeps bending the way it already leaned', () => {
+ const a = reach([0, 0.5, 0]);
+ const m = bake([a]);
+ expect(jointPositions(m.rig!.joints, a, 0).shin![2]).toBeGreaterThan(0.3);
+ });
+
+ it('out of reach it stretches straight toward the target and no further', () => {
+ const a = reach([0, -5, 0]);
+ const m = bake([a]);
+ const p = jointPositions(m.rig!.joints, a, 0);
+ expect(p.foot![1]).toBeCloseTo(0, 2);
+ expect(Math.abs(p.shin![2])).toBeLessThan(0.1);
+ });
+
+ it('a planted foot stays put while the hips sink, and the knee takes it up', () => {
+ const a: AnimationSource = { name: 'squat', duration: 1, loop: false, tracks: [
+ { joint: 'hips', move: [[0, 0, 0, 0], [1, 0, -0.5, 0]] },
+ { joint: 'foot', reach: [[0, 0, 0, 0], [1, 0, 0, 0]], pole: [0, 0, 1] },
+ ] };
+ const m = bake([a]);
+ for (const t of [0, 0.25, 0.5, 1]) {
+ const p = jointPositions(m.rig!.joints, a, t);
+ expect(gap(p.foot!, [0, 0, 0])).toBeLessThan(1e-5);
+ }
+ expect(jointPositions(m.rig!.joints, a, 1).shin![2]).toBeGreaterThan(jointPositions(m.rig!.joints, a, 0).shin![2]);
+ expect(jointPositions(m.rig!.joints, a, 1).thigh![1]).toBeCloseTo(1.5, 5);
+ });
+
+ it('linear slides straight between keys, where a curve would dip through the ground', () => {
+ const keys = [[0, 0, 0, 0.5], [0.5, 0, 0, -0.5], [0.75, 0, 0.3, 0]];
+ const straight: AnimationSource = { name: 'a', duration: 1, tracks: [{ joint: 'foot', reach: keys, linear: true }] };
+ const curved: AnimationSource = { name: 'b', duration: 1, tracks: [{ joint: 'foot', reach: keys }] };
+ const m = bake([straight, curved]);
+ const lowest = (a: AnimationSource): number => Math.min(...Array.from({ length: 21 }, (_, i) => jointPositions(m.rig!.joints, a, (i / 20) * 0.5).foot![1]));
+ expect(Math.abs(lowest(straight))).toBeLessThan(1e-9);
+ expect(lowest(curved)).toBeLessThan(-1e-4);
+ });
+
+ it('the clip written out lands the foot in the same place: what the preview shows is what plays', () => {
+ const a = reach([0.3, 0.4, 0.5], { pole: [0, 0, 1] });
+ const m = bake([a]);
+ const doc = timelineOf(a, m.rig!.joints) as { tracks: { name: string; channels: { property: string; keyframes: { value: number }[] }[] }[] };
+ expect(doc.tracks.map((t) => t.name)).toEqual(['thigh', 'shin', 'foot']);
+ // Recompose from the file alone: the rest offsets and the keyed rotations.
+ const q = (name: string): number[] => ['x', 'y', 'z', 'w'].map((c) => doc.tracks.find((t) => t.name === name)!.channels.find((k) => k.property === `rotation.${c}`)!.keyframes[0]!.value);
+ const rotate = (r: number[], v: number[]): number[] => {
+ const [x, y, z, w] = r as [number, number, number, number];
+ const t = [2 * (y * v[2]! - z * v[1]!), 2 * (z * v[0]! - x * v[2]!), 2 * (x * v[1]! - y * v[0]!)];
+ return [v[0]! + w * t[0]! + y * t[2]! - z * t[1]!, v[1]! + w * t[1]! + z * t[0]! - x * t[2]!, v[2]! + w * t[2]! + x * t[1]! - y * t[0]!];
+ };
+ const mul = (a: number[], b: number[]): number[] => [
+ a[3]! * b[0]! + a[0]! * b[3]! + a[1]! * b[2]! - a[2]! * b[1]!,
+ a[3]! * b[1]! - a[0]! * b[2]! + a[1]! * b[3]! + a[2]! * b[0]!,
+ a[3]! * b[2]! + a[0]! * b[1]! - a[1]! * b[0]! + a[2]! * b[3]!,
+ a[3]! * b[3]! - a[0]! * b[0]! - a[1]! * b[1]! - a[2]! * b[2]!,
+ ];
+ const hip = [0, 2, 0];
+ const knee = rotate(q('thigh'), [0, -1, 0.02]).map((v, i) => v + hip[i]!);
+ const foot = rotate(mul(q('thigh'), q('shin')), [0, -1, -0.02]).map((v, i) => v + knee[i]!);
+ expect(gap(foot, [0.3, 0.4, 0.5])).toBeLessThan(1e-4);
+ });
+
+ it('refuses a limb it cannot solve, and a rotation it would throw away', () => {
+ const anim = (tracks: unknown[]) => ({ version: 1, rig, steps: [leg], animations: [{ name: 'a', duration: 1, tracks }] });
+ expect(() => validateModelSource(anim([{ joint: 'thigh', reach: [[0, 0, 0, 0]] }]))).toThrow(/two bones above/);
+ expect(() => validateModelSource(anim([{ joint: 'foot', reach: [[0, 0, 0, 0]], move: [[0, 0, 0, 0]] }]))).toThrow(/both reach and move/);
+ expect(() => validateModelSource(anim([{ joint: 'foot', reach: [[0, 0, 0, 0]] }, { joint: 'shin', rotate: [[0, 0, 0, 0]] }]))).toThrow(/"shin" has rotate keys, but the reach on "foot" decides/);
+ expect(() => validateModelSource(anim([{ joint: 'shin', rotate: [[0, 0, 0, 0]], pole: [0, 0, 1] }]))).toThrow(/goes with reach/);
+ });
+});
+
+describe('controller', () => {
+ const clip = (name: string): AnimationSource => ({ name, duration: 1, tracks: [{ joint: 'shin', rotate: [[0, 0, 0, 10]] }] });
+ const animations = [clip('idle'), clip('walk'), { ...clip('hit'), loop: false }];
+ const controller = {
+ parameters: [{ name: 'speed', type: 'float', default: 0 }, { name: 'hurt', type: 'trigger' }, { name: 'down', type: 'bool' }],
+ initial: 'move',
+ states: [
+ { name: 'move', blend: { parameter: 'speed', stops: [{ value: 0, clip: 'idle' }, { value: 0.5, clip: 'walk' }] } },
+ { name: 'flinch', clip: 'hit', speed: 2, transitions: [{ to: 'move', afterClip: true, blend: 0.2 }] },
+ ],
+ any: [{ to: 'flinch', when: [{ param: 'hurt', op: 'trigger' }], blend: 0.1 }],
+ } as const;
+ const source = (c: unknown, a: unknown = animations) => ({ version: 1, rig, animations: a, controller: c, steps: [leg] });
+
+ it('accepts one that hangs together and writes what the engine reads', () => {
+ validateModelSource(source(controller));
+ const doc = controllerOf(controller as never, animations, (n) => `F_${n}.estimeline`) as { version: number; initialState: string; anyStateTransitions: { conditions: unknown[]; duration: number }[]; states: { motion: Record<string, unknown>; transitions: Record<string, unknown>[] }[] };
+ expect(doc.version).toBe(2);
+ expect(doc.initialState).toBe('move');
+ expect(doc.states[0]!.motion).toMatchObject({ kind: 'blend1d', parameter: 'speed' });
+ expect((doc.states[0]!.motion.thresholds as { motion: { clip: string } }[])[1]!.motion.clip).toBe('F_walk.estimeline');
+ expect(doc.states[1]!.motion).toEqual({ kind: 'timeline', clip: 'F_hit.estimeline', loop: false, speed: 2 });
+ expect(doc.states[1]!.transitions[0]).toEqual({ to: 'move', conditions: [], duration: 0.2, hasExitTime: true });
+ expect(doc.anyStateTransitions[0]).toEqual({ to: 'flinch', conditions: [{ param: 'hurt', op: 'trigger' }], duration: 0.1 });
+ });
+
+ it('refuses what would not run, naming it', () => {
+ const state = (s: unknown) => ({ initial: 'a', parameters: [{ name: 'speed', type: 'float' }, { name: 'go', type: 'bool' }], states: [s] });
+ expect(() => validateModelSource(source(controller, []))).toThrow(/this source has none/);
+ expect(() => validateModelSource(source({ ...controller, initial: 'nope' }))).toThrow(/initial "nope" is not a state/);
+ expect(() => validateModelSource(source(state({ name: 'a', clip: 'fly' })))).toThrow(/plays "fly", which is not an animation; there are idle, walk, hit/);
+ expect(() => validateModelSource(source(state({ name: 'a' })))).toThrow(/exactly one of clip, blend/);
+ expect(() => validateModelSource(source(state({ name: 'a', clip: 'idle', transitions: [{ to: 'b' }] })))).toThrow(/goes to "b", which is not a state/);
+ expect(() => validateModelSource(source(state({ name: 'a', clip: 'idle', transitions: [{ to: 'a', when: [{ param: 'nope', op: 'true' }] }] })))).toThrow(/reads "nope", which is not a parameter/);
+ expect(() => validateModelSource(source(state({ name: 'a', clip: 'idle', transitions: [{ to: 'a', when: [{ param: 'speed', op: 'true' }] }] })))).toThrow(/true reads a bool/);
+ expect(() => validateModelSource(source(state({ name: 'a', clip: 'idle', transitions: [{ to: 'a', when: [{ param: 'go', op: 'gt', value: 1 }] }] })))).toThrow(/gt compares a float/);
+ expect(() => validateModelSource(source(state({ name: 'a', blend: { parameter: 'go', stops: [{ value: 0, clip: 'idle' }] } })))).toThrow(/chosen by a float parameter/);
+ });
+});
+
+const closed = (m: BakedModel): void => {
+ expect(m.report.openEdges).toBe(0);
+ expect(m.report.nonManifoldEdges).toBe(0);
+ expect(m.report.flippedEdges).toBe(0);
+ expect(m.report.insideOutShells).toBe(0);
+};
+function volume(m: BakedModel): number {
+ let v = 0;
+ for (const { v: [a, b, c] } of m.triangles) {
+ const [p, q, r] = [m.poly.positions[a]!, m.poly.positions[b]!, m.poly.positions[c]!];
+ v += p[0] * (q[1] * r[2] - q[2] * r[1]) + p[1] * (q[2] * r[0] - q[0] * r[2]) + p[2] * (q[0] * r[1] - q[1] * r[0]);
+ }
+ return v / 6;
+}
+const model = (...steps: ModelStep[]): BakedModel => bakeModel({ version: 1, steps });
+
+describe('subdivide', () => {
+ it('rounds a cube toward its limit: inside the cage, closed, and getting there', () => {
+ const levels = [1, 2, 3].map((n) => model({ op: 'box', size: 2 }, { op: 'subdivide', levels: n }));
+ for (const m of levels) closed(m);
+ expect(levels[0]!.report.faces).toBe(24);
+ expect(levels[1]!.report.faces).toBe(96);
+ const v = levels.map(volume);
+ expect(v[0]!).toBeLessThan(8);
+ expect(v[1]!).toBeLessThan(v[0]!);
+ expect(v[0]! - v[1]!).toBeGreaterThan(v[1]! - v[2]!);
+ const radii = levels[2]!.poly.positions.map((p) => Math.hypot(p[0], p[1], p[2]));
+ expect(Math.max(...radii) / Math.min(...radii)).toBeLessThan(1.25); // nearly a ball
+ expect(Math.max(...radii)).toBeLessThan(Math.sqrt(3));
+ });
+
+ it('is shaded smooth', () => {
+ const m = model({ op: 'box', size: 2 }, { op: 'subdivide', levels: 2 });
+ expect(m.poly.faces.every((f) => f.smooth)).toBe(true);
+ expect(m.data.vertexCount).toBeLessThan(m.report.faces * 2.6);
+ });
+
+ it('crease keeps sharp edges on their line', () => {
+ const m = model({ op: 'box', size: 2 }, { op: 'subdivide', levels: 2, crease: 45 });
+ closed(m);
+ expect(volume(m)).toBeCloseTo(8, 5); // every cube edge is sharper than 45, so nothing moves
+ });
+
+ it('acts on whole shells, leaving the rest', () => {
+ const m = model({ op: 'box', size: 1, tag: 'a' }, { op: 'box', size: 1, at: [5, 0, 0], tag: 'b' }, { op: 'subdivide', faces: { tag: 'a', facing: '+y' }, levels: 1 });
+ closed(m);
+ expect(m.report.tags.a).toBe(24);
+ expect(m.report.tags.b).toBe(6);
+ });
+
+ it('keeps tags and colour', () => {
+ const m = model({ op: 'box', size: 1, tag: 'a', color: [1, 0, 0] }, { op: 'subdivide', levels: 1 });
+ expect(m.poly.faces.every((f) => f.tag === 'a' && f.color![0] === 1)).toBe(true);
+ });
+
+ it('holds on a prism and after an extrude', () => {
+ closed(model({ op: 'box', size: 1 }, { op: 'extrude', faces: '+y', distance: 1 }, { op: 'subdivide', levels: 2 }));
+ closed(model({ op: 'prism', points: [[0, 0], [2, 0], [2, 1], [1, 1], [1, 2], [0, 2]], height: 1 }, { op: 'subdivide', levels: 1 }));
+ });
+
+ it('refuses what it cannot do', () => {
+ expect(() => model({ op: 'box', size: 1 }, { op: 'subdivide', levels: 9 })).toThrow(/levels 9/);
+ expect(() => model({ op: 'box', size: 1 }, { op: 'subdivide', crease: 200 })).toThrow(/crease 200/);
+ expect(() => model({ op: 'box', size: 1 }, { op: 'subdivide', faces: 'nope' })).toThrow(/matched no face/);
+ });
+});
+
+describe('a rounded bevel', () => {
+ const chamfered = volume(model({ op: 'box', size: 2 }, { op: 'bevel', edges: 'all', width: 0.3 }));
+ const rounded = (round: number): BakedModel => model({ op: 'box', size: 2 }, { op: 'bevel', edges: 'all', width: 0.3, round });
+
+ it('stays closed at every level', () => {
+ for (const n of [1, 2, 3]) closed(rounded(n));
+ });
+
+ it('takes less off than a chamfer does, each pass adding faces', () => {
+ expect(rounded(1).report.faces).toBeGreaterThan(26);
+ expect(rounded(2).report.faces).toBeGreaterThan(rounded(1).report.faces);
+ // Corners cut again come off a chamfered body, so each pass is a little smaller, and all stay within the cube.
+ expect(volume(rounded(1))).toBeLessThan(chamfered);
+ expect(volume(rounded(2))).toBeLessThan(volume(rounded(1)));
+ expect(volume(rounded(3))).toBeGreaterThan(8 * 0.8);
+ });
+
+ it('rounds one edge, and leaves the box flat elsewhere', () => {
+ const m = model({ op: 'box', size: 2 }, { op: 'bevel', edges: { between: ['+y', '+z'] }, width: 0.3, round: 2 });
+ closed(m);
+ expect(m.report.bounds.size).toEqual([2, 2, 2]);
+ });
+
+ it('refuses a level past what it can do', () => {
+ expect(() => model({ op: 'box', size: 2 }, { op: 'bevel', edges: 'all', width: 0.3, round: 9 })).toThrow(/round 9/);
+ });
+});
diff --git a/pipeline/tests/modeling-rig.test.ts b/pipeline/tests/modeling-rig.test.ts
index 199c21893..b98d4a194 100644
--- a/pipeline/tests/modeling-rig.test.ts
+++ b/pipeline/tests/modeling-rig.test.ts
@@ -269,7 +269,7 @@ describe('refusals name what to change', () => {
const anim = (tracks: unknown[], extra = {}) => source({ rig, animations: [{ name: 'a', duration: 1, tracks, ...extra }] });
expect(() => validateModelSource(source({ animations: [] }))).toThrow(/no rig/);
expect(() => validateModelSource(anim([{ joint: 'elbow', rotate: [[0, 0, 0, 0]] }]))).toThrow(/no joint "elbow"; there are base, mid, tip/);
- expect(() => validateModelSource(anim([{ joint: 'mid' }]))).toThrow(/neither rotate nor move/);
+ expect(() => validateModelSource(anim([{ joint: 'mid' }]))).toThrow(/none of rotate, move, reach/);
expect(() => validateModelSource(anim([{ joint: 'mid', rotate: [[2, 0, 0, 0]] }]))).toThrow(/time 2 is outside/);
expect(() => validateModelSource(anim([{ joint: 'mid', rotate: [[0.5, 0, 0, 0], [0.2, 0, 0, 0]] }]))).toThrow(/time order/);
expect(() => validateModelSource(anim([{ joint: 'mid', rotate: [[0, 0, 0]] }]))).toThrow(/every key is \[time, x, y, z\]/);
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index ffecd8d1b..e2e62fe65 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -3866,6 +3866,10 @@ export const NOTED = {
{"note":"A sea seen from above is no longer scored with straight lines."},
"feat(mcp): an agent builds a 3D model in the editor from steps, changes it by one number, and sees every side of it":
{"note":"AI agents can build 3D models in the editor from steps."},
+ "feat(modeling): a foot can be told where to land, a controller says which clip plays when, and surfaces can be subdivided and edges rounded":
+ {"note":"AI agents can build 3D models in the editor from steps."},
+ "feat(mcp): model_write plants feet, writes an animator, subdivides and rounds":
+ {"note":"AI agents can build 3D models in the editor from steps."},
"feat(modeling): a model can have a rig with weights found over its surface, and clips of a few keys, so what an agent builds can move":
{"note":"AI agents can build 3D models in the editor from steps."},
"feat(mcp): model_write rigs and animates a model, and model_views shows the bones, the weights and a clip through time":