mwg API
    Preparing search index...

    Class Beam

    A one-shot beam between two screen points: a fading line by default, a fading texture strip with texture - tiled, or stretched once along the span in the object form, with thin narrowing the body as it fades (see BeamOptions). The sub-second ray flash - a zap, a laser, a life-link - where LightningArc is the persistent jittered geometry and MultiTurnBeam the multi-turn case.

    Fades from full to gone across duration and reports done exactly once, so a group can remove it without a second clock. retarget moves either endpoint for a beam tracking two moving points; z-order and parenting stay the caller's.

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

    declare const rayTexture: Texture2D;

    const zap = new Beam({ x: 0, y: 0 }, { x: 100, y: 0 }, { colour: 0x88ccff, duration: 0.2, thin: true });
    const ray = new Beam({ x: 0, y: 0 }, { x: 100, y: 0 }, {
    texture: { source: rayTexture, stretch: true },
    width: 8,
    thin: true,
    duration: 0.3,
    });
    const expired = zap.update(0.25);
    console.log(expired); // true - the instant it outlives its duration
    zap.destroy();
    ray.destroy();

    Hierarchy

    • Container
      • Beam
    Index
    • Removes all internal references and listeners as well as removes children from the display list. Do not use a Container after calling destroy.

      Returns void

      container.destroy();
      container.destroy(true);
      container.destroy({ children: true });
      container.destroy({ children: true, texture: true, textureSource: true });
    • Parameters

      • dt: number

      Returns boolean

      true the instant duration elapses, so a caller can remove the beam exactly once