trimesh.scene.lighting module

lighting.py

Hold basic information about lights.

Forked from the light model in pyrender: https://github.com/mmatl/pyrender

class trimesh.scene.lighting.DirectionalLight(name=None, color=None, intensity=None, radius=None)

Bases: Light

Directional lights are light sources that act as though they are infinitely far away and emit light in the direction of the local -z axis. This light type inherits the orientation of the node that it belongs to; position and scale are ignored except for their effect on the inherited node orientation. Because it is at an infinite distance, the light is not attenuated. Its intensity is defined in lumens per metre squared, or lux (lm/m2).

name

Name of the light.

Type:

str, optional

color

RGBA value for the light’s color in linear space.

Type:

(4,) unit8

intensity

Brightness of light. The units that this is defined in depend on the type of light. point and spot lights use luminous intensity in candela (lm/sr), while directional lights use illuminance in lux (lm/m2).

Type:

float

radius

Cutoff distance at which light’s intensity may be considered to have reached zero. Supported only for point and spot lights, must be > 0. If None, the radius is assumed to be infinite.

Type:

float

__init__(name=None, color=None, intensity=None, radius=None)
class trimesh.scene.lighting.Light(name=None, color=None, intensity=None, radius=None)

Bases: ABC

Base class for all light objects.

name

Name of the light.

Type:

str, optional

color

RGBA value for the light’s color in linear space.

Type:

(4,) uint8

intensity

Brightness of light. The units that this is defined in depend on the type of light: point and spot lights use luminous intensity in candela (lm/sr) while directional lights use illuminance in lux (lm/m2).

Type:

float

radius

Cutoff distance at which light’s intensity may be considered to have reached zero. Supported only for point and spot lights Must be > 0.0 If None, the radius is assumed to be infinite.

Type:

float

__init__(name=None, color=None, intensity=None, radius=None)
property color
property intensity
property radius
class trimesh.scene.lighting.PointLight(name=None, color=None, intensity=None, radius=None)

Bases: Light

Point lights emit light in all directions from their position in space; rotation and scale are ignored except for their effect on the inherited node position. The brightness of the light attenuates in a physically correct manner as distance increases from the light’s position (i.e. brightness goes like the inverse square of the distance). Point light intensity is defined in candela, which is lumens per square radian (lm/sr).

name

Name of the light.

Type:

str, optional

color

RGBA value for the light’s color in linear space.

Type:

(4,) uint8

intensity

Brightness of light. The units that this is defined in depend on the type of light. point and spot lights use luminous intensity in candela (lm/sr), while directional lights use illuminance in lux (lm/m2).

Type:

float

radius

Cutoff distance at which light’s intensity may be considered to have reached zero. Supported only for point and spot lights, must be > 0. If None, the radius is assumed to be infinite.

Type:

float

__init__(name=None, color=None, intensity=None, radius=None)
class trimesh.scene.lighting.SpotLight(name=None, color=None, intensity=None, radius=None, innerConeAngle=0.0, outerConeAngle=0.7853981633974483)

Bases: Light

Spot lights emit light in a cone in the direction of the local -z axis. The angle and falloff of the cone is defined using two numbers, the innerConeAngle and outerConeAngle. As with point lights, the brightness also attenuates in a physically correct manner as distance increases from the light’s position (i.e. brightness goes like the inverse square of the distance). Spot light intensity refers to the brightness inside the innerConeAngle (and at the location of the light) and is defined in candela, which is lumens per square radian (lm/sr). A spot light’s position and orientation are inherited from its node transform. Inherited scale does not affect cone shape, and is ignored except for its effect on position and orientation.

name

Name of the light.

Type:

str, optional

color

RGBA value for the light’s color in linear space.

Type:

(4,) uint8

intensity

Brightness of light. The units that this is defined in depend on the type of light. point and spot lights use luminous intensity in candela (lm/sr), while directional lights use illuminance in lux (lm/m2).

Type:

float

radius

Cutoff distance at which light’s intensity may be considered to have reached zero. Supported only for point and spot lights, must be > 0. If None, the radius is assumed to be infinite.

Type:

float

innerConeAngle

Angle, in radians, from centre of spotlight where falloff begins. Must be greater than or equal to 0 and less than outerConeAngle.

Type:

float

outerConeAngle

Angle, in radians, from centre of spotlight where falloff ends. Must be greater than innerConeAngle and less than or equal to PI / 2.0.

Type:

float

__init__(name=None, color=None, intensity=None, radius=None, innerConeAngle=0.0, outerConeAngle=0.7853981633974483)
property innerConeAngle
property outerConeAngle
trimesh.scene.lighting.autolight(scene)

Generate a list of lights for a scene that looks decent.

Parameters:

scene (trimesh.Scene) – Scene with geometry

Returns:

  • lights ([Light]) – List of light objects

  • transforms ((len(lights), 4, 4) float) – Transformation matrices for light positions.