API Docs for: 0.6.1
Show:

World Class

Extends EventTarget
Defined in: src/world/World.js:24

The physics world

Constructor

World

()

Methods

add

(
  • body
)
deprecated

Defined in src/world/World.js:238

Deprecated: Use .addBody instead

Add a rigid body to the simulation.

Parameters:

addConstraint

(
  • c
)

Add a constraint to the simulation.

Parameters:

addContactMaterial

(
  • cmat
)

Adds a contact material to the World

Parameters:

addEventListener

(
  • type
  • listener
)
EventTarget

Add an event listener

Parameters:

  • type String
  • listener Function

Returns:

EventTarget:

The self object, for chainability.

addMaterial

(
  • m
)

Adds a material to the World.

Parameters:

collisionMatrixTick

()

Store old collision state info

dispatchEvent

(
  • event
)
EventTarget

Emit an event.

Parameters:

  • event Object
    • type String

Returns:

EventTarget:

The self object, for chainability.

getContactMaterial

(
  • m1
  • m2
)
Contactmaterial

Get the contact material between materials m1 and m2

Parameters:

Returns:

Contactmaterial:

The contact material if it was found.

hasEventListener

(
  • type
  • listener
)
Boolean

Check if an event listener is added

Parameters:

  • type String
  • listener Function

Returns:

Boolean:

numObjects

() Number deprecated

Get number of objects in the world.

Returns:

Number:

rayTest

(
  • from
  • to
  • result
)

Raycast test

Parameters:

remove

(
  • body
)

Remove a rigid body from the simulation.

Parameters:

removeConstraint

(
  • c
)

Removes a constraint

Parameters:

removeEventListener

(
  • type
  • listener
)
EventTarget

Remove an event listener

Parameters:

  • type String
  • listener Function

Returns:

EventTarget:

The self object, for chainability.

step

(
  • dt
  • [timeSinceLastCalled]
  • [maxSubSteps=10]
)

Step the physics world forward in time.

There are two modes. The simple mode is fixed timestepping without interpolation. In this case you only use the first argument. The second case uses interpolation. In that you also provide the time since the function was last used, as well as the maximum fixed timesteps to take.

Parameters:

  • dt Number

    The fixed time step size to use.

  • [timeSinceLastCalled] Number optional

    The time elapsed since the function was last called.

  • [maxSubSteps=10] Number optional

    Maximum number of fixed steps to take per function call.

Example:

// fixed timestepping without interpolation
world.step(1/60);

step

(
  • dt
)

Step the simulation

Parameters:

  • dt Number

Properties

allowSleep

Boolean

Makes bodies go to sleep when they've been inactive

bodies

Array

broadphase

Broadphase

collisionMatrix

ArrayCollisionMatrix

collisionMatrixPrevious

ArrayCollisionMatrix

CollisionMatrix from the previous step.

constraints

Array

contactmaterials

Array

contactMaterialTable

TupleDictionary

Used to look up a ContactMaterial given two instances of Material.

contacts

Array

All the current contacts (instances of ContactEquation) in the world.

defaultContactMaterial

ContactMaterial

This contact material is used if no suitable contactmaterial is found for a contact.

doProfiling

Boolean

dt

Number

Last used timestep. Is set to -1 if not available.

gravity

Vec3

materials

Array

All added materials

narrowphase

Narrowphase

profile

Object

quatNormalizeFast

Boolean

Set to true to use fast quaternion normalization. It is often enough accurate to use. If bodies tend to explode, set to false.

quatNormalizeSkip

Number

How often to normalize quaternions. Set to 0 for every step, 1 for every second etc.. A larger value increases performance. If bodies tend to explode, set to a smaller value (zero to be sure nothing can go wrong).

solver

Solver

stepnumber

Number

Number of timesteps taken since start

subystems

Array

time

Number

The wall-clock time since simulation start