mwg API
    Preparing search index...

    Function loadSvgSkeleton

    • Load authored SVG limbs, normalize each around its pivot, and bind them to a skeleton. Uses SVG data-pivot-x / data-pivot-y attributes or pivots supplied by the game. Art is rotated back from its rest angle before rasterization, so rest poses reconstruct the drawing and posed limbs turn around their joints. Separately bound descendant groups are removed from parent parts, avoiding duplicate limbs; ancestor transforms and shared defs/styles survive. Requires browser DOMParser and XMLSerializer. Compiled asset paths work directly under file://.

      Parameters

      Returns Promise<LoadedSvgSkeleton>

      import { create } from '@datamoc/mwg/skeleton';
      import { loadSvgSkeleton } from '@datamoc/mwg/two-d/render';
      import { releaseSvgParts } from '@datamoc/mwg/assets';
      const loaded = await loadSvgSkeleton('<svg xmlns="http://www.w3.org/2000/svg" width="30" height="10"><g id="arm" data-pivot-x="0" data-pivot-y="5"><rect width="30" height="10"/></g></svg>', {
      skeleton: create([{ name: 'arm', length: 30, origin: { x: 0, y: 5 } }]), resolution: 2,
      });
      loaded.sprite.apply({ arm: 45 });
      loaded.sprite.destroy({ children: true });
      await releaseSvgParts(loaded.textures);