A Constraint object represents a physics constraint between two rigid bodies.
This is the list of supported constraints:
These constraints can be constructed with methods on the PhysicsDevice.
Summary
The first body the constraint applies to.
Syntax
var bodyA = constraint.bodyA;
Note
Read Only
Summary
The second body the constraint applies to.
Syntax
var bodyB = constraint.bodyB;
Note
Read Only
Summary
The Matrix43 object representing the frame of reference of the constraint for bodyA. It can only be modified for constraints of type slider or D6.
Syntax
// Get the current frame
var matrix = constraint.transformA;
// Set it to the origin
constraint.transformA = mathDevice.m43BuildIdentity();
Note
Not present on the Point2Point constraint
Summary
The Matrix43 object representing the frame of reference of the constraint for bodyB. It can only be modified for constraints of type slider or D6.
Syntax
// Get the current frame
var matrix = constraint.transformB;
// Set it to the origin
constraint.transformB = mathDevice.m43BuildIdentity();
Note
Not present on the Point2Point constraint
Summary
Name of the constraint type.
Syntax
var constraintTypeName = constraint.type;
Note
Read Only
Summary
The Vector3 value representing the local pivot point on bodyA.
Syntax
// Get the current pointA
var pointA = constraint.pointA;
// Set a new pivot point for bodyA
constraint.pointA = mathDevice.v3Build(0, 0, 1);
Summary
The Vector3 value representing the local pivot point on bodyB.
Syntax
// Get the current pointB
var pointA = constraint.pointB;
// Set a new pivot point for bodyB
constraint.pointB = mathDevice.v3Build(0, 0, 1);
Summary
The scalar value representing the maximum force for the constraint. Synonymous to tau in the bullet documentation.
Syntax
// Get the current force
var force = constraint.force;
// Double it
constraint.force = (2.0 * force);
Summary
The scalar value representing the damping of the constraint.
Syntax
// Get the current damping
var damping = constraint.damping;
// Half it
constraint.damping = (0.5 * damping);
Summary
The scalar value representing the impulse clamp of the constraint. A value of 0.0 means no clamp exists.
Syntax
// Get the current clamp
var clamp = constraint.impulseClamp;
// Change the clamp
constraint.impulseClamp = 2.0;
Summary
The scalar value representing the lower limit of the constraint’s rotation (in radians).
Syntax
// Get the current lower limit
var lowerLimit = constraint.low;
// Set a new lower limit
constraint.low = Math.PI / 2;
Summary
The scalar value representing the upper limit of the constraint’s rotation (in radians).
Syntax
// Get the current upper limit
var upperLimit = constraint.high;
// Set a new upper limit
constraint.high = Math.PI;
Summary
The scalar value representing the angle used to form the ellipsis in one axis (in radians).
Syntax
// Get the current lower limit
var swingSpan1 = constraint.swingSpan1;
// Set a new lower limit
constraint.swingSpan1 = Math.PI / 2;
Summary
The scalar value representing the angle used to form the ellipsis in one axis (in radians).
Syntax
// Get the current lower limit
var swingSpan2 = constraint.swingSpan2;
// Set a new lower limit
constraint.swingSpan2 = Math.PI / 2;
Summary
The scalar value representing the limit of the rotation around the x-axis (in radians).
Syntax
// Get the current lower limit
var twistSpan = constraint.twistSpan;
// Set a new lower limit
constraint.twistSpan = Math.PI / 2;
Summary
The scalar value representing the angle with the x-axis the body can rotate to (in radians).
Syntax
// Get the twist angle
var twistAngle = constraint.twistAngle;
Note
Read Only
Summary
The Vector3 value representing the translational lower limit for each axis. Each component of the vector represents the lower limit in that axis.
Syntax
// Get the current lower limit
var linearLowerLimit = constraint.linearLowerLimit;
// Set a new lower limit
constraint.linearLowerLimit = mathDevice.v3Build(1, 1, 1);
Summary
The Vector3 value representing the translational upper limit for each axis. Each component of the vector represents the upper limit in that axis.
Syntax
// Get the current upper limit
var linearUpperLimit = constraint.linearUpperLimit;
// Set a new upper limit
constraint.linearUpperLimit = mathDevice.v3Build(1, 1, 1);
Summary
The Vector3 value representing the angular motion lower limit for each axis. Each component of the vector represents the lower limit in that axis (in radians).
Syntax
// Get the current lower limit
var angularLowerLimit = constraint.angularLowerLimit;
// Set a new lower limit
constraint.angularLowerLimit = mathDevice.v3Build(-Math.PI, -Math.PI, -Math.PI);
Summary
The Vector3 value representing the angular motion upper limit for each axis. Each component of the vector represents the upper limit in that axis (in radians).
Syntax
// Get the current upper limit
var angularUpperLimit = constraint.angularUpperLimit;
// Set a new upper limit
constraint.angularUpperLimit = mathDevice.v3Build(Math.PI, Math.PI, Math.PI);
Summary
The scalar value representing the translational lower limit for the x-axis.
Syntax
// Get the current lower limit
var linearLowerLimit = constraint.linearLowerLimit;
// Set a new lower limit
constraint.linearLowerLimit = -3.0;
Summary
The scalar value representing the translational upper limit for the x-axis.
Syntax
// Get the current upper limit
var linearUpperLimit = constraint.linearUpperLimit;
// Set a new upper limit
constraint.linearUpperLimit = 3.0;
Summary
The scalar value representing the angular motion lower limit for the x-axis (in radians).
Syntax
// Get the current lower limit
var angularLowerLimit = constraint.angularLowerLimit;
// Set a new lower limit
constraint.angularLowerLimit = -(Math.PI / 2);
Summary
The scalar value representing the angular motion upper limit for the x-axis (in radians).
Syntax
// Get the current upper limit
var angularUpperLimit = constraint.angularUpperLimit;
// Set a new upper limit
constraint.angularUpperLimit = Math.PI / 2;