nape-js API
    Preparing search index...

    Class Ray

    A ray for raycasting queries.

    Fully modernized — uses ZPP_Ray directly (extracted to TypeScript).

    Index

    Constructors

    • Create a Ray from an origin point and a direction vector. Both must be non-null, non-disposed Vec2s.

      Parameters

      • origin: Vec2

        The start point of the ray in world coordinates.

      • direction: Vec2

        The direction vector (need not be unit length).

      Returns Ray

    Accessors

    Methods

    • Return the world-space point at distance along the ray.

      Parameters

      • distance: number

        Distance from the ray origin along the ray direction.

      • weak: boolean = false

        If true, the returned Vec2 is a weak (pooled) reference.

      Returns Vec2

      The point origin + distance * normalised_direction.

    • Create a Ray from a line segment. The ray origin is start, direction is end − start, and maxDistance is the segment length.

      Parameters

      • start: Vec2

        The start point of the segment.

      • end: Vec2

        The end point of the segment.

      Returns Ray

      A new Ray spanning the segment.