mwg API
    Preparing search index...

    Class DeformableSprite

    A sprite that deforms by pinned control points on the existing GPU mesh path.

    This is Pixi's MeshPlane with a PinnedDeform driving its position buffer: dragVertex moves one vertex while the rest stay pinned, and the mesh batch renders the result, so a Pontifex wing bends without the game touching Pixi's mesh directly. The routine itself never rotates, scales or repositions the sprite (rotation stays 0 through every drag) and never rewrites UVs; games that need a turned sprite rotate the texture art, not this mesh. Colour-batch and shader internals are untouched: this stays out of ColorTransformBatcher.

    import { DeformableSprite } from '@datamoc/mwg/two-d/render';
    import type { Texture2D } from '@datamoc/mwg/two-d/render';

    declare const wingTexture: Texture2D;

    const wing = new DeformableSprite(wingTexture, { columns: 4, rows: 4 });
    wing.dragVertex(wing.indexOf(3, 0), 99, -6); // the wingtip bends on the GPU mesh
    console.log(wing.vertexAt(wing.indexOf(0, 1)).x); // 0 - the pinned root stays put
    console.log(wing.rotation); // 0 - dragging never turns the whole sprite

    Hierarchy

    • MeshPlane
      • DeformableSprite
    Index
    • Move one mesh vertex to an absolute local position and re-upload the position buffer. Only that vertex changes; the rest stay pinned.

      Parameters

      • index: number
      • x: number
      • y: number

      Returns void

    • the flat index of the vertex at (column, row)

      Parameters

      • column: number
      • row: number

      Returns number

    • whether a vertex currently sits away from its rest position

      Parameters

      • index: number

      Returns boolean

    • Shift one mesh vertex by a delta and re-upload the position buffer.

      Parameters

      • index: number
      • dx: number
      • dy: number

      Returns void

    • Return one vertex to rest, or every vertex when called without an index.

      Parameters

      • Optionalindex: number

      Returns void