crashcat docs
    Preparing search index...

    Type Alias WorldSettings

    type WorldSettings = {
        ccd: {
            linearCastMaxPenetration: number;
            linearCastThreshold: number;
            minVelocityForRestitution: number;
        };
        contacts: { contactPointPreserveLambdaMaxDistSq: number };
        gravity: Vec3;
        gravityEnabled: boolean;
        layers: Layers;
        narrowphase: {
            collideOnlyWithActiveEdges: boolean;
            collideWithBackfaces: boolean;
            collisionTolerance: number;
            manifoldTolerance: number;
            normalCosMaxDeltaRotation: number;
            penetrationTolerance: number;
            returnDeepestPoint: boolean;
            speculativeContactDistance: number;
            useManifoldReduction: boolean;
        };
        sleeping: {
            allowSleeping: boolean;
            pointVelocitySleepThreshold: number;
            timeBeforeSleep: number;
        };
        solver: {
            baumgarteFactor: number;
            maxPenetrationDistance: number;
            minVelocityForRestitution: number;
            penetrationSlop: number;
            positionIterations: number;
            velocityIterations: number;
            warmStartImpulseRatio: number;
            warmStarting: boolean;
        };
    }
    Index

    Properties

    ccd: {
        linearCastMaxPenetration: number;
        linearCastThreshold: number;
        minVelocityForRestitution: number;
    }

    Continuous Collision Detection (CCD) options

    Type Declaration

    • linearCastMaxPenetration: number

      Fraction of inner radius allowed to penetrate during CCD. Provides penetration slop for stability.

      0.25 (25%)
      
    • linearCastThreshold: number

      Fraction of inner radius to trigger CCD. If movement < (threshold * innerRadius), use discrete update. Lower = more CCD (expensive), Higher = more tunneling risk.

      0.05 (5%)
      
    • minVelocityForRestitution: number

      Minimum relative velocity for restitution (bounce) in CCD. Below this, collisions are perfectly inelastic. Unit: m/s

      1.0
      
    contacts: { contactPointPreserveLambdaMaxDistSq: number }

    Contact cache settings

    Type Declaration

    • contactPointPreserveLambdaMaxDistSq: number

      Maximum allowed distance between old and new contact point to preserve contact forces for warm start. Unit: meters²

      0.0001 (0.01² or 1cm²)
      
    gravity: Vec3

    Gravity vector. Unit: m/s²

    [0,-9.81,0]
    
    gravityEnabled: boolean

    Enable/disable gravity globally.

    true
    
    layers: Layers

    Collision layers

    narrowphase: {
        collideOnlyWithActiveEdges: boolean;
        collideWithBackfaces: boolean;
        collisionTolerance: number;
        manifoldTolerance: number;
        normalCosMaxDeltaRotation: number;
        penetrationTolerance: number;
        returnDeepestPoint: boolean;
        speculativeContactDistance: number;
        useManifoldReduction: boolean;
    }

    Narrowphase collision detection settings

    Type Declaration

    • collideOnlyWithActiveEdges: boolean

      When false, we prevent collision against non-active (shared) edges. Mainly useful for triangle meshes to avoid ghost collisions at shared edges.

      true
      
    • collideWithBackfaces: boolean

      Collide with backfaces during raycasts/shapecasts.

      false
      
    • collisionTolerance: number

      If objects are closer than this distance, they are considered to be colliding (used for GJK). Unit: meters

      1e-4
      
    • manifoldTolerance: number

      Max distance to use to determine if two points are on the same plane for determining the contact manifold between two shape faces. Unit: meters

      1e-3 (1mm)
      
    • normalCosMaxDeltaRotation: number

      Maximum angle between normals that allows manifolds between different sub shapes of the same body pair to be combined. Stored as cos(max angle).

      cos(5°) ≈ 0.996
      
    • penetrationTolerance: number

      A factor that determines the accuracy of the penetration depth calculation. If the change of the squared distance is less than tolerance * current_penetration_depth^2 the algorithm will terminate. Unit: dimensionless

      1e-4
      
    • returnDeepestPoint: boolean

      Whether to return the deepest point during collision detection.

      false
      
    • speculativeContactDistance: number

      Radius around objects inside which speculative contact points will be detected. Note that if this is too big you will get ghost collisions as speculative contacts are based on the closest points during the collision detection step which may not be the actual closest points by the time the two objects hit. Unit: meters

      0.02 (2cm)
      
    • useManifoldReduction: boolean

      Whether or not to reduce manifolds with similar contact normals into one contact manifold. This groups contacts with similar normals that come from different SubShapeIDs (e.g. different triangles in a mesh shape or different compound shapes). If you need to track exactly which SubShapeIDs are in contact, turn this off per-body using body.useManifoldReduction = false.

      true
      
    sleeping: {
        allowSleeping: boolean;
        pointVelocitySleepThreshold: number;
        timeBeforeSleep: number;
    }

    Sleeping options

    Type Declaration

    • allowSleeping: boolean

      If objects can go to sleep or not. Sleeping bodies are excluded from physics simulation until woken.

      true
      
    • pointVelocitySleepThreshold: number

      To detect if an object is sleeping, we use 3 points:

      • The center of mass.
      • The centers of the faces of the bounding box that are furthest away from the center.

      The movement of these points is tracked and if the velocity of all 3 points is lower than this value, the object is allowed to go to sleep. Unit: m/s

      0.03 (3cm/s)
      
    • timeBeforeSleep: number

      Time before object is allowed to go to sleep. Unit: seconds

      0.5
      
    solver: {
        baumgarteFactor: number;
        maxPenetrationDistance: number;
        minVelocityForRestitution: number;
        penetrationSlop: number;
        positionIterations: number;
        velocityIterations: number;
        warmStartImpulseRatio: number;
        warmStarting: boolean;
    }

    Solver options

    Type Declaration

    • baumgarteFactor: number

      Baumgarte stabilization factor (how much of the position error to 'fix' in 1 update). Unit: dimensionless Range: 0 (nothing) to 1 (100%)

      0.2 (20%)
      
    • maxPenetrationDistance: number

      Maximum distance to correct in a single iteration when solving position constraints. Unit: meters

      0.2 (20cm)
      
    • minVelocityForRestitution: number

      Minimal velocity needed before a collision can be elastic. If the relative velocity between colliding objects in the direction of the contact normal is lower than this, the restitution will be zero regardless of the configured value. This lets an object settle sooner. Unit: m/s

      1.0
      
    • penetrationSlop: number

      How much bodies are allowed to sink into each other. Used to avoid jitter when objects are stacked. Unit: meters

      0.02 (2cm)
      
    • positionIterations: number

      Number of solver position iterations to run.

      2
      
    • velocityIterations: number

      Number of solver velocity iterations to run. Note that this needs to be >= 2 in order for friction to work (friction is applied using the non-penetration impulse from the previous iteration).

      10
      
    • warmStartImpulseRatio: number

      Scale factor for warm start impulses.

      1.0
      
    • warmStarting: boolean

      Whether or not to use warm starting for constraints (initially applying previous frames impulses). This helps the solver converge faster.

      true