Paths
Looping Paths
Connects the final control point back to the first for continuous tracks.
Call set_loop(true) before build_smooth(). A loop requires at least three points and adds a Hermite segment from the final point back to the first.
Creating a loop#
var loop = jolt_path();
loop.add_point(-7, 12, 3, 0);
loop.add_point(0, 7, 5, 30);
loop.add_point(7, 12, 3, 90);
loop.add_point(0, 17, 1, 0);
loop.set_loop(true);
loop.build_smooth();Loop state#
loop.is_loop();
loop.set_loop(false);Changing loop state discards the native build. Call build_smooth() again before sampling or creating a constraint.
Wrapped distances#
- Distance sampling wraps with modulo path length.
- Negative distances wrap backward around the loop.
- Motor target distances use the same arc-length-to-fraction conversion.
- Normalized fraction sampling remains in the public range 0 through 1.
Continuous tangents#
Every automatically generated loop tangent uses the previous and next point with wrapped indices. The last-to-first join is therefore smoothed by the same rule as every other control point.
Motorized loop#
var rail = jolt_path_world(cart, loop, {
rotation_mode: JOLT_PATH_ROTATION_FOLLOW,
motor_max_force: 500,
motor_velocity: 4
});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 |
|---|---|---|
| JoltPath.is_loop | JoltPath.is_loop() | set_loop Boolean result, change discards build; is_loop Boolean, count number/0 on error. get_point(zero-based index) copies position/roll/tangent/explicit_tangent or returns undefined. |
| JoltPath.set_loop | JoltPath.set_loop(loop) | set_loop Boolean result, change discards build; is_loop Boolean, count number/0 on error. get_point(zero-based index) copies position/roll/tangent/explicit_tangent or returns undefined. |