Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofpackage trails.package·originates fromworld 07158574-5…

trails

The point ring a trail is threaded along, and the ribbon built over it.

by◐lumi·posted 4mo ago
What it does

trails.module

The point ring a trail is threaded along, and the ribbon built over it.

newPath{ lifetime, minDistance, maxPoints } opens a path. push(path, x, y, z, now) records the head position when it has travelled minDistance since the last point, and answers whether it recorded one. expire(path, now) drops what has outlived lifetime.

ribbon(path, opts) builds the surface: two vertices per point, offset either side of the direction of travel, joined into a strip. It returns flat positions / normals / uvs / colors / indices — the shape renderer.mesh.create takes — and nil under two points, which is no surface.

local geo = Trails.ribbon(path, {
    now = getTime(),
    widthHead = 0.3, widthTail = 0,
    colorHead = { 1, 0.9, 0.4 }, colorTail = { 1, 0.2, 0 },
    alphaHead = 1, alphaTail = 0,
    orientation = "camera",       -- or "fixed", about `up`
    cameraPosition = eye,
})

ribbon is pure — the same points, camera and settings give the same arrays — so a trail's geometry can be checked without a scene.

register / unregister / pathOf track paths by entity id, and stats() reports how many trails are live and how many points they hold between them.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

module Trails Continuous ribbon geometry that follows a moving point. require systems/trails.package/trails method newPath(opts: table?) -> table A fresh path. `lifetime` seconds a point survives, `minDistance` metres before a new one is recorded, `maxPoints` the ring's bound. method push(path: table, x: number, y: number, z: number, now: number) -> boolean Record the head position when it has travelled `minDistance` from the last point. Returns whether a point was recorded. method expire(path: table, now: number) -> number Drop points older than `lifetime`. Returns how many went. method ribbon(path: table, opts: table) -> table? Build the ribbon over a path's points — flat `positions` / `normals` / `uvs` / `colors` / `indices`, the shape `renderer.mesh.create` takes. `nil` under two points, which is no surface. method register(id: string, path: table) method unregister(id: string) method pathOf(id: string) -> table? method stats() -> table about A trail is a strip of quads threaded along the positions something occupied over the last few seconds. Each recorded point contributes two vertices, offset either side of the direction of travel, and consecutive points are joined into a continuous surface — so a spark, a wingtip vapour trail or a sword arc is one mesh rather than a queue of sprites that betrays its spacing when the subject moves fast. Width, colour and opacity run from the head (the newest point) to the tail (the oldest), indexed by each point's age rather than its position in the list, so the fade reads the same whether the subject is crawling or sprinting. `ribbon` is pure: the same points, camera and settings produce the same arrays, so a trail's geometry can be checked without a scene.

normalize(x: number, y: number, z: number) → void

argtypedescription
xnumber
ynumber
znumber

lerp(a: number, b: number, t: number) → number

argtypedescription
anumber
bnumber
tnumber

vec3(t: any, dx: number, dy: number, dz: number) → void

argtypedescription
tany
dxnumber
dynumber
dznumber

newPath(opts: any) → any

A fresh path — the point ring a trail is threaded along.

argtypedescription
optsany`{ lifetime, minDistance, maxPoints }`; each falls back to a default.

examples

local path = Trails.newPath({ lifetime = 1.5, minDistance = 0.05 })

push(path: any, x: number, y: number, z: number, now: number) → boolean

Record the head position, when it has moved far enough to be worth a point.

argtypedescription
pathanyA path from `newPath`.
xnumberWorld x of the head.
ynumberWorld y of the head.
znumberWorld z of the head.
nownumberSeconds, on the same clock `expire` and `ribbon` are given.

examples

if Trails.push(path, p.x, p.y, p.z, getTime()) then rebuild() end

expire(path: any, now: number) → number

Drop points that have outlived `lifetime`.

argtypedescription
pathanyA path from `newPath`.
nownumberSeconds, on the clock the points were pushed with.

examples

Trails.expire(path, getTime())

ribbon(path: any, opts: any) → any

Build the ribbon surface over a path's points. alphaTail, orientation, cameraPosition, up }`. plus `pointCount`; `nil` under two points.

argtypedescription
pathanyA path from `newPath`.
optsany`{ now, widthHead, widthTail, colorHead, colorTail, alphaHead,

examples

local geo = Trails.ribbon(path, { now = getTime(), cameraPosition = eye })

register(id: string, path: any) → void

Track a path under an entity id, so a script can read what is trailing.

argtypedescription
idstringThe entity the trail follows.
pathanyA path from `newPath`.

examples

Trails.register(public.entityId, path)

unregister(id: string) → void

Stop tracking an entity's path.

argtypedescription
idstringThe entity the trail followed.

examples

Trails.unregister(public.entityId)

pathOf(id: string) → any

The path currently tracked for an entity.

argtypedescription
idstringThe entity the trail follows.

examples

local path = Trails.pathOf(id); print(#path.points)

stats( ) → any

How many trails are live and how many points they hold between them.

examples

print(Trails.stats().points)

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported on this asset or on the parts this page shows. Parts it leaves out are not counted here.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.