Render3D. Trail3D

Trail3D - A ribbon through where the object has been, thinning and fading with age

  • Records its world position each frame it moves, so parent it to something that moves or set pos3D yourself
  • The samples are world space, so width is a world width and scale3D does nothing to the ribbon
  • Drawn unlit in the transparent stage, dies down on its own once the object stops

Constructor

new Trail3D(pos3Dopt, lifeTimeopt, widthopt, tileInfoopt, coloropt, colorEndopt, additiveopt)

Create a trail

Parameters:
NameTypeAttributesDefaultDescription
pos3DVector3<optional>
lifeTimenumber<optional>
1

Seconds the ribbon takes to thin and fade from head to tail, Infinity keeps every sample at full width and never drops one, so it grows as long as the object moves

widthnumber<optional>
0.2

Width at the head, it thins to nothing at the tail

tileInfoTileInfo | TextureInfo<optional>

Tile or whole texture stretched along the trail, undefined is untextured

colorColor<optional>

Color at the head

colorEndColor<optional>

Color at the tail

additiveboolean<optional>
false

Additive blending

Example
const trail = new Trail3D(vec3(), 1, .3, undefined, hsl(.08, 1, .5), hsl(0, 1, .5, 0), true);
ball.addChild(trail); // follows the ball

Extends

  • EngineObject3D

Members

colorEnd

Properties
TypeDescription
Color

Color at the tail

lifeTime

Properties
TypeDescription
number

Seconds the ribbon takes to thin and fade from head to tail, Infinity never drops a sample

samples :Array.<Object>

Type:
  • Array.<Object>
Properties
TypeDescription
Array.<Object>

Recorded samples, oldest first

side :Vector3|undefined

Type:
  • Vector3 | undefined
Properties
TypeDescription
Vector3 | undefined

Direction across the ribbon, recorded with each sample, undefined faces the camera

width

Properties
TypeDescription
number

Width at the head

Methods

clear()

Forget the trail so far, for when the object teleports

destroy(immediateopt)

Stop recording, and go away once the ribbon has faded

Parameters:
NameTypeAttributesDescription
immediateboolean<optional>

render3D()

Draw the ribbon

update()

Record the position when it moved and drop old samples, called automatically each frame