Arbiter objects group contact, and other related data between pairs of interacting Shape objects.
These objects are created only by the internals of Physics2D and are recycled, so no references should be kept to them.
Summary
Query the contact normal for this interaction pair. The normal will always point from shapeA to shapeB.
This function will return [0, 0] when sensor is true.
Syntax
var normal = arbiter.getNormal();
// or
arbiter.getNormal(normal);
Summary
Query the rolling impulse that was applied for this Arbiter in the previous simulation step.
This value is non-zero only for interactions that involve a Circle shape.
This value is zero when sensor is true.
Syntax
var impulse = arbiter.getRollingImpulse();
Summary
Query the impulse applied to the given RigidBody by the interaction represented by this arbiter object in the previous simulation step.
The impulse returned is of 3 dimensions, the third equal to the angular impulse the interaction was responsible for.
Syntax
var impulse = arbiter.getImpulseForBody(body);
// or
arbiter.getImpulseForBody(body, impulse);
Should the input body be unrelated to this arbiter, the impulse returned will be [0, 0, 0]
Summary
Query the combined value of elasticity present for this pair of interacting shapes.
This is computed from the shapes by taking the average of material elasticities, and clamping to the range [0, 1] and may change over time should shape materials be changed.
This function returns undefined when sensor is true.
Syntax
var elasticity = arbiter.getElasticity();
Summary
Query the combined value of static friction present for this pair of interacting shapes.
This is computed from the shapes by taking the square root of the material’s static friction’s product and may change over time should shape materials be changed.
This function returns undefined when sensor is true.
Syntax
var staticFriction = arbiter.getStaticFriction();
Summary
Query the combined value of dynamic friction present for this pair of interacting shapes.
This is computed from the shapes by taking the square root of the material’s dynamic friction’s product and may change over time should shape materials be changed.
This function returns undefined when sensor is true.
Syntax
var dynamicFriction = arbiter.getDynamicFriction();
Summary
Query the combined value of rolling friction present for this pair of interacting shapes.
This is computed from the shapes by taking the square root of the material’s rolling friction’s product and may change over time should shape materials be changed.
This function returns undefined when sensor is true.
Syntax
var rollingFriction = arbiter.getRollingFriction();
Summary
Set the combined value of elasticity for this Arbiter.
This function may be called at any time outside of simulation step, but likely needs to be called from a relative preSolve event listener (which is the only time it may be called during a simulation step) so as to immediately override default computed values before physics is performed.
This function has no effect when sensor is true.
Syntax
arbiter.setElasticity(elasticity);
Summary
Set the combined value of elasticity for this Arbiter to be computed from its related Shape objects.
This may be called at any time outside of simulation step, and during a simulation step may be called only from a related preSolve event listener.
This function has no effect when sensor is true.
Syntax
arbiter.setElasticityFromShapes();
Summary
Set the combined value of static friction for this Arbiter.
This function may be called at any time outside of simulation step, but likely needs to be called from a relative preSolve event listener (which is the only time it may be called during a simulation step) so as to immediately override default computed values before physics is performed.
This function has no effect when sensor is true.
Syntax
arbiter.setStaticFriction(staticFriction);
Summary
Set the combined value of static friction for this Arbiter to be computed from its related Shape objects.
This may be called at any time outside of simulation step, and during a simulation step may be called only from a related preSolve event listener.
This function has no effect when sensor is true.
Syntax
arbiter.setStaticFrictionFromShapes();
Summary
Set the combined value of dynamic friction for this Arbiter.
This function may be called at any time outside of simulation step, but likely needs to be called from a relative preSolve event listener (which is the only time it may be called during a simulation step) so as to immediately override default computed values before physics is performed.
This function has no effect when sensor is true.
Syntax
arbiter.setDynamicFriction(dynamicFriction);
Summary
Set the combined value of dynamic friction for this Arbiter to be computed from its related Shape objects.
This may be called at any time outside of simulation step, and during a simulation step may be called only from a related preSolve event listener.
This function has no effect when sensor is true.
Syntax
arbiter.setDynamicFrictionFromShapes();
Summary
Set the combined value of rolling friction for this Arbiter.
This function may be called at any time outside of simulation step, but likely needs to be called from a relative preSolve event listener (which is the only time it may be called during a simulation step) so as to immediately override default computed values before physics is performed.
This function has no effect when sensor is true.
Syntax
arbiter.setRollingFriction(rollingFriction);
Summary
Set the combined value of rolling friction for this Arbiter to be computed from its related Shape objects.
This may be called at any time outside of simulation step, and during a simulation step may be called only from a related preSolve event listener.
This function has no effect when sensor is true.
Syntax
arbiter.setRollingFrictionFromShapes();
Summary
Query whether this Arbiter’s interaction has been accepted for computation in the time step.
This function always returns false when sensor is true.
Syntax
var accepted = arbiter.isStateAccepted();
Summary
Query whether the choice of accepting/ignoring this Arbiter’s interaction for computation in this time step is to persist until Arbiter death instead of only for a single step.
This function always returns false when sensor is true.
Syntax
var persistent = arbiter.isStatePersistent();
Summary
Set whether to accept this Arbiter’s interaction for the current time step.
This function has no effect when sensor is true.
Syntax
arbiter.setAcceptedState(false);
Summary
Set whether the decision to accept this Arbiter’s interaction for the current time step, should persist until Arbiter death instead of only for a single step.
This function has no effect when sensor is true.
Syntax
arbiter.setPersistentState(true);
Summary
The first Shape for this Arbiter. Arbiter normals and impulses are always defined relative to this shape.
Note
Read Only
Summary
The first RigidBody for this Arbiter. It will always be the case that shapeA.body === bodyA.
Note
Read Only
Summary
The second RigidBody for this Arbiter. It will always be the case that shapeB.body === bodyB.
Note
Read Only
Summary
Whether this arbiter object corresponds to a sensor type interaction. In such an interaction type there is no collision information computed, only intersection test.
Note
Read Only
Summary
Whether this arbiter object corresponds to an interaction between two sleeping objects.
Note
Read Only
Summary
This property indicates that the arbiter object is actively taking part in a simulation, when iterating lists of arbiter objects you should ignore any such inactive arbiter.
An arbiter is inactive either because it has persisted once an interaction has ended in order to cache information that may shortly be recovered, or because the arbiter is waiting to be destroyed.
Note
Read Only
The Contact object stores physics information for contact points of a collision interaction.
These objects are created only by the internals of Physics2D and are recycled, so no references should be kept to them.
Summary
Get contact position in world coordinates.
Syntax
var position = contact.getPosition();
// or
contact.getPosition(position);
If specified, the contact position will be stored in this array, otherwise a new array will be created.
The result of this operation will not effect the contact position which is immutable.
Summary
Get contact penetration, indicating how much the shapes are overlapping at this contact point along the related Arbiter normal.
Syntax
var penetration = contact.getPenetration();
Contact penetration may be negative (indicating separation) as in the edge-edge case for Polygons, 2 contact points are always computed, though only one may have been used for solving errors in velocity.
Summary
Query the signed magnitude of the normal impulse that was applied at this contact point during the simulation step.
Syntax
var normalImpulse = contact.getNormalImpulse();
Summary
Query the signed magnitude of the tangent (friction) impulse that was applied at this contact point during the simulation step.
Syntax
var tangentImpulse = contact.getTangentImpulse();
Summary
Indicates that this contact corresponds to active collision data.
When iterating contacts you should ignore any contact which is not active as it will refer to information from previous simulation steps which is persisting for purposes of caching values for possible re-use in near future.
Note
Read Only
Summary
This property indicates that the contact point was generated, but was not used during resolution of velocity errors in physics. This contact point may or may not have been used during resolution of positional errors.
A virtual contact will always have 0 normal and tangent impulse values.
Note
Read Only
Summary
This property indicates that this contact point was used for the first time in the resolution of velocity errors. This property may be used to cull contact points when determining impact impulses in collisions so as to ignore resting contacts.
Note
Read Only