Builtin Library
README.md
spline
Reusable spline library for rails, paths, procedural placement, and
debug drawing. Aggregates the core, placement, and drawing
sub-modules into a single namespace so callers only need one require.
Supports:
- linear, Catmull-Rom, and Bezier curves
- eased traversal modes (
linear,easeInQuad,easeOutSine,easeInOutCubic, etc.) - sampling by count or by spacing
- placement helpers for repeated items (fence posts, distributed instances)
- runtime constraint of an entity to a spline progress value
- lightweight debug drawing using spawned markers and segment meshes
Exports
Curve construction (forwarded from spline.core):
M.new(points, opts)/M.linear(points, opts)/M.catmullRom(points, opts)/M.bezier(points, opts)
Sampling and queries (forwarded from spline.core):
M.evaluate(path, t)/M.evaluateEased(path, t, easing)M.tangent(path, t)/M.length(path, steps?)M.sample(path, count, opts?)/M.sampleBySpacing(path, spacing, opts?)M.closestProgress(path, point, steps?)/M.resolveEasing(easing)/M.easingNames()M.measure(pathOrPoints, opts?)/M.atDistance(measured, distance, wrap?): the curve by arc length, read at constant speed
Placement helpers (forwarded from spline.placement):
M.distribute(path, count, opts?)/M.distributeBySpacing(path, spacing, opts?)M.fence(path, spacing, opts?)/M.constrain(entityId, path, progress, opts?)
Debug drawing (forwarded from spline.drawing):
M.draw(path, opts?)/M.drawMarkers(path, opts?)/M.drawSegments(path, opts?)/M.clearDrawn(ids)
Sub-module handles:
M.placement: table— the rawspline.placementtable.M.drawing: table— the rawspline.drawingtable.
Usage
local spline = require("@builtin::modules.spline")
local path = spline.new({
{ x = -6, y = 0, z = 0 },
{ x = -2, y = 2, z = 4 },
{ x = 2, y = 2, z = -4 },
{ x = 6, y = 0, z = 0 },
}, { mode = "catmullRom" })
local pos = spline.evaluateEased(path, 0.35, "easeInOutSine")
local posts = spline.fence(path, 1.5, { lateralOffset = 0.6 })
Notes
- To move an entity along a spline at a constant speed, add the
PathFollowercomponent and callfollow(path)with the spline. - For networks of paths (roads, tracks, rails, lanes, routes) with junctions, drivable surfaces, terrain conformance and route queries, use
@builtin::modules.pathNetwork. - See the sub-module READMEs for full signatures:
spline.module/core.module,spline.module/placement.module,spline.module/drawing.module.