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
  • Only the sun, render3D.sunDirection, casts shadows; these 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 itself, add a glow with drawSoftDisc or a small emissive mesh if it should be seen

Constructor

new Light3D(pos3Dopt, radiusopt, coloropt, intensityopt)

Create a point light

Parameters:
NameTypeAttributesDefaultDescription
pos3DVector3<optional>

Where it is

radiusnumber<optional>
5

Distance where the light fades to nothing

colorColor<optional>

Light color, its alpha fades it

intensitynumber<optional>
1

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

Example
const torch = new Light3D(vec3(0, 3, 0), 10, hsl(.1, 1, .65));

Extends

  • EngineObject3D

Members

directional

Properties
TypeDescription
boolean

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

glow

Properties
TypeDescription
number

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

Properties
TypeDescription
number

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

intensity

Properties
TypeDescription
number

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

radius

Properties
TypeDescription
number

Distance where the light fades to nothing

Methods

render3D()

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