Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
Trail3D
Inherits: Line3D < GeometryInstance3D < VisualInstance3D < Node3D < Node < Object
A node to draw lines behind moving objects.
Description
The Trail3D node draws a flat line in space, with an optional billboard mode.
Note: This node is designed for visual effects. For solid lines, pipes, and tubes, use a CSGPolygon3D node in CSGPolygon3D.MODE_PATH mode.
Properties
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
Methods
void |
clear() |
get_current_length() const |
Enumerations
enum LimitMode: 🔗
LimitMode LIMIT_MODE_LIFETIME = 0
Limit the trail length in time.
LimitMode LIMIT_MODE_MAX_LENGTH = 1
Limit the trail length in size.
LimitMode LIMIT_MODE_MAX = 2
Represents the size of the LimitMode enum.
Property Descriptions
Color color = Color(1, 1, 1, 1) 🔗
The color of the trail.
Note: Colors with values above 1.0 (overbright) are not supported.
Note: To have a visible effect on a BaseMaterial3D, BaseMaterial3D.vertex_color_use_as_albedo must be true. For a ShaderMaterial, ALBEDO *= COLOR.rgb; must be inserted in the shader's fragment() function. Otherwise, color will have no visible effect.
The color gradient over the trail length.
Note: Colors with values above 1.0 (overbright) are not supported.
Note: To have a visible effect on a BaseMaterial3D, BaseMaterial3D.vertex_color_use_as_albedo must be true. For a ShaderMaterial, ALBEDO *= COLOR.rgb; must be inserted in the shader's fragment() function. Otherwise, color will have no visible effect.
If true, the trail will generate new points from its head.
Note: Only one active trail is supported. Setting this property to true will cause the existing trail mesh to be cleared.
The lifetime of the trail when limit_mode is LIMIT_MODE_LIFETIME.
Whether to limit the trail by lifetime or length.
ShaderMaterial material 🔗
void set_material(value: ShaderMaterial)
ShaderMaterial get_material()
The material to assign to the trail mesh when material_mode is Line3D.MATERIAL_MODE_CUSTOM.
Tip: To preserve billboarding, use the following shader as a base:
shader_type spatial;
render_mode blend_mix, depth_draw_never, unshaded, skip_vertex_transform, cull_disabled;
void vertex() {
// Billboarding code for trails
// CUSTOM0 contains the tangent of the trail and the width.
if (dot(CUSTOM0.xyz, CUSTOM0.xyz) > 0.0) {
vec3 p = (inverse(MODELVIEW_MATRIX) * vec4(0.0, 0.0, 0.0, 1.0)).xyz;
p = VERTEX - p;
vec3 t = CUSTOM0.xyz;
vec3 binormal = normalize(cross(p, t));
vec3 normal = normalize(cross(t, binormal));
vec3 tangent = normalize(cross(binormal, normal));
VERTEX += CUSTOM0.w * binormal;
NORMAL = normal;
TANGENT = tangent;
BINORMAL = binormal;
}
}
void fragment() {
ALBEDO = COLOR.rgb;
ALPHA = COLOR.a;
}
MaterialMode material_mode = 0 🔗
void set_material_mode(value: MaterialMode)
MaterialMode get_material_mode()
The material mode for the trail.
The maximum length of the trail when limit_mode is LIMIT_MODE_MAX_LENGTH.
MeshAlignment mesh_alignment = 1 🔗
void set_mesh_alignment(value: MeshAlignment)
MeshAlignment get_mesh_alignment()
Alignment of the trail. Possible options are Line3D.MESH_ALIGNMENT_LOCAL for a 3D line, and Line3D.MESH_ALIGNMENT_BILLBOARD for a billboarded line.
float min_section_length = 0.2 🔗
Minimum required distance before adding a new section.
If true, pins the UVs to their positions in space.
TilingMode tiling_mode = 1 🔗
void set_tiling_mode(value: TilingMode)
TilingMode get_tiling_mode()
How to tile the UVs across the length of the trail.
float tiling_multiplier = 1.0 🔗
UV multiplier across the length of the trail.
Width of the trail.
Width across the length of the trail.
Method Descriptions
void clear() 🔗
Clears the trail.
float get_current_length() const 🔗
Returns the current length of the trail.