Table Of Contents

Previous topic

19.2. The CollisionObject Object

Next topic

19.4. The DynamicsWorld object

This Page

19.3. The Constraint Object

A Constraint object represents a physics constraint between two rigid bodies.

This is the list of supported constraints:

  • Point to Point
  • Hinge
  • Cone Twist
  • 6 Degrees of Freedom
  • Slider

These constraints can be constructed with methods on the PhysicsDevice.

19.3.1. Properties

19.3.1.1. bodyA

Summary

The first body the constraint applies to.

Syntax

var bodyA = constraint.bodyA;

Note

Read Only

19.3.1.2. bodyB

Summary

The second body the constraint applies to.

Syntax

var bodyB = constraint.bodyB;

Note

Read Only

19.3.1.3. transformA

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

19.3.1.4. transformB

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

19.3.1.5. type

Summary

Name of the constraint type.

Syntax

var constraintTypeName = constraint.type;

Note

Read Only

19.3.2. Point2Point Properties

19.3.2.1. pointA

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);

19.3.2.2. pointB

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);

19.3.2.3. force

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);

19.3.2.4. damping

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);

19.3.2.5. impulseClamp

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;

19.3.3. Hinge Properties

19.3.3.1. low

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;

19.3.3.2. high

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;

19.3.4. ConeTwist Properties

19.3.4.1. swingSpan1

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;

19.3.4.2. swingSpan2

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;

19.3.4.3. twistSpan

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;

19.3.4.4. twistAngle

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

19.3.5. 6DOF Properties

19.3.5.1. linearLowerLimit

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);

19.3.5.2. linearUpperLimit

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);

19.3.5.3. angularLowerLimit

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);

19.3.5.4. angularUpperLimit

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);

19.3.6. Slider Properties

19.3.6.1. linearLowerLimit

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;

19.3.6.2. linearUpperLimit

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;

19.3.6.3. angularLowerLimit

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);

19.3.6.4. angularUpperLimit

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;