Skip to content
Josh Stovall edited this page Dec 21, 2020 · 8 revisions

Light()

Create a light.
See the live demo.

var options = {
   type: "ambient",
   color: 0xFF0000,
   intensity: 1, 
   distance: 100,
   decay: 1
}
var light = new XR.Light(options);

Parameters

Name Type Options Default Description
type string ambient directional hemisphere point rect spot point type of light
angle float 1 Maximum angle of light dispersion from its direction whose upper bound is Math.PI/2 (makes spotlight wider)
color color white light color
decay float 0 to 1 0 The amount the light dims along the distance of the light
distance int > 0 0 Maximum range of the light
helper bool false add a helper
intensity float 0 to 1 1 The light's intensity, or strength
penumbra float 0 to 1 1 makes edges softer
position array xyz coordinates [0,0,0] position of light
width float 1 width (for rect lights)
height float 1 height (for rect lights)

type

Type of light.

  • ambient globally illuminates all objects in the reality equally
  • directional emitted in a specific direction (like the sun)
  • hemisphere positioned directly above the scene, with color fading from the sky color to the ground color
  • point emitted from a single point in all directions (like a lightbulb)
  • rect emits light uniformly across the face a rectangular plane (like a window or ceiling panel light)
  • spot emitted from a single point in one direction (like a flashlight)

color

Color of the light.

intensity

The light's intensity, or strength.

distance

Maximum range of the light. Default is 0 (no limit).

decay

The amount the light dims along the distance of the light

helper

Adds a light helper. Useful for debugging.

Clone this wiki locally