LittleJS 1.30.0

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

Extends EngineObject3D

Constructor

new Trail3D(pos3D, lifeTime, width, tileInfo, color, colorEnd, additive)render3dExtras.js:2191

Create a trail

pos3D Vector3 optional
lifeTime number optional, default 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

width number optional, default 0.2

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

tileInfo TileInfo|TextureInfo optional

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

color Color optional

Color at the head

colorEnd Color optional

Color at the tail

additive boolean optional, default false

Additive blending

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

Members

Methods

Inherited from EngineObject3D

Inherited from EngineObject

Members

Color at the tail

lifeTime : numberrender3dExtras.js:2212

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

samples : Array<{pos: Vector3, side: (Vector3|undefined), time: number}>render3dExtras.js:2222

Recorded samples, oldest first

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

Width at the head

Methods

Forget the trail so far, for when the object teleports

destroy(immediate)render3dExtras.js:2230

Stop recording, and go away once the ribbon has faded

immediate boolean optional
render3D() → voidrender3dExtras.js:2255

Draw the ribbon

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