Animation and skinning
Purpose
Section titled “Purpose”Keyframe animation of any node property and skeletal animation of 3D characters (G1a, G1b; ADRs 0207, 0208, 0244):
Animations with transform, value, bezier, method, audio and event tracks, played by an AnimationPlayer with
crossfades, queues, signals and root motion (ADR 0210) that a CharacterBody3D applies; Skeleton3D bones, skinned
MeshInstance3Ds drawn through a compute pre-skinning pass and BoneAttachment3D; skinned glTF/FBX characters import
with their clips; and the editor’s Animation panel, a timeline that keys, previews and edits animations. Names
follow Godot 4. The authoring tools for Claude-made clips are Animation authoring
(G1e shipped: root motion).
flowchart LR
I["ModelImporter (Assimp)<br/>bones · skins · clips · .mfmeta / glTF extras"] --> S[Skeleton3D]
I --> M["MeshInstance3D + Skin<br/>(Joints/Weights)"]
I --> P["AnimationPlayer<br/>AnimationLibrary → Animation"]
P -->|"bone poses (typed calls)"| S
P -->|"values: PropertyBinding (typed, no boxing)"| V[Node properties]
P -->|"method keys: generated invokers"| V
P -->|"audio keys"| U["AudioPlayer / 2D / 3D"]
P -->|"AnimationEvent / Finished / Changed"| G[Game code, also headless]
P -->|"root motion per update"| B["CharacterBody3D.ApplyRootMotion → MoveAndSlide"]
S --> A[BoneAttachment3D children]
S --> K["SkinState: palette + posed bounds"]
M --> K
K --> C["RenderServer.SkinMeshes<br/>Skin.vk.comp per instance"]
C --> D["Every mesh pipeline draws the skinned buffer<br/>(lit, shadows, outline, ids, prepass)"]
Code: Src/Animation/ (Animation, tracks, AnimationLibrary,
AnimationPlayer, AnimationValueOps/PropertyBinding, AnimationMethodAttribute), Scene/Nodes3D/Skeleton3D.cs,
Skin.cs (Skin, SkinState),
BoneAttachment3D.cs,
Rendering/Meshes/MeshSkinning.cs (MeshSkinner,
SkinnedMeshGpu), Assets/Shaders/Skinning/Skin.vk.comp.slang,
Resources/Import/ModelAnimationImport.cs.
Skeletons, skins and attachments
Section titled “Skeletons, skins and attachments”Skeleton3D(aNode3D):BoneNames,BoneParents(−1 for roots, parents before children) andBoneRests(relative to the parent) are what a scene saves. Poses (SetBonePosePosition/Rotation/Scale,SetBonePose,ResetBonePoses) start at the rests and are not saved.GetBoneGlobalPose(skeleton space) recomputes the global poses once after a change, parents first.FindBonetakes a span (no allocation);AddBonebuilds skeletons in code. A pose change inside a tree queues one deferred update per frame (a static callback, no allocation), which moves the attachments and raisesSkeletonUpdated;ForceUpdatePosedoes it now.Skin(resource):BindNames(the bone of each joint, matched by name; re-matched when the bones change) andBindPoses(inverse bind matrices, mesh space → bone space). Without a skin, jointiis boneibound at its rest. At mostSkin.MaxJoints(256) joints.- Skinned surfaces:
MeshSurface.Joints(four per vertex) andWeights(oneVector4per vertex, summing to 1; all-zero weights leave a vertex unskinned, so a mesh can mix skinned and static surfaces).Mesh.IsSkinned. MeshInstance3D.Skeleton(default.., Godot’s) andSkin.GetSkeleton()returns the skeleton a skinned mesh follows; without one it draws its bind pose (the editor warns).BoneAttachment3D, a child of the skeleton, sets its transform toBoneName’s skeleton-space pose whenever the pose changes: put a tool, a hat or a light under it. Its own transform is overwritten.- Ragdolls: a
PhysicalBoneSimulator3Dchild withPhysicalBone3Dbodies follows the animation and, once simulated, writes the bones’ poses after theAnimationPlayer(ADR 0212, Physics joints → Ragdolls); the editor’s Skeleton3D inspector creates one. Active ragdolls (G9.10c, ADR 0235) pull the simulated bodies towards the animated pose with drives and holds, so the character keeps its pose under physics (Active ragdolls).
AnimationPlayer
Section titled “AnimationPlayer”Animation (resource; name = ResourceName): Length, LoopMode (None, Linear, PingPong), Step (the
editor’s snap, 1/30 s) and Tracks. Every track has Path (from the player’s RootNode), Enabled and ascending
Times in seconds; values are parallel arrays:
| Track | Target | Values |
|---|---|---|
Position3DTrack, Rotation3DTrack, Scale3DTrack | a Node3D, or a Skeleton3D bone with Bone | Vector3[]/Quaternion[] |
ValueTrack | any animatable [Export] property: Property = "Energy", "Position", "Position:y", "Modulate:a" | Components floats per key; Update Continuous or Discrete (only the key’s value, as the playhead reaches it) |
BezierTrack | one float property (or component) | Values + per-key InHandles/OutHandles (time, value offsets): the cubic Bézier through the keys, solved for time |
MethodTrack | a node’s [AnimationMethod] methods | Methods (a name per key) + Arguments (a JSON array per key, [], [2, "open"]) |
AudioTrack | an AudioPlayer, AudioPlayer2D or AudioPlayer3D | Streams + StartOffsets (seconds into the stream) |
EventTrack | — | Names: raised as AnimationEvent(animation, name) |
The transform and value tracks are InterpolatedTracks: Interpolation Nearest, Linear (rotations slerp, shortest
arc) or Cubic (Godot’s cubic in time through the neighbouring keys, spherical for rotations; a missing neighbour is
mirrored, so the ends do not overshoot), per-key Transitions (Godot’s easing exponent, Mathf.Ease: 1 linear, above 1
ease in, below 1 ease out, negative in-out) and LoopWrap (on a looping animation the last key blends into the first;
off, the value holds). Bools, integers and enums are always discrete.
Bindings. A value track binds once per animation through the property’s generated registration:
PropertyBinding.Create(node, "Position:y") returns a typed PropertyBinding<TOwner, TValue> over the setter, and
AnimationValueOps.Get<T>() packs and unpacks the value as floats (floats, doubles, integers, bools and enums directly;
vectors, quaternions, both colour types, Vector2I, rects and any game [SerializableValue] struct with a float-array
codec through IFloatVectorCodec<T>). A :x/:y/:z/:w (or :r/:g/:b/:a) suffix animates one component and
leaves the rest. No reflection and no boxing: writes allocate nothing. An unknown property or type is logged once at bind
time and the track skipped.
Method tracks. [AnimationMethod] on an instance method (public or internal, non-generic, by-value parameters of
types [Export] supports, resources excepted) makes the source generator emit a typed invoker and a codec per parameter
(NodeTypeInfo.AnimationMethods, FindAnimationMethod); anything else is error MFG011. The key’s JSON arguments are
parsed once at bind time (missing trailing arguments take their defaults), so calls allocate nothing. The engine marks
Play/Stop on the audio players and Restart on the particle nodes. CallbackModeMethod is Deferred (after the
update’s values are applied, in key order; default) or Immediate (as the playhead passes the key).
Audio tracks start the key’s stream on the target player at the key’s offset (a key crossed late starts that far in) and stop it when the animation stops.
AnimationLibrary is a list of animations; its ResourceName prefixes them ("" the default library,
"moves/roll"). AnimationPlayer (Godot’s API):
Play(name = "", customBlend = -1, customSpeed = 1, fromEnd = false),PlayBackwards,Pause,Stop(keepState),Seek(seconds, update),Queue/ClearQueue,Advance(delta);Autoplay,SpeedScale,PlaybackDefaultBlendTime,RootNode(default..),Active,CallbackModeProcess(Idle:OnProcess;Physics: the fixed step;Manual: onlyAdvance).CurrentAnimation(""when not playing),AssignedAnimation,CurrentAnimationPosition,CurrentAnimationLength,IsPlaying(),IsBlending,GetPlayingSpeed(). Fit a clip to a gameplay duration withPlay(name, customSpeed: (float)(length / seconds))orSpeedScale.- Playing the animation that is playing (or paused) continues it; a finished one restarts.
BlendTimes:AnimationBlendTimeentries (From,To,Seconds) override the default crossfade per pair (Godot’s blend times).GetSyncState()/ApplySyncState(state): the current animation, position and playing flag for a late-joining peer.- Signals:
AnimationStarted(name),AnimationFinished(name)(non-looping only),AnimationChanged(old, new)(a queued animation took over),AnimationEvent(animation, event). - Events, method and audio keys fire when the playhead passes their key, in play direction, across loop wraps (once per ping-pong pass);
the first frame of a play includes keys at the start;
Seekraises none. Events are collected while the pose is evaluated and raised after it is applied, so handlers can callPlay. - Crossfade:
Playwith a blend (custom, elsePlaybackDefaultBlendTime) keeps the old animation advancing and mixes per channel (transforms and values; discrete values switch at half the blend): both → lerp/slerp by the blend weight; only the new one → its value; only the old one → toward the bone’s rest (a node: its value when the blend started). APlayduring a blend starts a new one from the pose as it is at that moment (captured, held still). - Binding happens once per animation (first play, or after its
Versionchanged): paths and bone names resolve to slots shared by every animation of the player. Each frame finds the key from a per-track cursor, interpolates and calls the typed setter. Steady playback, crossfades, events, value tracks and method keys allocate nothing (AnimationHeadlessTests,ValueTrackTests’ 1 000-node gate;AnimationBenchmarks). - Physics bodies: animate an
AnimatableBody3D/2DwithCallbackModeProcess = Physics; its motion becomes a velocity for the step and characters standing on it ride along (Paths → Moving platforms). The editor warns about aStaticBody3Dmoved by a track (it teleports) and a body animated outside the physics callback. - Determinism and servers: the pose and the events depend only on (clip, time), so peers that start clips from
replicated state agree; nothing needs a renderer, so animations and events run under
HeadlessHosttoo.
Root motion
Section titled “Root motion”Clips that travel (a walk covering ground, a leap, a turn) move a character body instead of sliding away from it
(ADR 0210, Godot’s root_motion_track):
AnimationPlayer.RootMotionTrack(aNodePathto theSkeleton3D, relative toRootNode; empty: off),RootMotionBone(empty: the skeleton’s first root bone) andRootMotionVertical(default false). A rig with a bone above the hips (Unreal’sroot) uses that bone; one whose hips are the top bone (Mixamo, Blender rigs) uses the hips. The bone’s pose is read relative to its parent.- Taken out of the pose: the bone’s horizontal position and its yaw (the twist about its parent’s +Y), relative to
its rest; vertical position too with
RootMotionVertical. Everything else stays: the hips keep their rest position horizontally and their rest facing, while a crouch or a jump’s arc still moves them up and down. - Reported per update:
GetRootMotionPosition()(skeleton space, in the facing the character had at the start of the update) andGetRootMotionRotation()(a turn about the skeleton’s +Y). Each update replaces them (zero when nothing played), so read them once per update. A body that moves by the position and then turns by the rotation retraces the clip’s path. - Loops, direction, crossfades: the update is split into stretches of clip time without a wrap (the same stretches
that raise events), each adding
value(to) − value(from); a loop wrap therefore adds the clip’s whole displacement (a stretch over the whole clip adds its whole turn, the sum of its key-to-key turns, so a clip turning 360° loops right), and backwards or ping-pong play subtracts. Crossfades lerp the two clips’ motion by the blend weight; a clip without root tracks contributes none.Play,Seekand clip switches never jump: nothing depends on the previous update’s sample. Turns per update must stay under half a circle. CharacterBody3D.ApplyRootMotion(player)turns the motion into world space with the skeleton’s global basis (its scale included), setsVelocityso the nextMoveAndSlidecovers it in one step (only the horizontal part withoutRootMotionVertical, so the game’s gravity still applies) and turns the body by the yaw now:
public sealed class Walker : CharacterBody3D{ private AnimationPlayer? _player; // CallbackModeProcess = Physics, RootMotionTrack = "Armature", RootMotionBone = "Hips"
protected override void OnReady() => _player = GetNode<AnimationPlayer>("Model/AnimationPlayer");
protected override void OnPhysicsProcess(float delta) { if (_player is not null) ApplyRootMotion(_player); Velocity -= UpDirection * (9.81f * delta); MoveAndSlide(); }}- The player should run in the
Physicscallback mode, one motion per physics step (the editor warns otherwise). A body that processes before its player (its parent) moves by the previous step’s motion: one step late, nothing lost. - Steady root motion with crossfades and
MoveAndSlideallocates nothing; the motion depends only on clip time and the fixed step, so it is deterministic and runs underHeadlessHost.
GPU skinning: compute pre-skinning
Section titled “GPU skinning: compute pre-skinning”sequenceDiagram
participant RS as RenderServer
participant MR as MeshRenderer
participant SK as MeshSkinner
participant G as GPU
RS->>MR: PrepareFrame: Prepare(view) per view
MR->>MR: skinned node: PrepareSkin (palette + posed bounds, once per frame), per-instance MeshGpu view, queue
RS->>RS: BeginFrame
RS->>SK: SkinMeshes → Dispatch(cb)
SK->>G: barrier (vertex input → compute), palettes into the slot's ring, Skin.vk.comp per instance
SK->>G: barrier (compute write → vertex attribute read)
RS->>G: shadows, offscreen views and picking, prepass, scene pass: the skinned buffers as plain vertices
- Per instance (
SkinnedMeshGpu): oneMeshVertexbuffer per frame slot (vertex + storage usage, device-local), a descriptor set per slot (source, palette, output), and aMeshGpuview that uses the slot’s output as its vertices and the shared mesh’s indices, colour/wind streams and surface ranges. Draw lists, shadow casters and picking hold the view, so the lit, unshaded, outline (MaterialOverlay/NextPass), object-ID, shadow (CSM, atlas, point cubes) and sub-viewport pipelines draw the pose unchanged, as will spatial shader materials. Skinned instances are not batched together (each has its own buffer). - Per mesh (
MeshGpu.SkinSource): a storage buffer ofSkinVertex(64 B: bind position and normal with the UV inw, four joints, four weights), uploaded with the mesh. - Palette:
SkinState.Updatebuildsinverse bind × bone global pose × skeleton → meshper joint (row vectors) and the posed bounds (per-joint bind-space boxes transformed by the pose, merged: O(joints));MeshSkinnerwrites three float4 rows per joint into a host-visible ring perFrameSlot(grown by doubling), the shader indexes it with a push-constant base. - Frame order:
RenderServer.SkinMeshes()runs right afterBeginFrame, beforeOnShadowPass; the upload queue’s buffer barrier includes the compute stage, so a mesh uploaded this frame is ready. - Motion vectors (ADR 0163): the prepass draws skinned surfaces with
Mesh/MeshDepthSkinned.vk.vert, which reads last frame’s skinned vertices at binding 5 (the previous slot’s buffer; this frame’s when the instance was not skinned then), so limbs get their own velocity for TAA and motion blur. - Cost: 32 B × vertices × 2 slots per instance, one dispatch per instance. 12 characters of ~6 000 triangles (and up
to 192 in a sweep) run at the 120 Hz display cap on an M5 in Release (
skinned-crowd).
Import
Section titled “Import”ModelImporter (Assimp; Asset pipeline) turns rigs into the nodes above (ADR 0208):
- Bones are the nodes a mesh’s bones name, the nodes between them and their common ancestor, and mesh-less subtrees
under them. The ancestor’s parent (Blender’s armature node) becomes the
Skeleton3D; bone nodes leave the node tree; other nodes under bones becomeBoneAttachment3Ds. - Skinned meshes move under the skeleton (identity transform,
Skeleton = "..") with aSkinof their bones’ offset matrices; four weights per vertex (LimitBoneWeights), normalised. FBX pivots are not preserved. - Clips become
Animations named after the actions (Blender’sArmature|prefix removed) in anAnimationLibraryon anAnimationPlayerchild of the model root. Channels that never leave their rest are dropped; withoptimizeAnimations(default) keys that linear interpolation reproduces are removed. - Loop modes and events: a
-loop/-cyclename suffix loops a clip; glTF animationextras("loop": true,"events": { "HammerFist": 0.42 }or[ { "name": …, "time": … } ]; Blender writes an action’s custom properties there with Include → Custom Properties) override it; the.mfmetaclipslist overrides both and covers FBX:
{ "importer": "model", "settings": { "scale": 1, "importAnimations": true, "optimizeAnimations": true, "clips": [ { "name": "run", "loop": "Linear" }, { "name": "swing", "events": [ { "name": "HammerFist", "time": 0.4 } ] }, { "name": "Jump", "rename": "jump_start" } ] } }- The importer’s
scaleapplies to the model root, so skeletons, skins and clips scale with it. - Silk.NET’s key structs are larger than the bundled Assimp’s (
mInterpolation); the importer detects the native key stride from the key times and reads through it.
Editor
Section titled “Editor”The nodes and resources are registered like any other: inspector rows for every [Export] (bone arrays, the skin,
libraries), icons (bone for Skeleton3D/Skin, link for BoneAttachment3D, player-play for AnimationPlayer,
movie for Animation), semantic property icons (BoneName, Libraries, SpeedScale, LoopMode), and node warnings
for a skinned mesh without its skeleton, an attachment outside a skeleton or naming no bone, a player without
animations, root motion that is not on the physics step or names no skeleton or bone (RootMotionTrack has the
run icon, RootMotionBone bone, RootMotionVertical arrow-up), and transform tracks that move a StaticBody3D
or a body outside the physics callback. Skinned meshes draw (and pick) posed in the editor’s views.
Animation panel
Section titled “Animation panel”
Selecting an AnimationPlayer adds an Animation tab to the bottom dock (Output | Profiler | Tile Map | Animation);
the pin keeps the panel on that player while other nodes are selected for keying. Code:
MainframeEngine.Editor/Src/Animation/ (AnimationEditor the model,
AnimationPanel the RmlUi panel over Assets/Editor/animation.rml, AnimationTimelineCanvas), the undo actions in
Undo/AnimationActions.cs, the shared timeline in Src/Timeline/.
- Header (icon buttons with tooltips): play from start, play/pause, stop, the playhead; the animation picker, new (into the player’s default library, created when missing), duplicate, rename, delete; length − / +, loop mode (one button cycling none / linear / ping-pong), snap to the step, frames on the ruler; add a method track or an audio track for the selected node; zoom; pin.
- Track list: a row per track with its kind’s icon and
path · property, and buttons for interpolation (nearest / linear / cubic), loop wrap, enable and remove. - Timeline: the seconds (or frames) ruler (click or drag to scrub), keys as diamonds (selected blue), method keys
labelled, audio keys as clips, the area past the length shaded. Click selects (Shift/Cmd adds), drag moves keys
(snapped), drag on empty space draws a rubber band, double-click a row inserts a key: the current value, the audio
player’s stream, or a method picked from the node’s
[AnimationMethod]s. Wheel scrolls, Cmd/Ctrl+wheel zooms around the mouse. Delete removes the selected keys; K keys the selected 3D nodes’ transforms. - Key row: the selected key’s time, its value per component (X/Y/Z coloured) and its easing.
- Inspector key buttons: while an animation is edited, every animatable inspector row gets a
keybutton that inserts the current value at the playhead, creating the track:Position/RotationDegrees/Scaleof aNode3Dmake transform tracks, other rows value tracks. - Preview: the scene is in edit mode, so the player does not process; the panel poses it with
Seek(t, update: true)(scrub) or each frame while playing (looping by the loop mode). Method and audio keys do not fire in the editor. Before the first preview the panel records the values the animation touches and puts them back on Stop, when the edited player changes, and around every save, so saved scenes hold authored values, never a preview frame (Godot’sRESETanimation is not needed). - Instanced models (G1.18): selecting an instance (an imported model, a sub-scene) whose scene has an
AnimationPlayershows that player in the panel read-only (a lock and the scene’s name in the header): its clips, baked ones from linked libraries included, play, scrub and loop, and nothing is edited (no history, no key buttons, the edit controls hidden). They belong to the model and its libraries: change them withmfe anim bakeor by opening the scene. When a library changes on disk (Editor → Files changed on disk) a running preview restarts from its time on the new keys. - Undo: every edit (keys, tracks, animation settings, library changes) is one step in the scene tab’s history
(
AnimationEditActionsnapshots the animation’s tracks,AnimationLibraryActionthe library); a key drag is one step, Esc cancels it.
The timeline component is shared with the song editor: TimelineZoom (scroll, pixels per unit, X/TimeAt,
ZoomAround), TimelineSnap, TimelineRuler (adaptive steps, cached labels), TimelineHost.Place (sizes the canvas
SubViewport and publishes it) and TimelineCanvasBase (ruler, shaded regions, playhead).
Humanoid map (G1c)
Section titled “Humanoid map (G1c)”The first step of animation authoring (G1.12, ADR 0281), in
MainframeEngine/Src/Animation/Humanoid/. It describes any humanoid Skeleton3D in one canonical space, so later steps
(the pose baker, mfe anim describe, checks, the editor’s sliders) speak one set of angles on every rig.
- Canonical space: Y up, +Z forward, +X the character’s left; the canonical T-pose is the reference.
HumanoidBoneis VRM 1.0’s humanoid set (55 bones);HumanoidBonesgives each one’s parent, side, mirror, direction and joint axes, and which are required (hips, spine, head, and per side the three leg and three arm bones; VRM’s set). - Angles:
JointAngles(Flex,Abduct,Twist, degrees), composed intrinsically twist → abduct → flex about the bone’s joint axes; right-side axes mirror the left ones, so equal numbers are equal motions on both sides; hinges (lower legs, lower arms) flex only.HipsPoseis an offset in metres plus yaw/pitch/roll.HumanoidPoseholds a whole body;HumanoidLimitsthe range of every component;HumanoidPosesthe named poses (tpose,stand,rest). HumanoidMap.Detect(skeleton, overrides, out report): names first (prefixes such asmixamorig:,DEF-andJ_Bip_?_stripped, side tokens split off, tables for VRM/VRoid, Mixamo, Unreal, Blender/Rigify and generic names; numbered spines become Spine/Chest/UpperChest by depth; twist, IK, roll and end bones are skipped), then the skeleton’s shape for what names miss (the hips have two similar chains down and one up; the arms branch where two similar chains go sideways), then the.mfmetahumanoidoverrides (Asset pipeline). TheHumanoidMapReportlists each entry’s source and confidence, unmapped rig bones, missing required bones and notes.HumanoidRig(skeleton, map): binds a map to the rest pose. The character frame comes from the rest (ankles to hips is up, right to left upper leg is left), so rigs facing any way, in any unit, map the same. Upper and lower legs and arms are straightened to the T-pose by a shortest-arc rest correction (an A-pose rig takes the same angles as a T-pose rig); every other bone keeps its rest relation to its parent, so feet stay flat and the torso keeps its posture.ToBoneRotation/FromBoneRotationconvert one bone;ApplyPose/ReadPosea whole body (canonical bones the rig lacks pass their rotation on to the next mapped bone);RestKind(T, A, other),RestArmAngle,Proportions(metres) andMetresPerUnitdescribe the rig.- Singularity: at abduct ±90° (an arm straight up from the T-pose) twist and flex share an axis; reading the angles back then gives twist 0.
Pose scripts and baking (G1c)
Section titled “Pose scripts and baking (G1c)”G1.13 (animation authoring), in MainframeEngine/Src/Animation/Authoring/.
A pose script is JSON: a few key poses in canonical angles, IK pins, arcs and a root mode; PoseScriptParser.Parse
reads it (every error with its JSON path, unknown properties rejected) and PoseBaker.Bake turns it into an ordinary
Animation. Scripts are input only: the keys are the truth.
- Keys:
t, a namedpose(the first key needs one; later keys start from the previous key),hips(x/y/z/yaw/pitch/roll),joints(any offlex/abduct/twistper bone; hinges flex only),mirror(left to right, or right to left where only the right is given),ik("pin","release",{ "pos": [x, y, z] }in character space,{ "pos": [...], "pin": true }: reach it, the foot or hand put down as at rest unless the key gives its angles, and hold it like a pin; G1.19, for landings on exact spots) andease(linear,in,out,inOutor a number: theTransitionsvalue of the segment after the key). - Root:
inPlace(default) keeps the keys’ hips offsets and ignores arcs, with a note;motionkeeps horizontal offsets and adds arcs, for root motion withRootMotionBone= the hips (PoseBakeResult.HipsBone). - Arcs add
4k·u(1−u)to the keyed hips height betweenfromandto:k = g·T²/8from the project’s gravity, or solved so the apex isheightabove take-off (a note when that is more than 25 % off gravity’s apex). - IK (
TwoBoneIk): the knee or elbow stays in the plane of the hip or shoulder, the target and the pole (knees forward, elbows back, turned with the upper bone’s current pose), each bone turns by the shortest arc so the authored twist is kept, a target out of reach straightens the limb towards it (noted). A pin holds the effector’s position and rotation from its key through itsreleasekey (the effector leaves its spot after that key; G1.15’s checks found the legs snapping straight when the release key dropped the pin first). - Keys written: at the script’s times, a cubic
Rotation3DTrackper mapped bone that leaves its rest (and every IK chain bone), aPosition3DTrackfor the hips; quaternions kept in one hemisphere. A 60 Hz pass then samples the clip as played (ClipSampler) and adds a key to the IK chain (or the hips) at the worst sample where a pin slides or an arc misses by more than 1 cm, until none does; a pin out of reach is noted rather than chased. Animation.BakedHashisAnimationHash.Computeof the keys written.PoseLibrary.Writeputs the clip into a library.mfres(created as the default library) and replaces a clip of that name only when it is an untouched bake, or when told to (replace), so hand fixes are never overwritten by accident; it links the library in the model’s.mfmetalibraries(Asset pipeline), changing nothing else there, and notes when the baked clip hides an imported clip of the same name.
Describe and edit scripts (G1c)
Section titled “Describe and edit scripts (G1c)”G1.14 (animation authoring → Edits), in
MainframeEngine/Src/Animation/Authoring/. After a bake the keys are the truth: an agent reads a clip back in canonical
terms and changes it with an edit script on top of its current keys, hand fixes included.
- Key times of a clip are the union of its transform tracks’ key times on the skeleton, merged within 1 ms
(
ClipDescriber.KeyTimes);TrackKeyssets or inserts keys (a new key takes the ease of the segment it splits; quaternions stay in one hemisphere), shared with the baker’s refinement. ClipDescriber.Describesamples the clip (ClipSampler) at its key times, or chosen ones, and reads the pose withHumanoidRig.ReadPose: the hips, every mapped bone’sflex/abduct/twist, and per foot and hand its position in character space (HumanoidRig.ToCharacterSpace, the space of IKpostargets), its height above the ground (the rest pose’s lowest foot or toe) and contact (within 2 cm). A time keyed by only some tracks lists those bones (refinement and hand-placed keys); a time keyed by none is sampled; the ease is the most common one among the tracks keyed there.ClipDescription.ToText()prints it for people and agents (non-zero angles only); it also says whether the clip is an untouched bake, a bake changed since, or not baked, and lists tracks on unmapped bones.- Edit scripts (
PoseScriptParser.ParseEdit,IsEditScript; errors with JSON paths like pose scripts):model,library,base,name(default: the base; another name writes a variant) andedits, each witht(an existing key time, or any time with"insert": true) orrange: [from, to](every key time in it), and any ofhips,joints(values20,"+=5","-=10"or"*1.3"per component),mirror,ease,ikand, with a range,arc. PoseEditor.Applyworks on a copy of the base. Each edit solves its keys on the clip as it was before that edit: the named bones (and their mirrors) take the changed angles; nothing else is written, so other tracks, key times, counts and eases stay. A bone keyed where its track has no key gets one there; a bone with no track gets one keyed at the edited times and the clip key times just outside them, so the change stays local. Unmapped bones are errors.- IK in edits:
"pin"holds the foot or hand where the clip had it before the edit (its rotation too, unless the edit names the end bone);{ "pos": [x, y, z] }reaches a character-space target. The chain is re-solved at the edited times, then over the whole planted span around them (adjacent key times where the effector was at the same spot) at 60 Hz: chain keys inside it are re-solved and refinement keys added where it slides more than 1 cm. - Arcs:
{ "range": [a, b], "arc": { "height": "*1.3" } }measures the hips’ apex above take-off (60 Hz) and scales the hips keys inside the range along the up axis, above the take-off-to-landing line, until the new apex is reached (within 1 cm, or a note says how far it got). It needs a hips position track with keys inside the range. BakedHash: an edit of an untouched bake stores the new hash (still untouched: no person’s work in it); an edit of a hand-edited or hand-made clip keeps its old hash, so a later full re-bake still refuses withoutreplace.PoseLibrary.Readloads a clip (errors list the library’s clips);PoseLibrary.WriteEditwrites over its own base always and guards a variant like a bake.
Checks (G1c)
Section titled “Checks (G1c)”G1.15 (animation authoring → Checks), AnimationChecks.Run in
MainframeEngine/Src/Animation/Authoring/AnimationChecks.cs. Claude cannot see the editor, so a clip is measured on its
rig at 60 Hz and at every key time, and each problem comes back as an AnimationCheckFinding: the check, its severity,
the time range (consecutive failing samples merge), the subject, the worst value, a message and a suggested fix.
AnimationCheckReport.HasErrors is what fails mfe anim check; warnings never do.
| Check | Measures | Severity |
|---|---|---|
ground | Feet, toes, hands and hips (bone origins) below the rest pose’s lowest foot or toe | error past 1 cm |
footSlide | A foot in contact (within 2 cm of the ground, moving up or down slower than 0.1 m/s) sliding from where the contact began | warning past 2 cm |
range | Every canonical angle against HumanoidLimits (hips pitch and roll against HipsTilt); abduct or twist on a hinge | error past the limit + 5° |
flip | Adjacent keys of a rotation track in opposite quaternion hemispheres | error |
spike | A mapped bone’s angular speed between samples | error past 1 500°/s |
loop | Linear: the pose and the per-frame motion at both ends; PingPong: no motion at either end | error past 2° / 1 cm |
start, end | The first and last pose’s joint angles against the declared named pose | warning past 2° |
root | InPlace: hips drift in x/z. Motion: hips moving faster than 30 m/s (a jump, error), yaw faster than 180°/s (warning) | warning past 1 cm |
physics | Motion only: each flight (both feet off the ground) whose hips apex is more than 25 % off g·T²/8 | warning |
- Scripts are not kept, so what a script declared comes in as
AnimationCheckOptions: the root mode, the start and end poses, gravity (ForScript(script, gravity)fills them from a pose script). Checks without them are skipped and listed inSkipped. Contacts are measured, not read from pins. AnimationCheckTolerancesholds every threshold;With("footSlide=0.03, range=10")sets them by name (ground,footSlide,contactHeight,range,angularSpeed,loopAngle,loopDistance,startEnd,rootDrift,rootYawRate,physics), asmfe anim check --tolerancewill.ToText()prints a summary line, the findings (errors first) and the skipped checks.- An in-place walk cycle slides its planted foot by design (the body is what moves): expect
footSlidewarnings there.
The mfe CLI
Section titled “The mfe CLI”The animate skill (.claude/skills/animate/SKILL.md, G1.19; game projects get the same file from the mfgame
template) teaches Claude Code the loop below: rig once, write a pose script in its scratch space, bake, read the checks,
render and look at the contact sheet, fix (at most five rounds), and change existing clips with describe and edit
scripts, never --replace unasked. It also says where mfe is in the engine repository, in a game built against a
checkout (MainframeEnginePath) and in a package game (an engine checkout with --project: the package does not carry
mfe yet), and holds a reference of the script fields, the checks and motion notes, with a jump that passes every
check.
G1.16 (animation authoring → The mfe CLI): Tools/MainframeEngine.Cli/
builds mfe, the engine/editor command-line tool; anim is its first command group. In this repo just mfe … runs it in
the current directory; a game project runs dotnet run --project <engine checkout>/Tools/MainframeEngine.Cli -c Release -- …. MfeCli.Run(args, output, error) is the whole program (tests run it in-process).
| Command | Does |
|---|---|
mfe anim rig <model> [--write-meta] | The bone tree, the humanoid map (each bone’s source and confidence), missing and unmapped bones, the rest pose (T/A) and proportions. --write-meta stores the map in the .mfmeta humanoid (HumanoidMap.Store). |
mfe anim poses | The named poses, the angle conventions, every canonical bone (required, hinge) with its limits. |
mfe anim bake <script.json> [--replace] [--no-link] [--tolerance …] | A pose script bakes (PoseBaker, PoseLibrary.Write, linking the library on the first bake); an edit script (base + edits) edits (PoseEditor, WriteEdit). Prints the tracks and key counts, the notes, the checks and how to play the clip. |
mfe anim describe <library> <clip> --model <m> [--times 0.2,0.4] | ClipDescriber in text. |
mfe anim check <library> <clip> --model <m> [--root inPlace|motion] [--start <pose>] [--end <pose>] [--tolerance …] | AnimationChecks. |
mfe anim list <library> | Each clip’s length, loop, tracks, keys and whether it is an untouched bake. |
mfe anim render <library> <clip> --model <m> -o <png> [--frames n] [--views …] [--size px] [--frame t] [--flat] | A contact sheet (below). Takes check’s --root, --start, --end and --tolerance for its report. |
- Project:
--project <dir>, else the nearestproject.mfprojabove the working directory. A run pointsContentPaths.ProjectDirectoryandAssetDatabase.Currentat it and restores both. Models and libraries are project paths (Assets/…); the script is a file path (it lives in the agent’s scratch space, never in the project). Arcs and the physics check use the length of the project’sphysics3D.gravity. - Output: text by default;
--jsonprints one JSON document with the same data. - Exit codes: 0 ok; 1 the checks found errors (a bake still writes its clip, so it can be edited) or a command failed; 2 usage or input errors: a script error (each with its JSON path), a missing file or clip, a refused replace. Nothing is written on 2.
- Unknown options are errors;
--tolerancetakesname=valuepairs (repeatable, comma-separated).
Contact sheets (G1c)
Section titled “Contact sheets (G1c)”G1.17 (animation authoring → Contact sheet rendering):
mfe anim render writes one picture of a clip to look at, in Tools/MainframeEngine.Cli/ContactSheet/.

- Layout (
ContactSheetLayout): a header (clip, model, length, loop, baked state, library, check summary), one row per view (front,side,threequarter) and one column per frame, then the trajectory strip and the check report. Frames are the times every track is keyed (refinement-only times left out, evenly thinned to 12), or--frames ntimes spaced over the clip (a sampled frame’s label ends in·), or--frame t: one large frame with the views side by side.--sizeis the sheet’s width (default 1 600 px). - Cells (
ContactSheetRenderer, anEnginewith a hidden window): the model on a lit ground (sun shadows, a procedural sky), posed withClipSamplerand seen from each view in turn, captured withCaptureFramea few frames later; each cell renders at twice its size (at most 1 024 px high) and is box-filtered down. The engine has no orthographic camera, so a 12° camera far enough away to fit 1.45× the character’s height stands in; it looks along the character’s −forward (front), from its left (side) or from front-left and 12° above (three-quarter), centred on the hips’ ground position at that time, so root motion stays in frame.--flatgives every mesh one unshaded grey: silhouettes. - Strip (
ContactSheetComposer): hips, feet and hands heights above the ground over time at 60 Hz, the frame times, and each foot’s contact band (fromClipDescriber). - Text is drawn on the CPU (
SheetCanvas,Font.RenderLine: Lato for labels, Roboto Mono for the report, the report’s errors in red and warnings in amber); the sheet is written withPng.WriteRgba8. - The engine’s own log goes to stderr (warnings and errors only) while it renders, so
--jsonstays one document. - Needs a GPU and a display (macOS: awake). Without one,
renderexits 1 naming the cause;describeandcheckstill give the numbers.
Getting started → Animate a character walks through exporting from Blender, importing, playing clips with crossfades, events and a hand attachment.
Testing
Section titled “Testing”- Unit (
Tests/MainframeEngine.Tests/Animation/):SkinnedImportTests(the generated character: skeleton, skin, weights, ten clips, loop modes and events from extras and.mfmeta, the CPU skinning reference at rest and posed, posed bounds containing every vertex, the import scale, clip settings round trip,CleanClipName),AnimationPlayerTests(loops and events across loops, crossfade values, fitting to a duration, queue, seek/stop/pause, backwards and ping-pong events, process modes and autoplay,BoneAttachment3Dkeeping a mesh and a light on the bone, global poses, scene round trip, static surfaces),AnimationHeadlessTests(events on the same frames every run underHeadlessHost, a root-motion body ending at the same pose every run, 0 B steady playback with crossfades, events and palettes),RootMotionTests(the pose without the motion, per-update replacement, vertical, loop wraps over one and several loops, backwards, turns carried into the facing closing a circle in small or large steps, a 360° clip, crossfade weights, settings changes, the yaw extraction),RootMotionCharacterTests(the character’s jump and circle moving a turnedCharacterBody3D; 0 B with crossfades,MoveAndSlideand palettes for four walkers),ValueTrackTests(value kinds and sub-components, discrete values, cubic and transitions, loop wrap, bezier, method keys across loops, backwards and ping-pong, deferred and immediate, audio keys, blend times, sync state, value crossfades,.mfresround trip, 0 B over 1 000 nodes). Generator:AnimationMethodsGetInvokersAndInvalidOnesAreReported(MFG011). Benchmark:AnimationBenchmarks. - Authoring (
Tests/MainframeEngine.Tests/Animation/Authoring/, G1c):PoseScriptParserTests,TwoBoneIkTests,PoseBakerTests,PoseLibraryTests(G1.13),ClipDescriberTests(the baked jump’s angles, contacts, eases and partial keys read back; a hand-made clip; the text),PoseEditScriptParserTests(every edit error names its path) andPoseEditorTests(only named keys change, inserts, new tracks, hand-placed keys kept, eases, arcs ×1.3 and absolute, pinned feet holding when the hips go lower, IK targets, theBakedHashrules, apply errors) andAnimationChecksTests(a clean squat passes; the G1.13 test jump’s real problems are found; a clip built to break each check reports it; tolerances move the thresholds) on the test character;MfeCliTestsrunsmfe animin-process on a temp project (help and usage errors, rig and--write-meta, poses, bake with links and checks, exit 1 on check errors and 2 on script errors, the replace guard, an edit script, describe and check with options, JSON output, restored globals, render’s option errors) andContactSheetLayoutTests(frames, geometry, the canvas, a composed sheet). Render:ContactSheetTestsrunsmfe.dllout of process on a temp project (every cell of a shaded and a--flatsheet shows the character;--framewith--json). - Editor:
EditorReloadTests(G1.18: a linked library rewritten on disk reloads into the open scene’s player, the editor’s own save is no reload, unsaved edits ask first, a model that now links a library reopens the clean scene and asks for a dirty one, an instanced model’s player previews read-only),AnimationNodesTests(warnings, icons),AnimationEditorTests(every undo action, key buttons and K, drags with snap and cancel, rubber band, method and audio keys, preview capture and restore, saving while previewing),TimelineTests(zoom around the mouse, ruler steps); the song tab’s tests run on the shared timeline. - QA:
Tests/QA/animation-walkthrough.qa(editor repo): create an animation on a player, key a node’s position from the inspector at two times, scrub, capture the panel. - Test asset:
Tests/Assets/Models/Character/character.glb, written bySkinnedCharacter(31 bones, two primitives, ~6 000 triangles, ten actions (jumpandcirclecarry root motion in the hips), both event forms, a.mfmetaclip);TheCommittedCharacterMatchesTheGeneratorkeeps it in sync (UPDATE_TEST_ASSETS=1). - Render (
SkinnedTests):skinned(two posed characters with CSM and point shadows, an outline overlay and a hand-attached hammer and torch; self-checks the dispatch count, a pick on the raised hand and the torch position; golden),skinned-crowd(12 characters crossfading: 0 B with the prepass and TAA, and the 120 fps budget). - Demo: the
animation_3dscene (Demo): a second character on aRootMotionWalkerbody walks half circles and jumps around a closed loop (Animation3DSceneTestschecks that it closes), and a workshop animated by tracks alone: anAnimatableBody3Dlift on the physics tick, a door that a method key unlocks (DoorLatch), swings open and shut and locks again, a lamp flickering on a cubic value track and a chime on an audio track.
Known issues
Section titled “Known issues”- No blend trees, IK or morph targets (Animation graph, Animation authoring).
- The panel has no curve view for bezier tracks (their handles are edited as data), no copy/paste or duplicate of keys,
no play-backwards button and no track filter; tracks are added from the inspector’s key buttons, K and the method and
audio buttons, not a
+menu. Imported libraries are edited with the scene; there is no “Save animations as.mfres” yet (Editor viewport tools, G7). - Normals are skinned with the palette’s 3×3 (renormalised), not its inverse transpose: non-uniform bone scale shades slightly wrong.
- Skinned instances draw one by one (no instancing of identical characters).
- The editor’s viewport focus and selection box use the mesh’s bind-pose bounds.
- Skinned surfaces with vertex colours draw their prepass without skinned motion vectors (the
MeshDepthExtpath). - Root motion comes from bone tracks only (not a plain
Node3D’s), has no accumulators (Godot’sget_root_motion_position_accumulator), and a hips-as-root rig hands the hips’ sideways sway to the body. The G1c baker’sroot: "motion"is not written yet.
Changes from the proposal
Section titled “Changes from the proposal”G1a followed the Keyframe animation proposal (now folded into this page) with these differences:
- Timeline extraction: one
Src/Timeline/withTimelineZoom(notTimelineViewState, which the video timeline already names),TimelineRuler,TimelineSnap,TimelineHostandTimelineCanvasBase. The song tab’s gestures stay its own; the press/drag state machine (TimelineGestures) was not extracted, because the song and animation gestures share little beyond the threshold. - Undo is two snapshot actions (
AnimationEditActionover an animation’s tracks and settings,AnimationLibraryActionover a library’s list) instead of seven fine-grained ones: an animation’s key arrays are small, and one shape covers every edit. - Track list is part of the panel’s chrome, not a separate data-bound list; the
+add-track menu became the inspector key buttons, K, and two header buttons for method and audio tracks. - Not built: the curve view, Alt-duplicate, key copy/paste and Cmd/Ctrl+D, play backwards, the track filter and the
missing-target warning icon, persisting the tab and pin in
editor_layout.json. They are follow-ups (see Known issues). - Events stay an
EventTrackbeside method tracks (games already subscribe toAnimationEvent). - Engine methods: the audio players’
Play/Stopand the particles’Restartare[AnimationMethod]s, so method tracks work on built-in nodes too.
Still open from the proposal: compute versus vertex-shader skinning on mobile; Assimp versus a glTF reader; large clips
as JSON once G7 saves them; editing external .mfres libraries with their own history; built-in replication of player
state (games use GetSyncState); an auto-key (record) mode; discrete string and resource tracks; morph targets and
instancing identical skinned characters.
Related
Section titled “Related”Animation authoring · Asset pipeline · Materials & meshes · GPU resources · Post-processing · Shadow system · Scene graph & nodes