Builtin Library
README.md
spline.placement
Placement helpers layered on top of spline.core sampling. Use this
to distribute instances along a path, generate fence-post transforms,
or constrain an entity to a normalised progress value on a spline.
Each returned placement carries position, forward, right,
rotation, and the source t.
Exports
Placement.distribute(path, count, opts?) -> { Placement }—countevenly spaced placements (int).Placement.distributeBySpacing(path, spacing, opts?) -> { Placement }— placements at constant world-space spacing.Placement.fence(path, spacing, opts?) -> { Placement }— alias fordistributeBySpacingwith fence-shaped semantics.Placement.constrain(entityId, path, progress, opts?) -> Placement?— set an entity's local position/rotation to a spline progress value.Placement.midpoint(a, b) -> Vec3— convenience midpoint helper for two vec3-shaped points.
Types:
PlacementOpts = { up?: Vec3, verticalOffset?: number, lateralOffset?: number, easing?: ..., steps?: number, orientToPath?: boolean }Placement = { t: number, position: Vec3, forward: Vec3, right: Vec3, rotation: Quat }Quat = { x: number, y: number, z: number, w: number }
Usage
local Placement = require("@builtin::modules.spline.placement")
local posts = Placement.distributeBySpacing(path, 1.5, { lateralOffset = 0.6 })
for _, p in ipairs(posts) do
local e = entity.spawn("post")
e.localPosition = { p.position.x, p.position.y, p.position.z }
e.localRotation = { p.rotation.x, p.rotation.y, p.rotation.z, p.rotation.w }
end
Placement.constrain(playerId, path, currentProgress)
Notes
- Default up vector is
{x=0, y=1, z=0}. Override viaopts.upfor non-Y-up worlds. lateralOffsetdisplaces the placement along the spline's right vector (perpendicular to forward, in the up plane).verticalOffsetdisplaces along the up vector.constrainreturnsnilwhen the entity id is invalid; passorientToPath = falseto update position without touching rotation.