Small World Engine API Reference - v0.78.00
    Preparing search index...

    Class Ray

    Represents a mathematical ray in 3D space.

    Index
    direction: Vector3D = ...

    The normalized direction vector of the ray.

    origin: Vector3D = ...

    The origin point of the ray.

    • Computes the point along the ray at a given distance.

      Parameters

      • t: number

        The distance along the ray.

      • target: Vector3D = ...

        Optional target vector.

      Returns Vector3D

      The computed point.

    • Tests whether this ray intersects the given AABB. Uses the slab method.

      Parameters

      Returns number

      The distance t to the intersection, or -1 if no intersection.

    • Tests whether this ray intersects the given OBB. Uses the slab method projected onto the OBB's local axes.

      Parameters

      • obb: OBB

        The oriented bounding box.

      Returns number

      The distance t to the nearest intersection, or -1 if no intersection.

    • Tests whether this ray intersects the given bounding sphere.

      Parameters

      Returns number

      The distance t to the nearest intersection, or -1 if no intersection.

    • Tests whether this ray intersects any bounding volume (Sphere, Box, OBB).

      Parameters

      Returns number

      Distance t to the nearest intersection, or -1 if no intersection.

    • Tests whether this ray intersects any bounding volume, computing the exact world hit point and outward surface normal.

      Parameters

      • volume: BoundingVolume

        Target bounding volume.

      • outPoint: Vector3D

        Vector3D receiving the computed world hit position.

      • outNormal: Vector3D

        Vector3D receiving the outward-pointing surface normal.

      Returns number

      Distance t to the nearest intersection, or -1 if no intersection.