← Previous Section Next Section →

Lights


You want your scenes to appear in a good light right? This tutorial will show you how to set up directional lights, point lights and spot lights.

Directional Light

The simplest light is a directional light, or infinite light. This is where the light rays are, to all intents and purposes, parallel.

		<DirectionalLight id="directional" direction='0 0 1' on ="TRUE" intensity='1.0' shadowIntensity='0.0'> </DirectionalLight> 
		

Point Light

A point light is defined to be a light source which emanates from a single point in space equally in all directions, like for example a light bulb.

		<PointLight id='point' on='TRUE' intensity='0.9000' color='0.0 0.6 0.0' location='0 10 0.5 ' radius='5.0000' >  </PointLight> 
		

Head Light

A head light is a light source which behaves as if it is tied to your view.

		<NavigationInfo id="head" headlight='true' type='"EXAMINE"'>  </NavigationInfo> 
		

Spot Light

A spot light is a light source which has a cone of effect like a flashlight.

		<SpotLight id='spot' on ="TRUE" beamWidth='0.9' color='0 0 1' cutOffAngle='0.78' location='0 0 12' radius='22' >  </SpotLight> 
		

If you want to include lights directly in your x3d file , you need to use "DEF" instead of "id".
A scene with all three light sources could look like the example below. You can see a white directional light, a yellowish point light and a blue spot light.

Lights in X3DOM.

For further informations about the lights, their attributes and implementation details please read the x3d specification.

Back to page top ⤴

Get this X3DOM example:

Read more about the X3DOM nodes used in this tutorial: