TrailComponent class Particles

An engine component that trails a camera-facing ribbon behind its owning node as the node moves, for missiles, sword slashes, tracers, and debris.

Each frame the component records the node's world position: a new trail point is anchored whenever the node has moved minVertexDistance from the last anchor, the newest point continuously follows the node so the head never lags, and points older than lifetime expire. The recorded path is rendered as a strip that always faces the camera, with width shaped by widthOverTrail and tinted by colorOverTrail from head (0) to tail (1).

Points are recorded in world space, so the ribbon hangs in the world where the node has been rather than dragging along rigidly with it. The strip is an ordinary triangle mesh (the trail gradient rides the vertex colors and its texture coordinates run head to tail along u), so it pairs with any standard material; the default is a translucent UnlitMaterial weighted fully to the vertex color, drawn without culling. A custom Material must also disable culling, since a camera-facing strip's winding flips wherever the path doubles back on itself.

Inheritance

Constructors

TrailComponent({double width = 0.25, double lifetime = 0.6, double minVertexDistance = 0.05, int maxPoints = 48, ParticleCurve? widthOverTrail, ColorGradient? colorOverTrail, Material? material})
Creates a trail. maxPoints bounds the recorded path (oldest points expire first); material defaults to a translucent unlit material driven by the trail's vertex colors.
factory

Properties

colorOverTrail ColorGradient?
Color over the trail, head (0) to tail (1). Defaults to white fading out toward the tail.
getter/setter pair
emitting bool
Whether new points are recorded. While false the existing ribbon ages out naturally.
getter/setter pair
enabled bool
Whether this component's update hook runs each frame.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
isAttached bool
Whether this component is currently attached to a node.
no setterinherited
isLoaded bool
Whether onLoad has completed.
no setterinherited
isMounted bool
Whether the owning node is part of a live scene graph.
no setterinherited
lifetime double
Seconds a recorded point lives before the tail consumes it.
getter/setter pair
mesh Mesh
The mesh this component draws.
getter/setter pairinherited
minVertexDistance double
World distance the node must move before a new point is anchored.
getter/setter pair
node Node
The node this component is attached to.
no setterinherited
renderItems List<RenderItem>
The render items registered for this component's mesh primitives, empty while not mounted. Exposed so a subclass (the LOD component) can tag the items it just registered.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
width double
The ribbon's width in world units at curve value 1.
getter/setter pair
widthOverTrail ParticleCurve?
Width multiplier over the trail, head (0) to tail (1). Defaults to a taper from full width at the head to zero at the tail.
getter/setter pair

Methods

clear() → void
Forgets the recorded path (the ribbon disappears immediately).
cloneFor(Node cloneOwner) Component?
Returns a copy of this component for cloneOwner, the Node.clone counterpart of the owning node, or null to not carry the component to clones (the default).
inherited
fixedUpdate(double fixedDt) → void
Called once per fixed physics step while the component is mounted, enabled, and loaded. fixedDt is the fixed timestep of the surrounding PhysicsWorld, not the frame interval.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onAttach() → void
Called when this component is added to a node.
inherited
onDetach() → void
Called when this component is removed from a node.
inherited
onLoad() Future<void>
Optional asynchronous setup, such as loading an asset.
inherited
onMount() → void
Called when the owning node enters a live scene graph.
inherited
onRenderItemsRegistered() → void
Called after this component registers its render items, on mount and on every re-registration (mesh assignment, refreshMaterials).
inherited
onUnmount() → void
Called when the owning node leaves a live scene graph.
inherited
toString() String
A string representation of this object.
inherited
update(double deltaSeconds) → void
Called once per frame while the component is mounted, enabled, and loaded. deltaSeconds is the elapsed time since the previous tick.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited