LittleJS 1.28.0

Render3D

LensFlare3D

LensFlare3D - The sun's lens flare, the old kind: a glow at the sun and a row of discs and rings of different sizes along the line from the sun through the middle of the screen

  • Make one and it shows, over the 3D scene and under what the game draws after, a HUD; destroy it to take it away
  • It follows render3D.sunDirection, and fades out as the sun leaves the screen or goes behind something
  • A Light3D gets one of its own with light.addFlare()
  • flareSize, count, intensity and saturation set its look, seed picks another arrangement, and its color tints it, with the sun's own color; shapes says what its ghosts are, glowSize and ghostSize how big its parts are; or give it elements of your own, which may be tiles of the game's
  • visible is how much of the sun shows, 0 to 1, eased over fadeTime, there for a game to read; it is 0 while the sun is too far off the screen for the flare to show, about a seventh of the screen past its edge, where nothing is tested
  • What hides the sun is found with a ray from the camera, against the level and every object that is not see through, each on the triangles of its mesh, see render3D.pick; turn it off with occlusion
  • It needs WebGL, and it draws nothing in the shadow of renderAfter2D

Extends EngineObject3D

Constructor

new LensFlare3D(size, count, intensity, saturation, color)render3dExtras.js:1895

Create the sun's lens flare

size number optional, default 1

Scales every part of it, 1 by default

count number optional, default 7

How many ghosts there are along the line, besides the glow at the sun

intensity number optional, default 1

How bright it is

saturation number optional, default 1

How colorful the ghosts are, 0 for all the flare's own color, 1 a rainbow

color Color optional

Tints the whole flare, with the sun's color

new LensFlare3D;                // the sun flares
new LensFlare3D(1.5, 10, .7, 0); // bigger, 10 ghosts, dimmer, all one color

Members

Methods

Inherited from EngineObject3D

Inherited from EngineObject

Members

How many ghosts there are along the line, besides the glow at the sun

elements : Array<LensFlareElement>|undefinedrender3dExtras.js:1929

The parts of the flare, to set your own in place of the ones made from count, seed, saturation, shapes, glowSize and ghostSize

fadeTime : numberrender3dExtras.js:1941

Seconds the flare takes to fade out or in when the sun is hidden or shows again

flareSize : numberrender3dExtras.js:1908

Scales every part of the flare

ghostSize : numberrender3dExtras.js:1925

Scales the ghosts

glowSize : numberrender3dExtras.js:1923

Scales the glow at the sun, 0 for none

intensity : numberrender3dExtras.js:1912

How bright it is

A light the flare is of in place of the sun, a lamp or a spotlight: the flare is at the light and in its color, smaller from farther than the light reaches, hidden by what is in front of the light but its lamp, a mesh around it whose surface is near it, and a spotlight's shows from inside its beam only; a DirectionalLight3D's is far away where it shines from, like the sun's; the flare is destroyed when its light is; light.addFlare sets this

occlusion : booleanrender3dExtras.js:1939

Fade out when something is between the camera and the sun

saturation : numberrender3dExtras.js:1914

How colorful the ghosts are, 0 for all the flare's own color, 1 a rainbow

Picks the arrangement of the ghosts, another seed is another flare

shapes : Array<string>|undefinedrender3dExtras.js:1921

The shapes the ghosts are picked from, glow, disc, ring, hex, streak or star: ['hex'] makes every ghost a hexagon, and a shape listed twice is picked twice as often; discs, rings and glows when not set

visible : numberrender3dExtras.js:1944

How much of the sun shows, 0 hidden, off the screen or behind the camera to 1 in plain view, eased; the first update sets it at once, so a sun hidden from the start never shows

Methods

The parts of the flare: the elements set by hand, or the ones made from count, seed, saturation, shapes, glowSize and ghostSize, a glow and a core at the sun and the ghosts, made again when one of those changes

getScreenElements() → Array<{pos: Vector2, size: (number|Vector2), color: Color, shape: (string|undefined), tileInfo: (TileInfo|undefined), angle: number}>render3dExtras.js:2044

The parts of the flare as they are drawn now: each one's place on the screen, its size in pixels, a vector when the element's is, and its color, dimmed by how much of the sun shows; empty when there is nothing to draw

getScreenPos() → Vector2|undefinedrender3dExtras.js:2034

Where the sun, or the flare's light, is on the screen, in pixels like mousePosScreen, undefined when it is behind the camera

isHidden() → booleanrender3dExtras.js:2070

Is something between the camera and the sun, or the flare's light: the level, or an object that is not see through, hit on its triangles as render3D.pick hits it, so a mesh the camera is inside hides nothing unless it is doubleSided

Draw the flare over the 3D scene, added onto it, called automatically in the 2D pass

A flare has nothing to draw in the 3D pass

Ease visible toward whether the sun shows, called automatically each frame; a flare that would not show wherever the sun is, off the screen or its light off, looks for nothing in the way