-
Notifications
You must be signed in to change notification settings - Fork 1
Light Class
SoJS coder edited this page Dec 11, 2023
·
4 revisions
The Light class represents a light source within a 2D scene. It allows for the manipulation of the light's position, brightness, color, and interaction with other objects. This documentation outlines the properties and methods of the Light class. For a directional light, use the DirectionalLight class.
-
position
(Array, required): An array representing the initial position of the light source. -
diffuse
(Number, required): How much the light is diffused across a scene. -
strength
(Number, optional): The strength of the light source. Default is 0.8. -
color
(Array, optional): An array representing the RGB color of the light. Default is [255, 255, 255].
const lightPosition = [100, 100];
const diffuse = 0.5;
const lightStrength = 0.8;
const lightColor = [255, 255, 255];
const myLight = new Light(lightPosition, diffuse, lightStrength, lightColor);
To add the light to the scene, use scene.addLight(myLight)
. (Ensure that scene.lighting
is set to true)
-
point
(Array): An array representing the current position of the light source. -
diffuse
(Boolean): How the light diffuses across a scene. -
strength
(Number): The strength of the light source. -
color
(Array): An array representing the RGB color of the light. -
pinnedTo
(Object): The object to which the light source is pinned, if any