-
Notifications
You must be signed in to change notification settings - Fork 1
DirectionalLight Class
SoJS coder edited this page Dec 12, 2023
·
3 revisions
The directional light class allows you to create directional lights (lights that face a certain direction in space)
Limited functionality (rotations do not work well)
-
position
(Array): Vector representing the lights position in 2d space (x,y) -
angle
(Number): the angle that the light is facing (in radians) -
spread
(Number): The angle that the light spreads at (in radians) -
diffuse
(Number): How far the light diffuses -
strength
(Number): The strength of the light -
color
(Array): [r,b,b] 0-255
Works in the same way as the light
class.
Inherits all methods from parent class light
(pin, brighten, dim, move)
Additional methods:
Points the light to an object
-
object
(GameObject): The game object to point the light to -
canvas
(HTMLCanvasElement): The canvas that the light is rendered on
myDirectionalLight.pointTo(polygon);
Pins the angle to an object
-
object
(GameObject): The game object to point the light to
myDirectionalLight.pinAngleTo(polygon);