Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Builtins — Animation (Anima)

Anima is Ling’s unified animation system (the ling-animation crate). Its guiding idea: one rig, any target, any temperament. Every animated thing — a 2-D vtexture, a 3-D mesh, a particle field, or a bag of scalar parameters — is a rig of abstract joints, driven by composable drivers, and deformed onto its target by a binding.

What makes Anima different is the temperament axis: a per-chain scalar from organic (灵) to mechanical (机) that selects and cross-fades the solver — muscle, breath, jiggle, and IK on one end; exact gear, cam, and linkage coupling on the other. A robot can have organic hydraulic sag; a creature can have a mechanical jaw.

The scalar drivers below are available today as builtins. They are pure functions — call them every frame with the current time (and any state you keep) to drive a scale, a position, a rotation, or a vtex parameter. Each is available in all five languages.

Organic drivers (灵)

EnglishSignatureReturnsDescription
tweentween(a, b, t)numberLinear interpolation a → b, t clamped to [0,1].
tween_easetween_ease(a, b, t, "kind")numberEased interpolation. kind is a curve name (see below).
breathebreathe(t, rate, depth)numberBreathing multiplier centred on 1.0: 1 + depth·sin(2π·rate·t).
wobblewobble(t, freq, amp, phase)numberSecondary sway / jiggle sine.
gait_phasegait_phase(t, speed)numberLocomotion phase in [0,1).
gait_swinggait_swing(t, speed, stride)numberForward/back leg swing for a walk cycle.
gait_liftgait_lift(t, speed, height)numberFoot lift (rises only during the swing half).
spring_tospring_to(pos, vel, target, stiffness, damping, dt)[pos, vel]One spring step (spring-bone / secondary motion). Returns the new position and velocity.
ik2ik2(l1, l2, tx, ty)[shoulder, elbow]Planar two-bone IK: joint angles that reach target (tx, ty).

Easing curve names (for tween_ease)

linear, step, quad_in/out/in_out, cubic_in/out/in_out (smooth), sine_in/out/in_out, expo_in/out/in_out, elastic_in/out (elastic), back_in/out/in_out (overshoot), bounce_in/out (bounce).

Mechanical drivers (机)

EnglishSignatureReturnsDescription
gear_couplegear_couple(angle, teeth_in, teeth_out)numberMeshed-gear output angle — opposite sign, scaled by the tooth ratio.
gear_traingear_train(angle, [t0, t1, t2, …])[angle…]Angles of every gear down a meshed train.
cam_liftcam_lift(angle, lift)numberCam follower displacement over a rotation (0 at θ=0, peak at θ=π).
pistonpiston(angle, crank, rod)numberSlider-crank pin position from a crank angle.
rackrack(angle, radius)numberRack-and-pinion linear travel: θ · radius.

Multilingual names

enzhjakoth
tween补间補間트윈แทรกค่า
breathe呼吸呼吸호흡หายใจ
wobble摆动揺れ흔들림โยก
gait_swing步摆歩振り걸음흔들ก้าวแกว่ง
spring_to弹向バネ寄せ스프링이동สปริงไป
ik2反解逆運動역운동ไอเค2
gear_couple齿轮联动歯車連動기어연동เฟืองทด
piston活塞ピストン피스톤ลูกสูบ

(The full table lives in lexicons/*.ling and lingfu normalize’s BUILTINS_ANIM.)

Example — a breathing, walking, geared scene

bind start = do {
    open_window("Anima")
    bind t = 0.0
    while window_is_open() {
        bind t = t + delta_time()
        fill(10, 12, 24)

        // organic 灵 — a body that breathes and a foot that walks
        bind chest = breathe(t, 0.4, 0.08)      // ~1.0 ± 0.08
        bind foot  = gait_swing(t, 1.6, 30.0)   // leg swing in pixels

        // mechanical 机 — a gear train driven by a turning shaft
        bind shaft = t * 2.0
        bind gears = gear_train(shaft, [12, 36, 12])

        present()
    }
}

For Rust authors — the crate (ling-animation)

The builtins above are the scalar layer. The crate also exposes the structural core that the runtime rig/skin builtins will build on:

  • easeEaseFunction, Lerp, tween_ease.
  • trackKeyframe, Track, Timeline.
  • rigRig, Joint, Pose, world-pose + skinning matrices.
  • temperament — the Temperament (灵 ↔ 机) axis with blend, liveliness, rigidity.
  • scalar — the per-frame driver math used by the builtins.
  • mechanism — exact linkages (gear_train, four_bar).
  • creature — procedural biped_legs, quadruped_legs, breathing_scale.

Not yet wired (roadmap)

The full rig pipeline is staged. Still to land as builtins:

  • rig_load (glTF skin import), rig_joint, pose/anim_clip/anim_play/anim_tick.
  • SkinBinding (3-D linear-blend skinning over a mesh), WarpBinding (2-D vtex control lattice), ParamBinding (drive vtex parameters / blendshapes).
  • The driver motion graph (masked, weighted blending of clip + procedural + physics).
  • GPU skinning (via ling-gpu) and driver-state snapshotting (via ling-net).