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

    Class PhysicsSystem

    A lightweight physics solver using Semi-Implicit Euler integration.

    Index
    ccdMotionThreshold: number = 1.0

    Continuous Collision Detection (CCD) threshold, as a multiple of a sphere body's own radius. If a sphere-shaped body moves farther than radius * ccdMotionThreshold in a single substep, it's swept against nearby geometry instead of only being checked for overlap at its new position -- this catches fast/small bodies that would otherwise tunnel straight through thin walls or other small colliders. Sphere bodies only, see docs/adr/0005-ccd-sphere-only-scope.md. 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)

    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.

    • get interpolationAlpha(): number

      How far the accumulator has progressed into the next, not-yet-simulated fixed timestep, as a fraction in [0, 1). Used by applyRenderInterpolation to blend each body's rendered transform between its previous and current physics state.

      Returns number

    • Renders every tracked rigid body's transform interpolated between its previous and current fixed-timestep physics state, instead of snapping to the latest completed substep -- this is what actually eliminates visual stutter when the render framerate doesn't line up evenly with fixedTimeStep (see "Fix Your Timestep!" in REFERENCES.md).

      Must be called once per frame, after anything that depends on the true physics transform (collision bounds, frustum culling, gameplay logic) and immediately before rendering: each object's true position/rotation is restored right after its interpolated world matrix is computed, so nothing else ever observes the interpolated (render-only) state.

      Returns void

    • Steps the physics simulation forward.

      Parameters

      • scene: Scene

        The scene containing objects with RigidBodies.

      • dt: number

        Delta time in seconds.

      Returns void