Skip to content

Latest commit

 

History

History
244 lines (109 loc) · 3.49 KB

File metadata and controls

244 lines (109 loc) · 3.49 KB

Home > server > Simulation

Simulation class

Represents the physics simulation for a world.

Signature:

export default class Simulation extends EventRouter 

Extends: EventRouter

Remarks

The simulation internally and automatically handles the physical interactions, collisions, contact forces, and events for all aspects of the world. Most methods are not often used directly, but are provided for advanced usage.

Events

This class is an EventRouter, and instances of it emit events with payloads listed under SimulationEventPayloads

The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the Simulation class.

Properties

Property

Modifiers

Type

Description

gravity

readonly

RAPIER.Vector3

The gravity vector for the simulation.

isDebugRaycastingEnabled

readonly

boolean

Whether the simulation has debug raycasting enabled

isDebugRenderingEnabled

readonly

boolean

Whether the simulation has debug rendering enabled.

timestepS

readonly

number

The fixed timestep for the simulation.

world

readonly

World

The world the simulation is for.

Methods

Method

Modifiers

Description

enableDebugRaycasting(enabled)

Enables or disables debug raycasting for the simulation. This will render lines for the raycast that disappear after a few seconds.

enableDebugRendering(enabled, filterFlags)

Enables or disables debug rendering for the simulation. When enabled, all colliders and rigid body outlines will be rendered in the world. Do not enable this in production. In large worlds enabling this can cause noticable lag and RTT spikes.

getContactManifolds(colliderHandleA, colliderHandleB)

Gets the contact manifolds for a pair of colliders.

raycast(origin, direction, length, options)

Casts a ray through the simulation.

setGravity(gravity)

Sets the gravity vector for the simulation.