mwg API
    Preparing search index...

    Class SpringSprite

    A debug line from a spring's anchor to its bob: one straight segment that stretches, overshoots and settles with the simulation. A game draws hair or hems by placing its own sprites with Spring.place, and keeps this around while tuning stiffness and damping. Call sync after stepping the spring; the line never steps anything itself.

    import { Spring } from '@datamoc/mwg/physics';
    import { SpringSprite } from '@datamoc/mwg/two-d/render';

    const spring = new Spring({ stiffness: 120, damping: 8 });
    const line = new SpringSprite({ spring });
    spring.setAnchor(10, 0);
    spring.update(1 / 60);
    line.sync(); // the segment now leans toward the anchor

    Hierarchy

    • Graphics
      • SpringSprite
    Index