PhysicsSystem

PhysicsSystem

A physics system using Cannon.js.

Constructor

new PhysicsSystem(settingsopt)

Parameters:
Name Type Attributes Description
settings Object <optional>
Properties
Name Type Attributes Description
gravity Vector3 <optional>

Members

cannonWorld :CANNON.World

Methods

getGravity(store)

Parameters:
Name Type Description
store Vector3

raycastAll(start, direction, maxDistance, optionsopt, callback) → {boolean}

Make a ray cast into the world of colliders, evaluating the given callback once at every hit.

Parameters:
Name Type Attributes Description
start Vector3
direction Vector3
maxDistance number
options Object <optional>
Properties
Name Type Attributes Default Description
collisionMask number <optional>
-1
collisionGroup number <optional>
-1
skipBackFaces number <optional>
true
callback function

raycastAny(start, direction, maxDistance, optionsopt, resultopt) → {boolean}

Make a ray cast into the world of colliders, stopping at the first hit that the ray intersects. Note that there's
no given order in the traversal, and there's no control over what will be returned.

Parameters:
Name Type Attributes Description
start Vector3
direction Vector3
maxDistance number
options Object <optional>
Properties
Name Type Attributes Default Description
collisionMask number <optional>
-1
collisionGroup number <optional>
-1
skipBackFaces number <optional>
true
result RaycastResult <optional>

raycastClosest(start, direction, maxDistance, optionsopt, resultopt) → {boolean}

Make a ray cast into the world of colliders, and only return the closest hit.

Parameters:
Name Type Attributes Description
start Vector3
direction Vector3
maxDistance number
options Object <optional>
Properties
Name Type Attributes Default Description
collisionMask number <optional>
-1
collisionGroup number <optional>
-1
skipBackFaces number <optional>
true
result RaycastResult <optional>

setGravity(gravityVector)

Parameters:
Name Type Description
gravityVector Vector3

start()

Starts simulation.

stop()

Stops simulation.