Constraints
SixDOF Constraint
Configures every relative translation and rotation axis as fixed, free or limited, with per-axis friction and motors.
SixDOF is the most flexible managed joint. Use it when Fixed, Hinge, Slider, Cone or SwingTwist cannot express the intended mechanism. Its power also makes correct frame, axis and unit documentation essential.
Syntax#
jolt_sixdof(body_a, body_b, anchor_x, anchor_y, anchor_z, options=undefined)Frame and general options#
| Field | Default | Description |
|---|---|---|
| axis_x | {x:1,y:0,z:0} | Finite non-zero world-space frame X axis. |
| axis_y | {x:0,y:1,z:0} | Finite non-zero non-parallel world-space frame Y axis. |
| swing_type | JOLT_SIXDOF_SWING_CONE | CONE for elliptical symmetric swing or PYRAMID for asymmetric Y/Z swing. |
| collision | false | Whether the connected bodies may collide. |
| enabled | true | Initial solver state. |
| friction | unset | Array of up to six non-negative per-axis force/torque limits. |
Axis options#
| Field | Axis | Accepted value |
|---|---|---|
| linear_x / linear_y / linear_z | Translation X/Y/Z | JOLT_SIXDOF_FIXED, JOLT_SIXDOF_FREE, 'fixed', 'locked', 'free', or {min,max} in world units. |
| angular_x | Rotation X / twist | Fixed, free, or {min,max} in degrees within -180..180. |
| angular_y / angular_z | Coupled swing | Fixed, free, or {min,max} in degrees within -180..180. |
Constants#
| Constants | Values / meaning |
|---|---|
| JOLT_SIXDOF_TRANSLATION_X / Y / Z | 0 / 1 / 2 |
| JOLT_SIXDOF_ROTATION_X / Y / Z | 3 / 4 / 5 |
| JOLT_SIXDOF_FIXED / FREE / LIMITED | 0 / 1 / 2 |
| JOLT_SIXDOF_SWING_CONE / PYRAMID | Symmetric elliptical swing / asymmetric pyramidal swing |
Axis methods#
| Method group | Methods |
|---|---|
| Mode | set_axis_free(), set_axis_fixed(), set_axis_limit(), get_axis_mode(), is_axis_free(), is_axis_fixed() |
| Limits | get_axis_min(), get_axis_max(), get_axis_limit() |
| Translation shortcuts | set_translation_limits(), get_translation_limits_min(), get_translation_limits_max() |
| Rotation shortcuts | set_rotation_limits(), get_rotation_limits_min(), get_rotation_limits_max() |
| Friction | set_friction(axis,value), get_friction(axis) |
Rotation semantics#
- Rotation X is Jolt twist. Rotation Y and Z are coupled swing dimensions, not independent Euler clamps.
- CONE swing requires limited Y/Z ranges symmetric around zero and creates an elliptical cone.
- PYRAMID permits asymmetric Y/Z ranges.
- Linear values use world units; high-level angular limits and angular velocities use degrees.
Motor methods#
| Method | Purpose |
|---|---|
| set_axis_motor_state(axis,state) / get_axis_motor_state(axis) | Selects Off, Velocity, Position or PositionAndVelocity for one axis. |
| set_target_position(x,y,z) / get_target_position() | Translation position target in body-1 constraint space. |
| set_target_velocity(x,y,z) / get_target_velocity() | Translation velocity target in body-1 constraint space. |
| set_target_angular_velocity(x,y,z) / get_target_angular_velocity() | Angular velocity target in degrees/s, using body-2 constraint space in Jolt 5.6. |
| set_target_orientation(x,y,z,w) | Authoritative normalized quaternion orientation target. |
| set_target_orientation_euler(x,y,z) | Degree-based convenience conversion to a target quaternion. |
| get_target_orientation() / get_current_orientation() | Target and current constraint-space quaternions. |
| get_target_orientation_euler() / get_current_orientation_euler() | Convenience Euler representations. |
| set_axis_motor_limit(axis,value) / get_axis_motor_limit(axis) | Force limit for translation or torque limit for rotation. |
| set_axis_motor_spring(axis,frequency,damping) | Per-axis native position-motor spring. |
| get_axis_motor_spring(axis) | Returns {frequency,damping} for the selected SixDOF axis. Use a live SixDOF constraint and a JOLT_SIXDOF_* axis; inspect native errors immediately if readback fails. |
Soft limits and solver state#
| Method | Result |
|---|---|
| set_limit_spring(axis, frequency, damping) | Softens Translation X/Y/Z limits only. |
| get_limit_spring(axis) | Returns {frequency,damping}. |
| get_impulses() | Returns translation, rotation, motor_translation and motor_rotation vectors. |
| get_sixdof_debug_frame() | Returns the live constraint frame used by diagnostics. |
Example: slider-like Z motion#
var joint = jolt_sixdof(body_a, body_b, 0, 0, 2, {
linear_z: { min:0, max:3 },
collision: false
});Example: driven translation axis#
joint.set_axis_free(JOLT_SIXDOF_TRANSLATION_X);
joint.set_axis_motor_limit(JOLT_SIXDOF_TRANSLATION_X, 120);
joint.set_axis_motor_spring(JOLT_SIXDOF_TRANSLATION_X, 3, 0.8);
joint.set_target_position(2, 0, 0);
joint.set_axis_motor_state(JOLT_SIXDOF_TRANSLATION_X, JOLT_MOTOR_POSITION);Validation and lifecycle#
- The creator requires two different live bodies, a finite anchor and two finite, non-zero, non-parallel frame axes.
- Every limited axis needs finite ordered min/max values; angular values must remain within -180..180 degrees.
- Per-axis friction is force for translations and torque for rotations.
- Runtime mutations wake connected bodies; getters do not.
- Destroying either body invalidates the constraint. destroy() and jolt_stop() are safe and ordered.
- There is currently no jolt_sixdof_world() convenience creator.
Verified operation contracts#
These contracts distinguish units, return values, errors and lifetime according to the current implementation. Check results: false, 0 and undefined can mean different things for different methods.
| Symbol / owner | Signature | Operation contract |
|---|---|---|
| jolt_sixdof | jolt_sixdof(body_a,body_b,anchor_x,anchor_y,anchor_z,options=undefined) | Two bodies, world anchor, axis_x/y default+X/+Y. All6 axes default FIXED; linear_x/y/z m, angular_x/y/z°:FIXED/FREE or {min, max}. Default CONE requires swing Y/Z symmetry, PYRAMID allows asymmetry. Collisionfalse, enabledtrue; Constraint/undefined. |
| JoltConstraint.get_axis_limit | JoltConstraint.get_axis_limit(axis) | SixDOF axis 0..5; min/max in m for translation, ° for rotation. get_axis_limit returns {mode, minimum, maximum}. Error fallbacks are FIXED/0/0; check validity and error state. |
| JoltConstraint.get_axis_max | JoltConstraint.get_axis_max(axis) | SixDOF axis 0..5; min/max in m for translation, ° for rotation. get_axis_limit returns {mode, minimum, maximum}. Error fallbacks are FIXED/0/0; check validity and error state. |
| JoltConstraint.get_axis_min | JoltConstraint.get_axis_min(axis) | SixDOF axis 0..5; min/max in m for translation, ° for rotation. get_axis_limit returns {mode, minimum, maximum}. Error fallbacks are FIXED/0/0; check validity and error state. |
| JoltConstraint.get_axis_mode | JoltConstraint.get_axis_mode(axis) | SixDOF axis 0..5. FREE/FIXED/LIMITED mode or Boolean comparison; on error get_axis_mode returns FIXED, so is_axis_fixed can be true on error. |
| JoltConstraint.get_axis_motor_limit | JoltConstraint.get_axis_motor_limit(axis) | SixDOF axis 0..5; N for translation, N·m for rotation; 0 for invalid wrapper/type, inspect native errors separately. |
| JoltConstraint.get_axis_motor_spring | JoltConstraint.get_axis_motor_spring(axis) | SixDOF: {frequency, damping}, Hz and ratio. Motor axes 0..5, limit only 0..2; on error components may contain native fallback 0. |
| JoltConstraint.get_axis_motor_state | JoltConstraint.get_axis_motor_state(axis) | SixDOF axis 0..5, JOLT_MOTOR_* state. Setter Boolean; getter numeric mode or OFF for invalid wrapper/type. |
| JoltConstraint.is_axis_fixed | JoltConstraint.is_axis_fixed(axis) | SixDOF axis 0..5. FREE/FIXED/LIMITED mode or Boolean comparison; on error get_axis_mode returns FIXED, so is_axis_fixed can be true on error. |
| JoltConstraint.is_axis_free | JoltConstraint.is_axis_free(axis) | SixDOF axis 0..5. FREE/FIXED/LIMITED mode or Boolean comparison; on error get_axis_mode returns FIXED, so is_axis_fixed can be true on error. |
| JoltConstraint.set_axis_fixed | JoltConstraint.set_axis_fixed(axis) | SixDOF only, integer axis 0..5 (translation X/Y/Z, rotation X/Y/Z). Boolean; fixed locks at 0, free removes the limit. |
| JoltConstraint.set_axis_free | JoltConstraint.set_axis_free(axis) | SixDOF only, integer axis 0..5 (translation X/Y/Z, rotation X/Y/Z). Boolean; fixed locks at 0, free removes the limit. |
| JoltConstraint.set_axis_limit | JoltConstraint.set_axis_limit(axis,minimum,maximum) | SixDOF, integer axis 0..5; finite min≤max. Translation in m, rotation within -180..180°. Cone swing type requires symmetric Y/Z rotation limits around 0. Boolean. |
| JoltConstraint.set_axis_motor_limit | JoltConstraint.set_axis_motor_limit(axis,value) | SixDOF axis 0..5; finite nonnegative force limit (axes 0..2, N) or torque limit (3..5, N·m). Boolean. Setting a limit alone does not enable a motor. |
| JoltConstraint.set_axis_motor_spring | JoltConstraint.set_axis_motor_spring(axis,frequency,damping) | SixDOF axis 0..5; finite frequency ≥0 Hz and damping ≥0 as damping ratio. Boolean. |
| JoltConstraint.set_axis_motor_state | JoltConstraint.set_axis_motor_state(axis,state) | SixDOF axis 0..5, JOLT_MOTOR_* state. Setter Boolean; getter numeric mode or OFF for invalid wrapper/type. |