mwg API
    Preparing search index...

    Class SkeletalSprite

    Bones driving drawn parts (roadmap 400), the drawing half of the skeleton module.

    A SkeletalSprite binds sprites or texture regions to bones by name; update(dt) advances the mixer (or applies a pose a game resolved itself) and places each part at its bone's world transform, so a character sheet, an SVG puppet split by groups or a mixed rig animate through the same bone tree. Walk, swing and look cycles are clips; the binding is the only rendering decision this side makes.

    An ArticulatedChain is the one articulated shape a keyframe cannot express: a long body (a dragon's neck and tail, a serpent's spine) drawn as a chain of segments that follows its head procedurally. Each segment eases toward its parent's previous position, with per-segment rotation limits so the body bends like a body and not like a rope of beads. This is deliberately not a clip - it is a follower rule, not authored motion - and composes with one: a clip drives the head and limbs, the chain does the rest of the body.

    import * as Skeleton from '@datamoc/mwg/skeleton';
    import { Texture, TextureSource } from 'pixi.js';
    import { SkeletalSprite } from '@datamoc/mwg/two-d/render';

    const puppet = Skeleton.create([{ name: 'arm', length: 12 }]);
    const mixer = Skeleton.createMixer(puppet, {
    id: 'idle', duration: 1, loop: true,
    frames: [{ time: 0, rotations: { arm: 0 } }, { time: 1, rotations: { arm: 90 } }],
    });
    const rig = new SkeletalSprite(puppet, mixer);
    const armTexture = new Texture({ source: new TextureSource({ width: 8, height: 8 }) });
    rig.bind('arm', armTexture).anchor.set(0, 0.5);
    rig.update(1 / 60); // each part sits on its bone, every frame

    Hierarchy

    • Container
      • SkeletalSprite
    Index
    • Explicit development opt-in. Disabled rigs allocate no overlay and draw no diagnostics.

      Parameters

      • enabled: boolean

      Returns void