indiesoftby/defold-hyper-trails/hyper_trails
Easy to use and customizable trail effect.
- GitHub: indiesoftby/defold-hyper-trails — pinned to
1.4.2- Pick a release from indiesoftby/defold-hyper-trails releases and add its Source code (zip) URL (or a packaged
.zipasset, if the library ships one) togame.projectunder[project]dependencies, then Fetch Libraries in the Defold editor. - Run
bunx @defold-typescript/cli resolveto materialize its types. - Import it under a namespace alias of your choice:
import * as hyper_trails from "hyper_trails"
- Pick a release from indiesoftby/defold-hyper-trails releases and add its Source code (zip) URL (or a packaged
Functions
queue_late_update()draw_trail(self: LuaMap<string, unknown> |PlainTable)encode_data_to_buffers(self: LuaMap<string, unknown> |PlainTable)fade_tail(self: LuaMap<string, unknown> |PlainTable, dt: number, data_arr: LuaTable, data_from: number)follow_position(self: LuaMap<string, unknown> |PlainTable, dt: number)get_head_data_points(self: LuaMap<string, unknown> |PlainTable): LuaMultiReturn<[LuaTable, LuaTable]>get_position(self: LuaMap<string, unknown> |PlainTable):Vector3init_data_points(self: LuaMap<string, unknown> |PlainTable)init_buffers(self: LuaMap<string, unknown> |PlainTable)final(self: LuaMap<string, unknown> |PlainTable)init_props(self: LuaMap<string, unknown> |PlainTable)init_vars(self: LuaMap<string, unknown> |PlainTable)make_angle(diff_pos:Vector3): numbermake_vectors_from_angle(self: LuaMap<string, unknown> |PlainTable, row: LuaTable)pull_not_used_points(self: LuaMap<string, unknown> |PlainTable, data_arr: LuaTable, data_from: number)shrink_length(self: LuaMap<string, unknown> |PlainTable, dt: number, data_arr: LuaTable, data_from: number)shrink_width(self: LuaMap<string, unknown> |PlainTable, dt: number, data_from: number, data_arr: LuaTable, data_limit: number)split_segments_by_length(self: LuaMap<string, unknown> |PlainTable)update_uv_opts(self: LuaMap<string, unknown> |PlainTable)
queue_late_update()
Queue late update for trail rendering Based on https://forum.defold.com/t/delay-when-using-draw-line-in-update/68695/2
draw_trail(self: LuaMap<string, unknown> | PlainTable)
Draw the trail by encoding data to buffers and updating UV options
Parameters
self:LuaMap<string, unknown> | PlainTable— Script instance
encode_data_to_buffers(self: LuaMap<string, unknown> | PlainTable)
Encode trail data into mesh buffers
Parameters
self:LuaMap<string, unknown> | PlainTable— Script instance
fade_tail(self: LuaMap<string, unknown> | PlainTable, dt: number, data_arr: LuaTable, data_from: number)
Fade the tail of the trail by decreasing the alpha value of the tail points
Parameters
self:LuaMap<string, unknown> | PlainTable— Script instancedt:number— Delta timedata_arr:LuaTable— Array of trail point datadata_from:number— Starting index for fading. ⚠️ 1-based; passed tohyper_trailsunchanged.
follow_position(self: LuaMap<string, unknown> | PlainTable, dt: number)
Update trail position and properties based on object movement
Parameters
self:LuaMap<string, unknown> | PlainTable— Script instancedt:number— Delta time
get_head_data_points(self: LuaMap<string, unknown> | PlainTable): LuaMultiReturn<[LuaTable, LuaTable]>
Get the two points at the head of the trail
Parameters
self:LuaMap<string, unknown> | PlainTable— Script instance
Returns
LuaTable— Previous head pointLuaTable— Current head point
get_position(self: LuaMap<string, unknown> | PlainTable): Vector3
Get current position of the trail object
Parameters
self:LuaMap<string, unknown> | PlainTable— Script instance
Returns
Vector3— Current position
init_data_points(self: LuaMap<string, unknown> | PlainTable)
Initialize trail data points
Parameters
self:LuaMap<string, unknown> | PlainTable— Script instance
init_buffers(self: LuaMap<string, unknown> | PlainTable)
Initialize mesh buffers for trail rendering
Parameters
self:LuaMap<string, unknown> | PlainTable— Script instance
final(self: LuaMap<string, unknown> | PlainTable)
Clean up resources on script destruction
Parameters
self:LuaMap<string, unknown> | PlainTable— Script instance
init_props(self: LuaMap<string, unknown> | PlainTable)
Initialize trail properties
Parameters
self:LuaMap<string, unknown> | PlainTable— Script instance
init_vars(self: LuaMap<string, unknown> | PlainTable)
Initialize internal variables
Parameters
self:LuaMap<string, unknown> | PlainTable— Script instance
make_angle(diff_pos: Vector3): number
Calculate angle from position difference
Parameters
diff_pos:Vector3— Position difference vector
Returns
number— Angle in radians
make_vectors_from_angle(self: LuaMap<string, unknown> | PlainTable, row: LuaTable)
Generate perpendicular vectors for trail width based on angle
Parameters
self:LuaMap<string, unknown> | PlainTable— Script instancerow:LuaTable— Trail point data row
pull_not_used_points(self: LuaMap<string, unknown> | PlainTable, data_arr: LuaTable, data_from: number)
Fill with zeros unused trail points
Parameters
self:LuaMap<string, unknown> | PlainTable— Script instancedata_arr:LuaTable— Array of trail point datadata_from:number— Starting index for unused points. ⚠️ 1-based; passed tohyper_trailsunchanged.
shrink_length(self: LuaMap<string, unknown> | PlainTable, dt: number, data_arr: LuaTable, data_from: number)
Shrink trail length over time
Parameters
self:LuaMap<string, unknown> | PlainTable— Script instancedt:number— Delta timedata_arr:LuaTable— Array of trail point datadata_from:number— Starting index for shrinking. ⚠️ 1-based; passed tohyper_trailsunchanged.
shrink_width(self: LuaMap<string, unknown> | PlainTable, dt: number, data_from: number, data_arr: LuaTable, data_limit: number)
Shrink trail width from head to tail
Parameters
self:LuaMap<string, unknown> | PlainTable— Script instancedt:number— Delta timedata_from:number— Starting index. ⚠️ 1-based; passed tohyper_trailsunchanged.data_arr:LuaTable— Array of trail point datadata_limit:number— Maximum points to process
split_segments_by_length(self: LuaMap<string, unknown> | PlainTable)
Split trail segments that exceed maximum length
Parameters
self:LuaMap<string, unknown> | PlainTable— Script instance
update_uv_opts(self: LuaMap<string, unknown> | PlainTable)
Update UV options for trail texture
Parameters
self:LuaMap<string, unknown> | PlainTable— Script instance