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 by default: it lights what is near it and fades out by its radius
  • Set directional to shine from far away along the light's forward axis instead, aim it with lookAt or rotation3D
  • A directional light shines from no particular place, so only its facing counts and moving it does nothing
  • Only render3D.lightDirection casts shadows, these light without shadowing
  • 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 bright color
  • radius is a world distance, so scale3D does not change it
  • An alpha 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)

Create a point light, set directional to make it shine from far away instead

Parameters:
NameTypeAttributesDefaultDescription
pos3DVector3<optional>
radiusnumber<optional>
5

Distance where the light fades to nothing, ignored when directional

colorColor<optional>

Light color, alpha scales the brightness

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

Extends

  • EngineObject3D

Members

directional

Properties
TypeDescription
boolean

Shine along the light's forward axis from far away instead of out from its position, with no falloff

radius

Properties
TypeDescription
number

Distance where the light fades to nothing

Methods

render3D()

Lights draw nothing