Light

Package: aspose.threed.entities (aspose-3d-foss)

Light is an Entity that adds a light source to a 3D scene. Like Camera, it is attached to a Node to control its position and direction.

class Light(Camera):

Inheritance

A3DObjectSceneObjectEntityCameraLight

Light inherits from Camera. In the current release, the Light class itself does not expose additional properties beyond those inherited from Camera and Entity. The LightType enum exists for categorizing lights but there is no light_type property on the Light class.


Constructor

Light(name: str = None)
ParameterTypeDefaultDescription
namestr | NoneNoneOptional name for the light object.

Properties

PropertyTypeDescription
namestrName of the light object (inherited from A3DObject).

Light also inherits all Camera properties (near_plane, far_plane, etc.), though these are not meaningful for light objects. Note: the Light class does not expose a light_type property in the current API surface.


LightType Values

from aspose.threed.entities import LightType
ConstantValueDescription
LightType.POINT"POINT"Emits light equally in all directions from a single point.
LightType.DIRECTIONAL"DIRECTIONAL"Parallel rays from an infinitely distant source (like sunlight).
LightType.SPOT"SPOT"Cone-shaped beam; position and direction matter.
LightType.AREA"AREA"Light emitted from a rectangular area.
LightType.VOLUME"VOLUME"Volumetric/global illumination light.

Usage Examples

Point Light

from aspose.threed import Scene, FileFormat
from aspose.threed.entities import Light, LightType

scene = Scene()

light = Light("PointLight")
node = scene.root_node.create_child_node("light", light)
node.transform.set_translation(0.0, 10.0, 0.0)

scene.save("lit-scene.glb", FileFormat.GLTF)

Directional Light

from aspose.threed import Scene
from aspose.threed.entities import Light, LightType

scene = Scene()

sun = Light("Sun")
node = scene.root_node.create_child_node("sun", sun)
# Direction is controlled by the node's rotation
node.transform.set_euler_angles(-45.0, 30.0, 0.0)  # degrees

scene.save("directional-light.glb")

Add Both a Camera and a Light

from aspose.threed import Scene, FileFormat
from aspose.threed.entities import Camera, Light, LightType, ProjectionType

scene = Scene()

# Camera
cam = Camera("Cam", ProjectionType.PERSPECTIVE)
cam.field_of_view = 60.0
cam_node = scene.root_node.create_child_node("camera", cam)
cam_node.transform.set_translation(0.0, 5.0, 15.0)

# Directional light
light = Light("DirLight")
light_node = scene.root_node.create_child_node("light", light)
light_node.transform.set_euler_angles(-30.0, 45.0, 0.0)

scene.save("camera-and-light.glb", FileFormat.GLTF)

Enumerate Lights in an Imported Scene

from aspose.threed import Scene
from aspose.threed.entities import Light

scene = Scene()
scene.open("model.glb")

def find_lights(node, depth=0):
    if isinstance(node.entity, Light):
        print(f"{'  ' * depth}Light: {node.name}")
    for child in node.child_nodes:
        find_lights(child, depth + 1)

find_lights(scene.root_node)

See Also