ConstraintBuilders Module
Factory functions for constructing constraint-related SimulationCommand messages from simple F# values.
These builders hide the nested proto message hierarchy (ConstraintType → AddConstraint → SimulationCommand).
Use batchAdd to send the resulting commands. Constraint IDs can be generated with nextId "constraint".
Functions and values
| Function or value |
Description
|
Full Usage:
makeAngularMotorCmd id bodyA bodyB targetVelocity maxForce
Parameters:
string
-
Unique constraint ID.
bodyA : string
-
ID of the first body.
bodyB : string
-
ID of the second body.
targetVelocity : float * float * float
-
Target angular velocity (x, y, z) in rad/s.
maxForce : float
-
Maximum force the motor can apply.
Returns: SimulationCommand
|
Builds an
|
Full Usage:
makeBallSocketCmd id bodyA bodyB offsetA offsetB
Parameters:
string
-
Unique constraint ID. Use nextId "constraint" for auto-generated IDs.
bodyA : string
-
ID of the first body.
bodyB : string
-
ID of the second body.
offsetA : float * float * float
-
Local-space offset on body A (x, y, z) where the socket attaches.
Example: (0.0, 0.5, 0.0) = top of a 1m-tall body.
offsetB : float * float * float
-
Local-space offset on body B (x, y, z) where the socket attaches.
Returns: SimulationCommand
A SimulationCommand ready for batchAdd.
|
Builds an
Example
val joint: obj
|
Full Usage:
makeDistanceLimitCmd id bodyA bodyB minDist maxDist
Parameters:
string
-
Unique constraint ID.
bodyA : string
-
ID of the first body.
bodyB : string
-
ID of the second body.
minDist : float
-
Minimum allowed distance in meters. Use 0 for no minimum.
maxDist : float
-
Maximum allowed distance in meters. Typical: 1.0–10.0 for chain links.
Returns: SimulationCommand
A SimulationCommand ready for batchAdd.
|
Builds an
Example
val chain: obj
|
Full Usage:
makeDistanceSpringCmd id bodyA bodyB offsetA offsetB targetDistance
Parameters:
string
-
Unique constraint ID.
bodyA : string
-
ID of the first body.
bodyB : string
-
ID of the second body.
offsetA : float * float * float
-
Local-space offset on body A (x, y, z).
offsetB : float * float * float
-
Local-space offset on body B (x, y, z).
targetDistance : float
-
Target distance in meters that the spring pulls toward.
Returns: SimulationCommand
|
Builds an
|
Full Usage:
makeHingeCmd id bodyA bodyB axis offsetA offsetB
Parameters:
string
-
Unique constraint ID.
bodyA : string
-
ID of the first body.
bodyB : string
-
ID of the second body.
axis : float * float * float
-
Hinge axis direction (x, y, z). Example: (0.0, 1.0, 0.0) for vertical hinge,
(1.0, 0.0, 0.0) for horizontal hinge along X.
offsetA : float * float * float
-
Local-space attachment offset on body A.
offsetB : float * float * float
-
Local-space attachment offset on body B.
Returns: SimulationCommand
A SimulationCommand ready for batchAdd.
|
Builds an
Example
val hinge: obj
|
Full Usage:
makeLinearAxisMotorCmd id bodyA bodyB offsetA offsetB axis targetVelocity maxForce
Parameters:
string
-
Unique constraint ID.
bodyA : string
-
ID of the first body.
bodyB : string
-
ID of the second body.
offsetA : float * float * float
-
Local-space offset on body A (x, y, z).
offsetB : float * float * float
-
Local-space offset on body B (x, y, z).
axis : float * float * float
-
Local axis direction (x, y, z) for the motor.
targetVelocity : float
-
Target velocity along the axis in m/s.
maxForce : float
-
Maximum force the motor can apply.
Returns: SimulationCommand
|
Builds an
|
Full Usage:
makePointOnLineCmd id bodyA bodyB origin direction offset
Parameters:
string
-
Unique constraint ID.
bodyA : string
-
ID of the first body.
bodyB : string
-
ID of the second body.
origin : float * float * float
-
Local origin of the line on body A (x, y, z).
direction : float * float * float
-
Local direction of the line (x, y, z).
offset : float * float * float
-
Local offset on body B (x, y, z).
Returns: SimulationCommand
|
Builds an
|
Full Usage:
makeRemoveConstraintCmd constraintId
Parameters:
string
-
The ID of the constraint to remove. Must match a previously added constraint.
Returns: SimulationCommand
A SimulationCommand ready for batchAdd.
|
Builds a
Example
val remove: obj
|
Full Usage:
makeSwingLimitCmd id bodyA bodyB axisA axisB maxAngle
Parameters:
string
-
Unique constraint ID.
bodyA : string
-
ID of the first body.
bodyB : string
-
ID of the second body.
axisA : float * float * float
-
Local axis on body A (x, y, z).
axisB : float * float * float
-
Local axis on body B (x, y, z).
maxAngle : float
-
Maximum swing angle in radians.
Returns: SimulationCommand
|
Builds an
|
Full Usage:
makeTwistLimitCmd id bodyA bodyB axisA axisB minAngle maxAngle
Parameters:
string
-
Unique constraint ID.
bodyA : string
-
ID of the first body.
bodyB : string
-
ID of the second body.
axisA : float * float * float
-
Local axis on body A (x, y, z).
axisB : float * float * float
-
Local axis on body B (x, y, z).
minAngle : float
-
Minimum twist angle in radians.
maxAngle : float
-
Maximum twist angle in radians.
Returns: SimulationCommand
|
Builds an
|
Full Usage:
makeWeldCmd id bodyA bodyB
Parameters:
string
-
Unique constraint ID.
bodyA : string
-
ID of the first body.
bodyB : string
-
ID of the second body. The bodies are welded at their current relative position and orientation.
Returns: SimulationCommand
A SimulationCommand ready for batchAdd.
|
Builds an
Example
val weld: obj
|
PhysicsSandbox