BabylonJS lights
BabylonJS is an open-source, robust JavaScript framework for creating and rendering 3D graphics and immersive experiences directly in web browsers.
Note: Learn more about BabylonJS.
Lights
The BabylonJS lights determine how objects in the scene are illuminated and their interactions with light sources. BabylonJS offers the following types of lights:
Hemispheric light
Directional light
Point light
Spot light
The HemisphericLight syntax
This light simulates ambient light by illuminating objects from all directions. They are commonly used to create a soft, even lighting effect.
Syntax
var light = new BABYLON.HemisphericLight(label, vector, scene);
labelis the name of the light. It is a string.vectoris aBABYLON.Vector3that defines the light's direction.sceneis the BabylonJS scene where the light will be added.
Example code
The DirectionalLight syntax
This light simulates sunlight or a strong light source coming from a specific direction. They create parallel light rays that illuminate the scene uniformly.
Syntax
It has a similar syntax to DirectionalLight:
var light = new BABYLON.DirectionalLight(label, vector, scene);
labelis the name of the light. It is a string.vectoris aBABYLON.Vector3that defines the light's direction.sceneis the BabylonJS scene where the light will be added.
Example code
The PointLight syntax
This light simulates a light source radiating light in all directions from a single point in space. They are used to model light bulbs or other light sources that are emit light in all directions.
Syntax
var light = new BABYLON.DirectionalLight(label, vector, scene);
labelis the name of the light. It is a string.vectoris aBABYLON.Vector3that defines the light's direction.sceneis the BabylonJS scene where the light will be added.
Example code
The SpotLight syntax
This light simulates a focused beam of light that illuminates a cone-shaped area. They are often used for flashlights or spotlights.
Syntax
var light = new BABYLON.SpotLight(label, vector1, vector2, H, J, scene);
labelis the name of the light. It is a string.vector1specifies the position of the light source.vector2defines the direction of the light's axis.His the angle of the spotlight's cone (in radians).Jis the exponent controlling the spotlight's intensity distribution.sceneis the scene where the light will be added.
Example code
Continue reading
Free Resources