LittleJS 1.30.0

Render3D

Light3D

Light3D - A light that is an EngineObject3D, so it can move, follow a parent or be destroyed like anything else

  • A point light: it lights what is near it and fades out by its radius, DirectionalLight3D shines from far away
  • A coneAngle makes it a spotlight: it shines along its own forward, turned by rotation3D or by what it is attached to, inside the cone, fading over the part of it coneSoftness says
  • The sun, render3D.sunDirection, casts the shadows; a spotlight can cast them in its place, see render3D.shadowLight; the other lights light and make highlights without one
  • Only the 8 lights nearest the camera are used each frame
  • radius is where the light fades out, and it fades fast, so a small radius wants a higher intensity
  • intensity multiplies the color, above 1 for a light brighter than white
  • radius is a world distance, so scale3D does not change it
  • An alpha, an intensity or a radius of 0 switches it off, and a light that is off takes none of those slots
  • Draws nothing but its glow, when it has one; add a small emissive mesh if the lamp itself should be seen
  • addFlare gives it a lens flare, see LensFlare3D

Extends EngineObject3D

Extended by DirectionalLight3D

Constructor

new Light3D(pos3D, radius, color, intensity)render3dObject.js:1621

Create a point light

pos3D Vector3 optional

Where it is

radius number optional, default 5

Distance where the light fades to nothing

color Color optional

Light color, its alpha fades it

intensity number optional, default 1

Brightness, multiplies the color, above 1 is brighter than white

const torch = new Light3D(vec3(0, 3, 0), 10, hsl(.1, 1, .65));
torch.addFlare();   // light in the lens when the torch is in view

Members

Methods

Inherited from EngineObject3D

Inherited from EngineObject

Members

coneAngle : numberrender3dObject.js:1643

Makes it a spotlight: the angle in radians from its forward out to the edge of its cone, so the beam is twice this across; 0 for a light that shines every way

coneSoftness : numberrender3dObject.js:1646

How much of the cone is its fading edge: 0 a hard edge, .2 by default, the outer fifth, 1 fading all the way from the middle of the beam

directional : booleanrender3dObject.js:1640

Shine from far away, from its position toward the origin, instead of out from its position with a falloff; DirectionalLight3D sets it

The light's lens flare, undefined for none: addFlare makes it, or set a LensFlare3D of your own, and destroying the flare takes it away

  • The flare is the light's: it is attached to the light as its child, so it stays through a scene change when the light does, and is destroyed with the light or when another takes its place
flareObject : LensFlare3D|undefinedrender3dObject.js:1662

A gel: a picture the light shines through, like a stained glass window or the leaves of a tree, cast along its cone in its colors, upright as the light looks out, the whole texture of a TileInfo; only the spotlight that casts the shadows has one, with render3D.shadows on and it as render3D.shadowLight, and only on what takes its shadows: an object with receiveShadow off is lit without the gel; its alpha is not read, see through panes are dark

Size of a soft hazy glow drawn over the light, like a lamp at night, 0 for none; it is added onto what is behind it, and what is in front of the light hides it

glowFalloff : numberrender3dObject.js:1652

How fast the glow fades from its middle: 1 by default, .5 a wide haze, 2 a tight bright core

intensity : numberrender3dObject.js:1637

Brightness, multiplies the color, above 1 is brighter than white

radius : numberrender3dObject.js:1635

Distance where the light fades to nothing

Methods

addFlare(size, count, intensity, saturation, color) → LensFlare3Drender3dObject.js:1672

Give the light a lens flare, made with the arguments of LensFlare3D, in place of the one it had

size number optional

Scales every part of it

count number optional

How many ghosts there are, besides the glow at the light

intensity number optional

How bright it is

saturation number optional

How colorful the ghosts are

color Color optional

Tints the flare, with the light's own color

Returns
  • The flare, to change: light.addFlare().shapes = ['hex']
destroy(immediate)render3dObject.js:1701

Destroy the light, and its flare with it

immediate boolean optional

Draw the glow, a quad facing the camera with a soft round glow on it, pulled toward the camera by half its size so a lamp at the light does not cut into it, but never past the camera