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

    Class PhysicsSystem

    A lightweight physics solver using Semi-Implicit Euler integration and spatial broadphase acceleration.

    Index
    ccdMotionThreshold: number = 1.0

    Continuous Collision Detection (CCD) threshold, as a multiple of a body's broad radius. Set to Infinity to disable CCD entirely.

    fixedTimeStep: number = ...

    The fixed time step for physics calculations (e.g. 1/60).

    gravity: Vector3D = ...

    Global gravity vector (default: -9.81 on Y)

    joints: Joint[] = []

    Active Physics Joints / Constraints tracked directly by the system.

    maxDeltaTime: number = 0.25

    Maximum delta time allowed per frame.

    maxSubSteps: number = 10

    Maximum number of sub-steps per frame to prevent spiral of death.

    solverIterations: number = 4

    Number of iterative solver iterations per substep for stacking stability & constraint relaxation (default: 4).

    • get interpolationAlpha(): number

      How far the accumulator has progressed into the next fixed timestep [0, 1).

      Returns number

    • Steps the physics simulation forward. /** Adds a joint to the physics simulation.

      Parameters

      Returns void

    • Renders every tracked rigid body's transform interpolated between previous and current physics states.

      Returns void

    • Resets and clears the broadphase tree, active pairs, and trigger/collision tracking state.

      Returns void

    • Returns a stable integer ID for any Collidable object. Uses collider.id if defined, or assigns a stable internal ID.

      Parameters

      Returns number

    • 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.

    • Advances the physics simulation for a given Scene by delta time dt. Automatically executes fixed-timestep sub-steps to preserve determinism and numerical stability.

      Parameters

      • scene: Scene

        The scene containing objects with RigidBodies.

      • dt: number

        Delta time in seconds.

      Returns void