Skip to content

Models and animation ​

Make and edit animation clips in the Animation panel, set a model up as a unit, bring in clips from Mixamo, and set how a unit dies, looks in the HUD and sounds. To bring a model file in first, see Bring in a model.

Make your first animation ​

  1. Open Window › Animation (its icon is on the bottom rail).
  2. Pick a Model in the panel's bar: a unit type, or a model file.
  3. Press New and type a name (↵). The clip has one key at 0, holding the model's pose now.
  4. Click a bone on the model (or pick it by name in the Bone tab): the gizmo appears on it.
  5. Pick Turn (E) to drag rings, or Move (W) to drag arrows: the buttons are at the stage's top left. When you let go, a key is made at the playhead.
  6. Click later on the timeline's ruler and pose again: another key. The clip lasts to its last key.
  7. Press ▶ (Space) to play it. Ctrl+Z undoes any edit.
  8. Press Save. The first time, name it: it writes animations/<name>.anim.glb, which any model can play.

The panel ​

From left to right: the model's clips (• on one changed, ◆ with its count of marks), the stage with its tools over it, the timeline, and the inspector in tabs.

  • The bar: the model, New, to the start, to the key before, play, to the key after, the time, Undo and Redo, and Save. Write the look • shows there while marks, loops or blends are changed and not yet written.
  • The stage: Turn (E) and Move (W) for the gizmo, Key pose (K) keys every bone as it stands. The bone picked is named at the top right; × lets it go.
  • The timeline: each lane is named at the left (Marks on the ruler, All bones, the bone picked). Above it, the row that marks the playhead (see Mark moments).

Pose a bone ​

The Bone tab:

  • Bone: pick one by name (or click it on the model).
  • The gizmo: Turn (E), Move (W), or Hide (P) to see the model clean.
  • At the playhead: the bone's turn in degrees and its place, x y z. Typing a number keys it at the playhead; ◆ says the bone has a key there.
  • This bone: Key it, Remove its key, Put back (R: as the model rests it, keyed at the playhead), Copy and Paste (Ctrl+C, Ctrl+V).
  • The whole pose: Key every bone (K), Remove keys here, Copy pose.

A bone keyed for the first time partway into a clip also gets a key at 0, as the model rests it, so it moves from there.

Mark moments: hit, foot, effects, sounds ​

A mark is a moment of the clip the game acts on as the animation reaches it. Put the playhead there and press one in the row above the timeline:

ButtonMarkDoes
Hit (M)hitWhere the blow lands, or the shot leaves. An attack clip is fitted so this lands on the attack's damagePoint. One per clip
FootfootA footstep sound. A walk has one per foot
Effect…fx:<effect>Plays one of the game's effects on the unit: pick one, or type a name
Sound…sound:<sound>Plays one of the game's sounds at the unit
Custom…your wordYour look's onMark hears it

Each kind has its colour on the ruler. Drag a mark to move it. The Marks tab lists them all: rename one, type its time in seconds, go to it, take it away. It also says where an attack's blow lands. Marks are part of the unit's look: press Write the look to keep them in looks.json. To time an attack with them: Time an attack and its effects to the animation.

Edit keys, the loop and the clip ​

  • Move keys: drag them (Alt copies, Shift adds to the selection, drag a box over rows). Delete removes them. Double-click a lane to add a key.
  • ↑ and ↓ go to the key before and after (of the bone picked, or of any bone). ← → step a frame, Home and End go to the ends, the wheel zooms, 0 fits.

The Clip tab:

  • Length retimes the whole clip.
  • Loop: In here (I) and Out here (O) set the looped part (idle, walk), Whole clip clears it, Trim to it cuts the clip to it.
  • Between keys: Straight, Held or Eased, for the bones whose keys are selected (all with none). Remove selected takes the selected keys and marks away.
  • Plays on: the part of the body the clip plays on, the rest left to what the unit keeps doing: Whole body, Upper body (the spine and everything on it: an attack over the walk, the legs still walking), Lower body, or Bones… by name (+ picked bone adds the one picked). Preview over the walk plays it layered as a game does. See A clip on a part of the body.
  • A clip of this pose makes a one-second clip of the current pose.
  • Blends: how many seconds one clip takes to give way to another (0.16 by default).

Save clips into the model or its look ​

The Files tab:

  1. Write the clips into the model: changed clips go into the model's clips file, <model>.clips.glb, beside it.
  2. Write the look: the marks, loops and blends go into looks.json for the unit type whose look the model is.
  3. Revert this clip gives a clip back as the file has it.

Bring in an animation from Blender or Mixamo ​

A GLB with clips and no mesh (Blender's export of an armature and its actions, or a Mixamo clip downloaded "without skin") is an animation, not a model. Drop it on Assets, or press Import files…: it comes in as animations/<name>.anim.glb and is listed under Animations. Double-click it (or right-click › Apply to a model…) to apply it, as below. A GLB with a mesh is a model; to take its clips, use Import clips.

Apply an animation file to another model ​

  1. Pick the model in the panel's Model.
  2. In the Files tab, press Save or apply a file…, or in Assets or Content pick an animation and Apply to a model….
  3. Match the file's bones to the model's in the table (by name, by preset, or by hand).
  4. Press Preview to try it, then Write to the look (for a unit type, with what it plays it for, such as walk) or Bake into its clips.

Set a model up as a unit ​

  1. In Assets or Content, right-click a model and pick Set up as a unit….
  2. Pick the Unit type, then set Scale (compare with another type), Health bar, Facing, Turn upright and Team colour.
  3. Under Clips, say what each clip is played for (idle, walk, attack, death).
  4. Open the folds for more: Walk and attack timing, Bones, Points, Lights, Glow, Parts shown, Drawn far away, Death, damage, icon, sounds.
  5. Press Write it for… to save it into looks.json.

Under the attack's Hit at, the attack's timing is drawn as bars. Set damage point from the clip sets the type's damagePoint to where the clip lands its blow (kept in data.json); Fit the clip to the attack moves the mark instead. See Timing.

Import clips from Mixamo or another file ​

  1. In Set up as a unit's Clips, press Import clips… (the Animation panel's Files › Import clips opens it for the model shown).
  2. Pick a GLB, or a glTF with its files. For Mixamo's FBX, install fbx2gltf (npm i -g fbx2gltf) and restart the dev server: it converts the FBX on the way in. Without it, an FBX is refused with that message; convert it to a GLB yourself (Blender: import the FBX, export glTF Binary) and bring that.
  3. Check the bone table: the same names match first, then the preset (Mixamo → KayKit), then near spellings. Pick the rest by hand or leave them out.
  4. Rename clips if you like, and press Preview on the model.
  5. Press Write the clips, then Write it for… to name the file in looks.json.

Bones are matched, not made: no rigging. A pose is copied by where each bone points, so a T-pose file works on an A-pose model. The model keeps its own proportions.

A Mixamo character and its clips, from a script ​

node scripts/mixamo.mjs <folder> <out.glb> --character <file.fbx> makes one GLB of a Mixamo character and every clip in the folder (a pack's zip, unzipped): each clip named after its file, its ground moves taken out so the game moves the unit, its materials made matte, its pictures WebP. --lift 2.5 brightens a character of dark armour. It needs FBX2glTF (npm i fbx2gltf). The examples' Oathbound (apps/examples, showcase-paladin) is made this way.

Then, in the unit's look:

  • loop: locomotion({ walk: { forward, back, left, right }, run: {…}, idle: [...] }) walks the clip of the way it goes against the way it faces, and takes its idles in turn.
  • onHit: { clip: [...] } flinches with a clip, only where the unit does nothing else.
  • client.ghost(id, { clip, seconds, rise }) raises a see-through white likeness of a unit that fades as it goes up.
  • points: { sword: { at: 'mixamorig:RightHand', turn: [0, 0, 1.57], scale: 0.6 } } with hold puts a shared weapon in a Mixamo hand.

Set how a unit dies, looks and sounds ​

  1. Look into a unit type (Content: right-click › Look into it), which opens the Model view.
  2. Use its tabs:
    • Attack: its attacks and casts, timed to their clips, with their shots, effects and sounds: see Attacks and casts.
    • Death, Going up (a building) and Damage: see Destruction.
    • Icon: a picture from icons/, typed or dropped from Assets.
    • Portrait: the picture, and the live portrait's model, camera, light, background, clips and moods (see The HUD).
    • Sounds: a sound for selected, ordered, attack, hit, death and what it says, with ▶ to hear it.
  3. Each is written into looks.json as you go. As the code's removes it.

A copy made in the Data panel uses its original's until it has its own.

Split a model into parts ​

  1. Right-click a model and pick Split into models… (Assets, Content, or the Model view).
  2. Pick a part in the tree or on the model (Ctrl for several), and name it.
  3. Add it as a .glb or .gltf; tick As one mesh to join several parts.
  4. Press Save.

Look into a model ​

Pick a model in Content or Assets and Look into it: the Inspector draws it to turn and zoom, with its triangles, vertices, meshes, materials, textures, bones, clips, file size and GPU memory. Its tabs list nodes, materials, clips and the file. Draw faces, edges or vertices, UVs, materials, normals, bounds or bones.

Make lighter detail levels ​

  1. Select a unit, or open a model's Model view › Detail.
  2. Press Make levels (or Assets › Make lighter levels).
  3. Compare a level seen from a distance with the full model, and pick what the map draws it with.

Levels are made by npm run lod through the dev server, beside the model. A model over 3 MB with no levels is flagged in Problems (heavy-model).

In code ​

ts
// open the Animation panel at a type and a clip
editor.panels.api('animation')?.open({ type: 'footman', clip: 'attack' })

// animation files
await editor.saveAnimation(src, clip, { name: 'swing' })
editor.animationFiles()
await editor.applyAnimation('footman', 'animations/swing.anim.glb', { as: 'attack', bones })

// clips from another file
await editor.importClips(src, file, { table, bones, clips, existing })

// what a model is made of
editor.inspectModel(model)

A game's page carries none of the editing code: it reads clipsFile, animation files and looks.json. See An animation file on a model to play one without the editor.

Reference ​

What is written where ​

WhatFileField
Clips edited or imported<model>.clips.glbModelDef.clipsFile
An animation fileanimations/<name>.anim.glbmodel.animationFiles[<file>].bones
Marks, loops, masks, blendslooks.jsonModelDef.clips, ClipDef.marks, ClipDef.loop, ClipDef.mask, ModelDef.blends (BlendDef)
A unit's setuplooks.jsonthe type's look
Icon, portrait, soundslooks.jsonicon, portrait, sounds
Attacks' and casts' lookslooks.jsonattacks, casts (Attacks and casts)
A model's lights and glowlooks.jsonModelDef.lights, ModelDef.glow

In play the client times an attack about its hit mark (hitAtOf, clipMarkAt), loops a clip over its loop and blends by blends (blendSeconds). Marks are played as the clip reaches them (marks in play).

Clip edits as functions ​

On a KeyedClip (a track per bone): moveKeys, copyKeys, removeKeys, setKey, trimClip, retimeClip, easeTracks, clipFromPose (what New makes), sampleClip. On what a model says of a clip: trimClipDef, withMark, withClipDef. Files: writeClipsFile(model, { existing, clips }), readClip(document, name), makeClipsFile, retargetClips, guessBones, clipBones, modelBones; a bone table of your own is a BoneMap, presets are RETARGET_PRESETS.

ModelStage draws a model on a stage of its own: stage.clipOf(name), stage.setClip, stage.poseOf(), stage.restOf(bone), stage.poseBone(name), stage.setBonePicking(on), stage.onBonePicked(listener), stage.setShowBones(true, { seeThrough: false }).

Models come in as GLBs, or glTFs with their files (made one GLB on the way in: EditorClient.importModel). Split models are written by EditorClient.writeModels with cutOut of @v12-engine/editor. A model's anatomy is modelAnatomy(bytes) of @v12-engine/client/common.