Constructors

Fields Summary

Functions Summary

wade.physics.addJoint (jointData)

Adds a joint to the simulation
wade.physics.debugDrawJoint (joint, active)

Draw the joint using debug graphics
wade.physics.exportScene (stringify)

Exports all joints currently in the joint list
wade.physics.getGravity ()

Get the current gravity vector
wade.physics.getJoint (name)

Retrieve a joint object using it's name
wade.physics.getPositionIterations ()

Get the current number of iterations for the physics position solver.
wade.physics.getTimeStep ()

Get the current time step value for the physics simulation
wade.physics.getVelocityIterations ()

Get the current number of iterations for the physics velocity solver.
wade.physics.importScene (data, callback)

Imports joints into the scene
wade.physics.init (options)

Initialize the physics plugin.
wade.physics.isInitialized ()

Check whether the physics engine has been initialized.
wade.physics.isRunning ()

Check whether the physics simulation is currently running
wade.physics.isStepping ()

Check whether we are in the middle of a physics step
wade.physics.removeJoint (jointObject)

Removes the provided joint from the simulation
wade.physics.serializeJoint (joint)

Serializes this list of joints and returns the result
wade.physics.setGravity (gravity)

Set a new value for gravity (by default gravity is {x:0, y:9.81}
wade.physics.setPositionIterations (positionIterations)

Set the number of iterations for the physics position solver. By default this is 4.
wade.physics.setTimeStep (timeStep)

Set the time step value for the physics simulation. By default this matches WADE's simulation time step (1/60 seconds)
wade.physics.setVelocityIterations (velocityIterations)

Get the current number of iterations ofr the physics velocity solver. By default this is 2.
wade.physics.startSimulation ()

Start the physics simulation. Note that the simulation is started automatically when wade.physics.init() is called, so it only makes sense to call this function after a call to stopSimulation().
wade.physics.step ()

Step the box2d physics world forward. This normally happens automatically.
wade.physics.stopSimulation ()

Stop (pause) the physics simulation.

Fields Details

Function Details

wade.physics.addJoint (jointData)

Adds a joint to the simulation

object jointData : An object containing the joint type, and scene objects to connect


Returns object : joint A joint interface created from joint data

^
wade.physics.debugDrawJoint (joint, active)

Draw the joint using debug graphics

object joint : A joint object, as returned by wade.physics.createJoint() or wade.physics.getJoint()


boolean active : Whether to enable or disable debug-drawing


Returns SceneObject : The SceneObject used to display the debug graphics

^
wade.physics.exportScene (stringify)

Exports all joints currently in the joint list

stringify : If true, a stringified json object is returned, if false, a javascript object is returned


Returns object : data An object containing a joints array

^
wade.physics.getGravity ()

Get the current gravity vector

Returns {x: number, y: number} : The current gravity vector

^
wade.physics.getJoint (name)

Retrieve a joint object using it's name

string name : The name of the joint that is to be retrieved


Returns object : The joint object, or null, if there is no joint with the provided name

^
wade.physics.getPositionIterations ()

Get the current number of iterations for the physics position solver.

Returns number : The current number of iterations for the physics position solver.

^
wade.physics.getTimeStep ()

Get the current time step value for the physics simulation

Returns number : The current time step value for the physics simulation

^
wade.physics.getVelocityIterations ()

Get the current number of iterations for the physics velocity solver.

Returns number : The current number of iterations for the physics velocity solver.

^
wade.physics.importScene (data, callback)

Imports joints into the scene

data : An object that contains a joints array


callback : Executed after a zero timeout

^
wade.physics.init (options)

Initialize the physics plugin.
This function must be called once for the physics simulation to work.
This normally happens automatically the fist time you try to use the physics engine and you don't need to call it directly from your code.

object options (optional): An object with some of the following fields, which are all optional:

  • gravity: an object with x and y fields, describing the gravity in meters/seconds squared. By default, this is {x:0, y:9.81}.

  • timeStep: the time interval used in the box2d Step function. Default is wade.c_timeStep

  • positionIterations: a number describing how many positions iterations to use in the box2d solver. Default is 4

  • velocityIterations: a number describing how many velocity iterations to use in the box2d solver. Default is 2

^
wade.physics.isInitialized ()

Check whether the physics engine has been initialized.

Returns boolean : Whether the physics engine has been initialized.

^
wade.physics.isRunning ()

Check whether the physics simulation is currently running

Returns boolean : Whether the physics simulation is currently running

^
wade.physics.isStepping ()

Check whether we are in the middle of a physics step

Returns : {boolean}

^
wade.physics.removeJoint (jointObject)

Removes the provided joint from the simulation

object jointObject : The joint object to remove

^
wade.physics.serializeJoint (joint)

Serializes this list of joints and returns the result

Returns object : serialized A serialized version of the joint interface object

^
wade.physics.setGravity (gravity)

Set a new value for gravity (by default gravity is {x:0, y:9.81}

{x: number, y: number} gravity : The new gravity vector

^
wade.physics.setPositionIterations (positionIterations)

Set the number of iterations for the physics position solver. By default this is 4.

number positionIterations : The number of iterations for the physics position solver. Use a larger number for greater accuracy (but it will be slower)

^
wade.physics.setTimeStep (timeStep)

Set the time step value for the physics simulation. By default this matches WADE's simulation time step (1/60 seconds)

number timeStep : The length (in seconds) of the time step for the physics simulation

^
wade.physics.setVelocityIterations (velocityIterations)

Get the current number of iterations ofr the physics velocity solver. By default this is 2.

number velocityIterations : The number of iterations for the physics velocity solver. Use a larger number for greater accuracy (but it will be slower)

^
wade.physics.startSimulation ()

Start the physics simulation. Note that the simulation is started automatically when wade.physics.init() is called, so it only makes sense to call this function after a call to stopSimulation().
^
wade.physics.step ()

Step the box2d physics world forward. This normally happens automatically.
^
wade.physics.stopSimulation ()

Stop (pause) the physics simulation.
^