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

    Class SpatialQueries

    Spatial query operations (raycast / raycastAll / sphereCast) against the broadphase tree.

    Owns its own reusable broadphase query buffer and keeps the trigger-filter logic in one place, so the owner system only delegates to this service.

    Index
    • Casts a ray against all active colliders in the scene, returning the closest hit.

      Parameters

      • ray: Ray

        The ray to cast.

      • maxDistance: number = Infinity

        Maximum travel distance (default: Infinity).

      • mask: number = 0xffffffff

        32-bit collision layer mask filter (default: 0xFFFFFFFF).

      • OptionaloutHit: RaycastHit

        Optional RaycastHit object receiving the hit details.

      • ignoreTriggers: boolean = true

        If true, ignores sensor/trigger colliders (default: true).

      Returns RaycastHit | null

      RaycastHit or null if nothing was hit within maxDistance.

    • Casts a ray against all active colliders and returns all hits sorted by distance ascending.

      Parameters

      • ray: Ray

        The ray to cast.

      • maxDistance: number = Infinity

        Maximum travel distance.

      • mask: number = 0xffffffff

        32-bit collision layer mask filter.

      • OptionaloutHits: RaycastHit[]

        Optional array receiving the results.

      • ignoreTriggers: boolean = true

        If true, ignores sensor/trigger colliders.

      Returns RaycastHit[]

      Array of RaycastHit objects sorted by distance ascending.

    • Sweeps a sphere along a direction vector against all active colliders in the scene.

      Parameters

      • origin: Vector3D

        Starting center position of the swept sphere.

      • radius: number

        Radius of the sphere.

      • direction: Vector3D

        Direction vector of the sweep.

      • maxDistance: number = Infinity

        Maximum travel distance along direction.

      • mask: number = 0xffffffff

        32-bit collision layer mask filter (default: 0xFFFFFFFF).

      • OptionaloutHit: RaycastHit

        Optional RaycastHit object receiving the hit details.

      • ignoreTriggers: boolean = true

        If true, ignores sensor/trigger colliders (default: true).

      Returns RaycastHit | null

      RaycastHit or null if no obstacle was struck.