Table of Contents
Point Light
The syntax for point light:
var light0 = new BABYLON.PointLight("Omni0", new BABYLON.Vector3(1, 10, 1), scene);
Three params for Point Light:
- The 1st param is the name of the light.
- The 2nd param is the position where the point light is placed.
- The 3rd param is the scene to which the light needs to be attached.
Add color on the object created above:
light0.diffuse = new BABYLON.Color3(1, 0, 0); light0.specular = new BABYLON.Color3(1, 1, 1);
Directional Light
The syntax for Directional Light:
var light0 = new BABYLON.DirectionalLight("Dir0", new BABYLON.Vector3(0, -1, 0), scene);
Three params for Directional Light:
- The 1st param is the name of the light.
- The 2nd param is the position. Right now, it isplaced with negative -1 in the Y axis.
- The 3rd param is the scene to be attached.
Add color with the specular and diffuse property:
light0.diffuse = new BABYLON.Color3(0, 1, 0); light0.specular = new BABYLON.Color3(1,0, 0);
Spot Light
The syntax for the Spot Light:
var light0 = new BABYLON.SpotLight("Spot0", new BABYLON.Vector3(0, 30, -10), new BABYLON.Vector3(0, -1, 0), 0.8, 2, scene);
Five params for Spot Light:
- 1st Param is the name of the light.
- 2nd param is the position.
- 3rd param is the direction.
- 4th param is the angle.
- 5th param is the exponent.
Control the color of the light:
light0.diffuse = new BABYLON.Color3(1, 0, 0); light0.specular = new BABYLON.Color3(1, 1, 1);
Hemispheric Light
The syntax for the Hemispheric Light:
var light0 = new BABYLON.HemisphericLight("Hemi0", new BABYLON.Vector3(0, 1, 0), scene);
For colors:
light0.diffuse = new BABYLON.Color3(1, 0, 0); light0.specular = new BABYLON.Color3(0, 1, 0); light0.groundColor = new BABYLON.Color3(0, 0, 0);