Configuring a Light Source for a 3D Scene
- Updated2025-03-11
- 2 minute(s) read
Configuring a Light Source for a 3D Scene
You can configure a light source to achieve visual effects such as sunlight or spotlights in a visible 3D scene. You can create three types of lights in a 3D scene: directional lights, positional lights, and spotlights. While the following procedure explains how to configure a directional light for a 3D scene, you can use similar steps to configure positional lights and spotlights.
Complete the following steps to configure a directional light for a 3D scene.
- Create a 3D scene, or open a VI that contains a 3D scene.
- Remove the wire that connects the 3D object to the 3D picture control terminal.
- Right-click the reference output of the Set Drawable method and select Create»Method for SceneObject Class»Light»Add Light from the shortcut menu to create the Light:Add Light method.
- Add the Light:Add Light method to the right of the Set Drawable method, and wire the reference output of the Set Drawable method to the reference input of the Light:Add Light method.
- Add the New Light VI to the block diagram.
- Right-click the Light Number input of the New Light VI, select Create»Constant from the shortcut menu, and enter a number between 0 and 7, inclusive. This indexes, or sets the integer that identifies, the light. You cannot index more than 8 lights.
- Right-click the New Light Refnum output of the New Light VI and select Create»Property for SceneLight Class»Direction from the shortcut menu to create the Direction property.
- Add the Direction property to the right of the New Light VI, right-click the property, and select Change to Write from the shortcut menu.
- Wire the New Light Refnum output of the New Light VI to the reference input of the Direction property.
- Right-click the Direction input of the Direction property, select Create»Constant from the shortcut menu, and change the values of the constant to the x, y, and z coordinates that you want to use to define a direction for the light.
- Wire the reference output of the Direction property to the Light input of the Light:Add Light method.
- Wire the reference output of the Light:Add Light method to the 3D picture control terminal.
The following block diagram shows a 3D scene with a configured directional light. The direction coordinates in this 3D scene add the light source beneath the 3D object.

- Wire error in and error out terminals on the block diagram.
- Run the VI to generate the 3D scene.
Refer to the Using Meshes VI in the labview\examples\Graphics and Sound\3D Picture Control directory for an example of configuring a light source for a 3D scene.