Light — Aspose.3D FOSS for .NET
Namespace: Aspose.ThreeD.Entities
Overview
The Light class represents a light source attached to a scene node. It extends Entity and supports four light types: directional, point, spot, and ambient. A light is placed in the scene by creating a child node and attaching the Light entity to it.
using Aspose.ThreeD;
using Aspose.ThreeD.Entities;
using Aspose.ThreeD.Utilities;
var scene = new Scene();
// Add a point light to the scene
var light = new Light(LightType.POINT, "SunLight");
light.Color = new Vector3(1.0f, 0.95f, 0.8f);
light.Intensity = 2.0f;
light.Range = 10.0f;
scene.RootNode.CreateChildNode("sun", light);Constructors
| Constructor | Description |
|---|---|
Light() | Creates a point light with default name "Light", white color, intensity 1.0, range 1.0 |
Light(LightType type) | Creates a light of the given type with default name "Light" |
Light(LightType type, string name) | Creates a named light of the given type |
Properties
| Name | Type | Access | Description |
|---|---|---|---|
Type | LightType | get | The light type (POINT, SPOT, DIRECTIONAL, or AMBIENT). Set at construction; read-only after. |
Color | Vector3 | get/set | RGB colour of the light. Default: Vector3.One (white) |
Intensity | float | get/set | Brightness multiplier. Default: 1.0 |
Range | float | get/set | Maximum distance of influence for point and spot lights. Default: 1.0 |
Methods
| Method | Return Type | Description |
|---|---|---|
GetBoundingBox() | BoundingBox | Returns an empty bounding box (lights have no geometric extent) |
LightType
LightType is a value-type class with four public static instances:
| Instance | Description |
|---|---|
LightType.POINT | Emits light equally in all directions from a point in space |
LightType.SPOT | Emits a cone of light in the direction the node is facing |
LightType.DIRECTIONAL | Emits parallel light rays as if from an infinitely distant source |
LightType.AMBIENT | Adds uniform ambient illumination; range and direction are not used |
LightType has one property:
| Name | Type | Access | Description |
|---|---|---|---|
Name | string | get | The display name of the light type ("Point", "Spot", "Directional", "Ambient") |
Example
Add a directional and a point light to a scene and save to FBX:
using Aspose.ThreeD;
using Aspose.ThreeD.Entities;
using Aspose.ThreeD.Utilities;
var scene = new Scene();
// Directional light — positioned and oriented via the node Transform
var dirLight = new Light(LightType.DIRECTIONAL, "Sun");
dirLight.Color = new Vector3(1.0f, 1.0f, 0.9f);
dirLight.Intensity = 1.5f;
scene.RootNode.CreateChildNode("dirLight", dirLight);
// Point light with limited range
var pointLight = new Light(LightType.POINT, "Lamp");
pointLight.Color = new Vector3(1.0f, 0.6f, 0.3f);
pointLight.Intensity = 3.0f;
pointLight.Range = 5.0f;
scene.RootNode.CreateChildNode("lamp", pointLight);
scene.Save("lit_scene.fbx");