lagrange.scene

Module Contents

Classes

Animation

Animation

AnimationList

Camera

Camera

CameraList

ElementIdList

Extensions

FacetAllocationStrategy

Create a collection of name/value pairs.

Image

Image structure that can store either image data or reference to an image file

ImageBuffer

Minimalistic image data structure that stores the raw image data

ImageList

Light

Light

LightList

Material

PBR material, based on the gltf specification. This is subject to change, to support more material models

MaterialList

MeshInstance3D

A single mesh instance in a scene

Node

Represents a node in the scene hierarchy

NodeList

RemeshingOptions

Scene

A 3D scene

SceneMeshInstance

Pairs a mesh with its materials (zero, one, or more)

SceneMeshInstanceList

SimpleScene3D

Simple scene container for instanced meshes

Skeleton

Skeleton

SkeletonList

SurfaceMeshList

Texture

Texture

TextureInfo

Pair of texture index (which texture to use) and texture coordinate index (which set of UVs to use)

TextureList

Functions

compute_global_node_transform(scene, node_idx)

Compute the global transform associated with a node.

mesh_to_scene(mesh)

Converts a single mesh into a scene with a single identity instance of the input mesh.

mesh_to_simple_scene(mesh)

Converts a single mesh into a simple scene with a single identity instance of the input mesh.

meshes_to_scene(meshes)

Converts a list of meshes into a scene with a single identity instance of each input mesh.

meshes_to_simple_scene(meshes)

Converts a list of meshes into a simple scene with a single identity instance of each input mesh.

scene_to_mesh(scene[, normalize_normals, ...])

Converts a scene into a concatenated mesh with all the transforms applied.

simple_scene_to_mesh(scene[, normalize_normals, ...])

Converts a scene into a concatenated mesh with all the transforms applied.

class lagrange.scene.Animation

Animation

property extensions: Extensions

Animation extensions

Return type:

Extensions

property name: str

Animation name

Return type:

str

__repr__()

Return repr(self).

Return type:

str

class lagrange.scene.AnimationList
class lagrange.scene.AnimationList(arg)
class lagrange.scene.AnimationList(arg, /)
__bool__()

Check whether the vector is nonempty

Return type:

bool

__contains__(arg: Animation, /) bool
__contains__(arg: object, /) bool
__delitem__(arg: int, /) None
__delitem__(arg: slice, /) None
__eq__(arg, /)

Return self==value.

Parameters:

arg (object)

Return type:

bool

__getitem__(arg: int, /) Animation
__getitem__(arg: slice, /) AnimationList
__iter__()
Return type:

collections.abc.Iterator[Animation]

__len__()
Return type:

int

__ne__(arg, /)

Return self!=value.

Parameters:

arg (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__setitem__(arg0: int, arg1: Animation, /) None
__setitem__(arg0: slice, arg1: AnimationList, /) None
append(arg, /)

Append arg to the end of the list.

Parameters:

arg (Animation)

Return type:

None

clear()

Remove all items from list.

Return type:

None

count(arg, /)

Return number of occurrences of arg.

Parameters:

arg (Animation)

Return type:

int

extend(arg, /)

Extend self by appending elements from arg.

Parameters:

arg (AnimationList)

Return type:

None

insert(arg0, arg1, /)

Insert object arg1 before index arg0.

Parameters:
Return type:

None

pop(index=-1)

Remove and return item at index (default last).

Parameters:

index (int)

Return type:

Animation

remove(arg, /)

Remove first occurrence of arg.

Parameters:

arg (Animation)

Return type:

None

class lagrange.scene.Camera

Camera

class Type(*args, **kwds)

Bases: enum.Enum

Camera type

Orthographic = 1

Orthographic projection

Perspective = 0

Perspective projection

property aspect_ratio: float

Screen aspect ratio. This is the value of width / height of the screen. aspect_ratio = tan(horizontal_fov / 2) / tan(vertical_fov / 2)

Return type:

float

property extensions: Extensions

Camera extensions

Return type:

Extensions

property far_plane: float | None

Distance of the far clipping plane

Return type:

float | None

property get_vertical_fov: float

Get the vertical field of view. Make sure aspect_ratio is set before calling this

Return type:

float

property horizontal_fov: float

Horizontal field of view angle, in radians. This is the angle between the left and right borders of the viewport. It should not be greater than Pi. fov is only defined when the camera type is perspective, otherwise it should be 0

Return type:

float

property look_at: Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order='C')]

Camera look-at point

Return type:

Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order=’C’)]

property name: str

Camera name

Return type:

str

property near_plane: float

Distance of the near clipping plane. This value cannot be 0

Return type:

float

property orthographic_width: float

Half width of the orthographic view box. Or horizontal magnification. This is only defined when the camera type is orthographic, otherwise it should be 0

Return type:

float

property position: Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order='C')]

Camera position. Note that the camera is part of the scene graph, and has an associated transform in its node. This value is relative to the coordinate system defined by the node

Return type:

Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order=’C’)]

property type: Camera

Camera type

Return type:

Camera

property up: Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order='C')]

Camera up vector

Return type:

Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order=’C’)]

__repr__()

Return repr(self).

Return type:

str

set_horizontal_fov_from_vertical_fov(vfov)

Set horizontal fov from vertical fov. Make sure aspect_ratio is set before calling this

Parameters:

vfov (float)

Return type:

None

class lagrange.scene.CameraList
class lagrange.scene.CameraList(arg)
class lagrange.scene.CameraList(arg, /)
__bool__()

Check whether the vector is nonempty

Return type:

bool

__contains__(arg: Camera, /) bool
__contains__(arg: object, /) bool
__delitem__(arg: int, /) None
__delitem__(arg: slice, /) None
__eq__(arg, /)

Return self==value.

Parameters:

arg (object)

Return type:

bool

__getitem__(arg: int, /) Camera
__getitem__(arg: slice, /) CameraList
__iter__()
Return type:

collections.abc.Iterator[Camera]

__len__()
Return type:

int

__ne__(arg, /)

Return self!=value.

Parameters:

arg (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__setitem__(arg0: int, arg1: Camera, /) None
__setitem__(arg0: slice, arg1: CameraList, /) None
append(arg, /)

Append arg to the end of the list.

Parameters:

arg (Camera)

Return type:

None

clear()

Remove all items from list.

Return type:

None

count(arg, /)

Return number of occurrences of arg.

Parameters:

arg (Camera)

Return type:

int

extend(arg, /)

Extend self by appending elements from arg.

Parameters:

arg (CameraList)

Return type:

None

insert(arg0, arg1, /)

Insert object arg1 before index arg0.

Parameters:
Return type:

None

pop(index=-1)

Remove and return item at index (default last).

Parameters:

index (int)

Return type:

Camera

remove(arg, /)

Remove first occurrence of arg.

Parameters:

arg (Camera)

Return type:

None

class lagrange.scene.ElementIdList
class lagrange.scene.ElementIdList(arg)
class lagrange.scene.ElementIdList(arg, /)
__bool__()

Check whether the vector is nonempty

Return type:

bool

__contains__(arg: int, /) bool
__contains__(arg: object, /) bool
__delitem__(arg: int, /) None
__delitem__(arg: slice, /) None
__eq__(arg, /)

Return self==value.

Parameters:

arg (object)

Return type:

bool

__getitem__(arg: int, /) int
__getitem__(arg: slice, /) ElementIdList
__iter__()
Return type:

collections.abc.Iterator[int]

__len__()
Return type:

int

__ne__(arg, /)

Return self!=value.

Parameters:

arg (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__setitem__(arg0: int, arg1: int, /) None
__setitem__(arg0: slice, arg1: ElementIdList, /) None
append(arg, /)

Append arg to the end of the list.

Parameters:

arg (int)

Return type:

None

clear()

Remove all items from list.

Return type:

None

count(arg, /)

Return number of occurrences of arg.

Parameters:

arg (int)

Return type:

int

extend(arg, /)

Extend self by appending elements from arg.

Parameters:

arg (ElementIdList)

Return type:

None

insert(arg0, arg1, /)

Insert object arg1 before index arg0.

Parameters:
  • arg0 (int)

  • arg1 (int)

Return type:

None

pop(index=-1)

Remove and return item at index (default last).

Parameters:

index (int)

Return type:

int

remove(arg, /)

Remove first occurrence of arg.

Parameters:

arg (int)

Return type:

None

class lagrange.scene.Extensions
property data: dict[str, int | float | str | list | dict | bool]

Raw data stored in this extension as a dict

Return type:

dict[str, int | float | str | list | dict | bool]

property empty: bool
Return type:

bool

property size: int
Return type:

int

__repr__()

Return repr(self).

Return type:

str

class lagrange.scene.FacetAllocationStrategy(*args, **kwds)

Bases: enum.Enum

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

    >>> Color.RED
    <Color.RED: 1>
    
  • value lookup:

    >>> Color(1)
    <Color.RED: 1>
    
  • name lookup:

    >>> Color['RED']
    <Color.RED: 1>
    

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

EvenSplit = 0
RelativeToMeshArea = 1
RelativeToNumFacets = 2
Synchronized = 3
class lagrange.scene.Image

Image structure that can store either image data or reference to an image file

property extensions: Extensions

Image extensions

Return type:

Extensions

property image: ImageBuffer

Image data

Return type:

ImageBuffer

property name: str

Image name. Not guaranteed to be unique and can be empty

Return type:

str

property uri: str | None

Image file path. This path is relative to the file that contains the scene. It is only valid if image data should be mapped to an external file

Return type:

str | None

__repr__()

Return repr(self).

Return type:

str

class lagrange.scene.ImageBuffer

Minimalistic image data structure that stores the raw image data

property data: object

Raw buffer of size (width * height * num_channels * num_bits_per_element / 8) bytes containing image data

Return type:

object

property dtype: type | None

The scalar type of the elements in the buffer

Return type:

type | None

property height: int

Image height

Return type:

int

property num_channels: int

Number of image channels (must be 1, 3, or 4)

Return type:

int

property width: int

Image width

Return type:

int

__repr__()

Return repr(self).

Return type:

str

class lagrange.scene.ImageList
class lagrange.scene.ImageList(arg)
class lagrange.scene.ImageList(arg, /)
__bool__()

Check whether the vector is nonempty

Return type:

bool

__contains__(arg: Image, /) bool
__contains__(arg: object, /) bool
__delitem__(arg: int, /) None
__delitem__(arg: slice, /) None
__eq__(arg, /)

Return self==value.

Parameters:

arg (object)

Return type:

bool

__getitem__(arg: int, /) Image
__getitem__(arg: slice, /) ImageList
__iter__()
Return type:

collections.abc.Iterator[Image]

__len__()
Return type:

int

__ne__(arg, /)

Return self!=value.

Parameters:

arg (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__setitem__(arg0: int, arg1: Image, /) None
__setitem__(arg0: slice, arg1: ImageList, /) None
append(arg, /)

Append arg to the end of the list.

Parameters:

arg (Image)

Return type:

None

clear()

Remove all items from list.

Return type:

None

count(arg, /)

Return number of occurrences of arg.

Parameters:

arg (Image)

Return type:

int

extend(arg, /)

Extend self by appending elements from arg.

Parameters:

arg (ImageList)

Return type:

None

insert(arg0, arg1, /)

Insert object arg1 before index arg0.

Parameters:
  • arg0 (int)

  • arg1 (Image)

Return type:

None

pop(index=-1)

Remove and return item at index (default last).

Parameters:

index (int)

Return type:

Image

remove(arg, /)

Remove first occurrence of arg.

Parameters:

arg (Image)

Return type:

None

class lagrange.scene.Light

Light

class Type(*args, **kwds)

Bases: enum.Enum

Light type

Ambient = 4

Ambient light

Area = 5

Area light

Directional = 1

Directional light

Point = 2

Point light

Spot = 3

Spot light

Undefined = 0

Undefined light type

property angle_inner_cone: float

Inner angle of a spot light’s light cone. 2PI for point lights, undefined for directional lights

Return type:

float

property angle_outer_cone: float

Outer angle of a spot light’s light cone. 2PI for point lights, undefined for directional lights

Return type:

float

property attenuation_constant: float

intensity / (attenuation_constant + attenuation_linear * d + attenuation_quadratic * d * d + attenuation_cubic * d * d * d)

Type:

Attenuation constant. Intensity of light at a given distance ‘d’ is

Return type:

float

property attenuation_cubic: float

Cubic attenuation factor

Return type:

float

property attenuation_linear: float

Linear attenuation factor

Return type:

float

property attenuation_quadratic: float

Quadratic attenuation factor

Return type:

float

property color_ambient: Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order='C')]

Ambient color

Return type:

Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order=’C’)]

property color_diffuse: Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order='C')]

Diffuse color

Return type:

Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order=’C’)]

property color_specular: Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order='C')]

Specular color

Return type:

Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order=’C’)]

property direction: Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order='C')]

Light direction

Return type:

Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order=’C’)]

property extensions: Extensions

Light extensions

Return type:

Extensions

property intensity: float

Light intensity

Return type:

float

property name: str

Light name

Return type:

str

property position: Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order='C')]

Light position. Note that the light is part of the scene graph, and has an associated transform in its node. This value is relative to the coordinate system defined by the node

Return type:

Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order=’C’)]

property range: float

Range is defined for point and spot lights. It defines a distance cutoff at which the light intensity is to be considered zero. When the value is 0, range is assumed to be infinite

Return type:

float

property size: Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=2, order='C')]

Size of area light source

Return type:

Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=2, order=’C’)]

property type: Light

Light type

Return type:

Light

property up: Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order='C')]

Light up vector

Return type:

Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order=’C’)]

__repr__()

Return repr(self).

Return type:

str

class lagrange.scene.LightList
class lagrange.scene.LightList(arg)
class lagrange.scene.LightList(arg, /)
__bool__()

Check whether the vector is nonempty

Return type:

bool

__contains__(arg: Light, /) bool
__contains__(arg: object, /) bool
__delitem__(arg: int, /) None
__delitem__(arg: slice, /) None
__eq__(arg, /)

Return self==value.

Parameters:

arg (object)

Return type:

bool

__getitem__(arg: int, /) Light
__getitem__(arg: slice, /) LightList
__iter__()
Return type:

collections.abc.Iterator[Light]

__len__()
Return type:

int

__ne__(arg, /)

Return self!=value.

Parameters:

arg (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__setitem__(arg0: int, arg1: Light, /) None
__setitem__(arg0: slice, arg1: LightList, /) None
append(arg, /)

Append arg to the end of the list.

Parameters:

arg (Light)

Return type:

None

clear()

Remove all items from list.

Return type:

None

count(arg, /)

Return number of occurrences of arg.

Parameters:

arg (Light)

Return type:

int

extend(arg, /)

Extend self by appending elements from arg.

Parameters:

arg (LightList)

Return type:

None

insert(arg0, arg1, /)

Insert object arg1 before index arg0.

Parameters:
  • arg0 (int)

  • arg1 (Light)

Return type:

None

pop(index=-1)

Remove and return item at index (default last).

Parameters:

index (int)

Return type:

Light

remove(arg, /)

Remove first occurrence of arg.

Parameters:

arg (Light)

Return type:

None

class lagrange.scene.Material

PBR material, based on the gltf specification. This is subject to change, to support more material models

class AlphaMode(*args, **kwds)

Bases: enum.Enum

Alpha mode

Blend = 2

Alpha value is used to composite source and destination

Mask = 1

Output is either opaque or transparent depending on the alpha value and the alpha_cutoff value

Opaque = 0

Alpha is ignored, and rendered output is opaque

property alpha_cutoff: float

Alpha cutoff value

Return type:

float

property alpha_mode: Material

The alpha mode specifies how to interpret the alpha value of the base color

Return type:

Material

property base_color_texture: TextureInfo

Base color texture

Return type:

TextureInfo

property base_color_value: Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=4, order='C')]

Base color value

Return type:

Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=4, order=’C’)]

property double_sided: bool

Whether the material is double-sided

Return type:

bool

property emissive_texture: TextureInfo

Emissive texture

Return type:

TextureInfo

property emissive_value: Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order='C')]

Emissive color value

Return type:

Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=3, order=’C’)]

property extensions: Extensions

Material extensions

Return type:

Extensions

property metallic_roughness_texture: TextureInfo

Metalness and roughness are packed together in a single texture. Green channel has roughness, blue channel has metalness

Return type:

TextureInfo

property metallic_value: float

Metallic value

Return type:

float

property name: str

Material name. May not be unique, and can be empty

Return type:

str

property normal_scale: float

Normal scaling factor. normal = normalize(<sampled tex value> * 2 - 1) * vec3(scale, scale, 1)

Return type:

float

property normal_texture: TextureInfo

Normal texture

Return type:

TextureInfo

property occlusion_strength: float

Occlusion strength. color = lerp(color, color * <sampled tex value>, strength)

Return type:

float

property occlusion_texture: TextureInfo

Occlusion texture

Return type:

TextureInfo

property roughness_value: float

Roughness value

Return type:

float

__repr__()

Return repr(self).

Return type:

str

class lagrange.scene.MaterialList
class lagrange.scene.MaterialList(arg)
class lagrange.scene.MaterialList(arg, /)
__bool__()

Check whether the vector is nonempty

Return type:

bool

__contains__(arg: Material, /) bool
__contains__(arg: object, /) bool
__delitem__(arg: int, /) None
__delitem__(arg: slice, /) None
__eq__(arg, /)

Return self==value.

Parameters:

arg (object)

Return type:

bool

__getitem__(arg: int, /) Material
__getitem__(arg: slice, /) MaterialList
__iter__()
Return type:

collections.abc.Iterator[Material]

__len__()
Return type:

int

__ne__(arg, /)

Return self!=value.

Parameters:

arg (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__setitem__(arg0: int, arg1: Material, /) None
__setitem__(arg0: slice, arg1: MaterialList, /) None
append(arg, /)

Append arg to the end of the list.

Parameters:

arg (Material)

Return type:

None

clear()

Remove all items from list.

Return type:

None

count(arg, /)

Return number of occurrences of arg.

Parameters:

arg (Material)

Return type:

int

extend(arg, /)

Extend self by appending elements from arg.

Parameters:

arg (MaterialList)

Return type:

None

insert(arg0, arg1, /)

Insert object arg1 before index arg0.

Parameters:
Return type:

None

pop(index=-1)

Remove and return item at index (default last).

Parameters:

index (int)

Return type:

Material

remove(arg, /)

Remove first occurrence of arg.

Parameters:

arg (Material)

Return type:

None

class lagrange.scene.MeshInstance3D

A single mesh instance in a scene

property mesh_index: int
Return type:

int

property transform: Annotated[numpy.typing.NDArray[numpy.float64], dict(order='C', device='cpu')]
Return type:

Annotated[numpy.typing.NDArray[numpy.float64], dict(order=’C’, device=’cpu’)]

class lagrange.scene.Node

Represents a node in the scene hierarchy

property cameras: ElementIdList

List of cameras contained in this node

Return type:

ElementIdList

property children: ElementIdList

Children indices. May be empty

Return type:

ElementIdList

property extensions: Extensions
Return type:

Extensions

property lights: ElementIdList

List of lights contained in this node

Return type:

ElementIdList

property meshes: SceneMeshInstanceList

List of meshes contained in this node

Return type:

SceneMeshInstanceList

property name: str

Node name. May not be unique and can be empty

Return type:

str

property parent: int | None

Parent index. May be invalid if the node has no parent (e.g. the root)

Return type:

int | None

property transform: Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=4, 4, order='F')]

Transform of the node, relative to its parent

Return type:

Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=(4, 4), order=’F’)]

__repr__()

Return repr(self).

Return type:

str

class lagrange.scene.NodeList
class lagrange.scene.NodeList(arg)
class lagrange.scene.NodeList(arg, /)
__bool__()

Check whether the vector is nonempty

Return type:

bool

__contains__(arg: Node, /) bool
__contains__(arg: object, /) bool
__delitem__(arg: int, /) None
__delitem__(arg: slice, /) None
__eq__(arg, /)

Return self==value.

Parameters:

arg (object)

Return type:

bool

__getitem__(arg: int, /) Node
__getitem__(arg: slice, /) NodeList
__iter__()
Return type:

collections.abc.Iterator[Node]

__len__()
Return type:

int

__ne__(arg, /)

Return self!=value.

Parameters:

arg (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__setitem__(arg0: int, arg1: Node, /) None
__setitem__(arg0: slice, arg1: NodeList, /) None
append(arg, /)

Append arg to the end of the list.

Parameters:

arg (Node)

Return type:

None

clear()

Remove all items from list.

Return type:

None

count(arg, /)

Return number of occurrences of arg.

Parameters:

arg (Node)

Return type:

int

extend(arg, /)

Extend self by appending elements from arg.

Parameters:

arg (NodeList)

Return type:

None

insert(arg0, arg1, /)

Insert object arg1 before index arg0.

Parameters:
  • arg0 (int)

  • arg1 (Node)

Return type:

None

pop(index=-1)

Remove and return item at index (default last).

Parameters:

index (int)

Return type:

Node

remove(arg, /)

Remove first occurrence of arg.

Parameters:

arg (Node)

Return type:

None

class lagrange.scene.RemeshingOptions
property facet_allocation_strategy: FacetAllocationStrategy
Return type:

FacetAllocationStrategy

property min_facets: int
Return type:

int

class lagrange.scene.Scene

A 3D scene

property animations: AnimationList

Animations (unused for now)

Return type:

AnimationList

property cameras: CameraList

Cameras. The first camera (if any) is the default camera view

Return type:

CameraList

property extensions: Extensions

Scene extensions

Return type:

Extensions

property images: ImageList

Images

Return type:

ImageList

property lights: LightList

Lights in the scene

Return type:

LightList

property materials: MaterialList

Materials. They can reference textures

Return type:

MaterialList

property meshes: SurfaceMeshList

Scene meshes

Return type:

SurfaceMeshList

property name: str

Name of the scene

Return type:

str

property nodes: NodeList

Scene nodes. This is a list of nodes, the hierarchy information is contained by each node having a list of children as indices to this vector

Return type:

NodeList

property root_nodes: ElementIdList

Root nodes. This is typically one. Must be at least one

Return type:

ElementIdList

property skeletons: SkeletonList

Scene skeletons

Return type:

SkeletonList

property textures: TextureList

Textures. They can reference images

Return type:

TextureList

__repr__()

Return repr(self).

Return type:

str

add(element)

Add an element to the scene.

Parameters:

element (Node | lagrange.core.SurfaceMesh | Image | Texture | Material | Light | Camera | Skeleton | Animation) – The element to add to the scene. E.g. node, mesh, image, texture, material, light, camera, skeleton, or animation.

Returns:

The id of the added element.

Return type:

int

add_child(parent_id, child_id)

Add a child node to a parent node. The parent-child relationship will be updated for both nodes.

Parameters:
  • parent_id (int) – The parent node id.

  • child_id (int) – The child node id.

Returns:

The id of the added child node.

Return type:

None

class lagrange.scene.SceneMeshInstance

Pairs a mesh with its materials (zero, one, or more)

property materials: ElementIdList

Material indices in the scene.materials vector. This is typically a single material index. When a single mesh uses multiple materials, the AttributeName::material_id facet attribute should be defined.

Return type:

ElementIdList

property mesh: int | None

Mesh index. Has to be a valid index in the scene.meshes vector (None if invalid)

Return type:

int | None

__repr__()

Return repr(self).

Return type:

str

class lagrange.scene.SceneMeshInstanceList
class lagrange.scene.SceneMeshInstanceList(arg)
class lagrange.scene.SceneMeshInstanceList(arg, /)
__bool__()

Check whether the vector is nonempty

Return type:

bool

__contains__(arg: SceneMeshInstance, /) bool
__contains__(arg: object, /) bool
__delitem__(arg: int, /) None
__delitem__(arg: slice, /) None
__eq__(arg, /)

Return self==value.

Parameters:

arg (object)

Return type:

bool

__getitem__(arg: int, /) SceneMeshInstance
__getitem__(arg: slice, /) SceneMeshInstanceList
__iter__()
Return type:

collections.abc.Iterator[SceneMeshInstance]

__len__()
Return type:

int

__ne__(arg, /)

Return self!=value.

Parameters:

arg (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__setitem__(arg0: int, arg1: SceneMeshInstance, /) None
__setitem__(arg0: slice, arg1: SceneMeshInstanceList, /) None
append(arg, /)

Append arg to the end of the list.

Parameters:

arg (SceneMeshInstance)

Return type:

None

clear()

Remove all items from list.

Return type:

None

count(arg, /)

Return number of occurrences of arg.

Parameters:

arg (SceneMeshInstance)

Return type:

int

extend(arg, /)

Extend self by appending elements from arg.

Parameters:

arg (SceneMeshInstanceList)

Return type:

None

insert(arg0, arg1, /)

Insert object arg1 before index arg0.

Parameters:
Return type:

None

pop(index=-1)

Remove and return item at index (default last).

Parameters:

index (int)

Return type:

SceneMeshInstance

remove(arg, /)

Remove first occurrence of arg.

Parameters:

arg (SceneMeshInstance)

Return type:

None

class lagrange.scene.SimpleScene3D

Simple scene container for instanced meshes

property num_meshes: int

Number of meshes in the scene

Return type:

int

property total_num_instances: int

Total number of instances for all meshes in the scene

Return type:

int

add_instance(instance)
Parameters:

instance (MeshInstance3D)

Return type:

int

add_mesh(mesh)
Parameters:

mesh (lagrange.core.SurfaceMesh)

Return type:

int

get_instance(mesh_index, instance_index)
Parameters:
  • mesh_index (int)

  • instance_index (int)

Return type:

MeshInstance3D

get_mesh(mesh_index)
Parameters:

mesh_index (int)

Return type:

lagrange.core.SurfaceMesh

num_instances(mesh_index)
Parameters:

mesh_index (int)

Return type:

int

ref_mesh(mesh_index)
Parameters:

mesh_index (int)

Return type:

lagrange.core.SurfaceMesh

reserve_instances(mesh_index, num_instances)
Parameters:
  • mesh_index (int)

  • num_instances (int)

Return type:

None

reserve_meshes(num_meshes)
Parameters:

num_meshes (int)

Return type:

None

class lagrange.scene.Skeleton

Skeleton

property extensions: Extensions

Skeleton extensions

Return type:

Extensions

property meshes: ElementIdList

This skeleton is used to deform those meshes. This will typically contain one value, but can have zero or multiple meshes. The value is the index in the scene meshes

Return type:

ElementIdList

__repr__()

Return repr(self).

Return type:

str

class lagrange.scene.SkeletonList
class lagrange.scene.SkeletonList(arg)
class lagrange.scene.SkeletonList(arg, /)
__bool__()

Check whether the vector is nonempty

Return type:

bool

__contains__(arg: Skeleton, /) bool
__contains__(arg: object, /) bool
__delitem__(arg: int, /) None
__delitem__(arg: slice, /) None
__eq__(arg, /)

Return self==value.

Parameters:

arg (object)

Return type:

bool

__getitem__(arg: int, /) Skeleton
__getitem__(arg: slice, /) SkeletonList
__iter__()
Return type:

collections.abc.Iterator[Skeleton]

__len__()
Return type:

int

__ne__(arg, /)

Return self!=value.

Parameters:

arg (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__setitem__(arg0: int, arg1: Skeleton, /) None
__setitem__(arg0: slice, arg1: SkeletonList, /) None
append(arg, /)

Append arg to the end of the list.

Parameters:

arg (Skeleton)

Return type:

None

clear()

Remove all items from list.

Return type:

None

count(arg, /)

Return number of occurrences of arg.

Parameters:

arg (Skeleton)

Return type:

int

extend(arg, /)

Extend self by appending elements from arg.

Parameters:

arg (SkeletonList)

Return type:

None

insert(arg0, arg1, /)

Insert object arg1 before index arg0.

Parameters:
Return type:

None

pop(index=-1)

Remove and return item at index (default last).

Parameters:

index (int)

Return type:

Skeleton

remove(arg, /)

Remove first occurrence of arg.

Parameters:

arg (Skeleton)

Return type:

None

class lagrange.scene.SurfaceMeshList
class lagrange.scene.SurfaceMeshList(arg)
class lagrange.scene.SurfaceMeshList(arg, /)
__bool__()

Check whether the vector is nonempty

Return type:

bool

__contains__(arg: lagrange.core.SurfaceMesh, /) bool
__contains__(arg: object, /) bool
__delitem__(arg: int, /) None
__delitem__(arg: slice, /) None
__eq__(arg, /)

Return self==value.

Parameters:

arg (object)

Return type:

bool

__getitem__(arg: int, /) lagrange.core.SurfaceMesh
__getitem__(arg: slice, /) SurfaceMeshList
__iter__()
Return type:

collections.abc.Iterator[lagrange.core.SurfaceMesh]

__len__()
Return type:

int

__ne__(arg, /)

Return self!=value.

Parameters:

arg (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__setitem__(arg0: int, arg1: lagrange.core.SurfaceMesh, /) None
__setitem__(arg0: slice, arg1: SurfaceMeshList, /) None
append(arg, /)

Append arg to the end of the list.

Parameters:

arg (lagrange.core.SurfaceMesh)

Return type:

None

clear()

Remove all items from list.

Return type:

None

count(arg, /)

Return number of occurrences of arg.

Parameters:

arg (lagrange.core.SurfaceMesh)

Return type:

int

extend(arg, /)

Extend self by appending elements from arg.

Parameters:

arg (SurfaceMeshList)

Return type:

None

insert(arg0, arg1, /)

Insert object arg1 before index arg0.

Parameters:
Return type:

None

pop(index=-1)

Remove and return item at index (default last).

Parameters:

index (int)

Return type:

lagrange.core.SurfaceMesh

remove(arg, /)

Remove first occurrence of arg.

Parameters:

arg (lagrange.core.SurfaceMesh)

Return type:

None

class lagrange.scene.Texture

Texture

class TextureFilter(*args, **kwds)

Bases: enum.Enum

Texture filter mode

Linear = 9729

Linear filtering

LinearMipmapLinear = 9987

Linear mipmap linear filtering

LinearMipmapNearest = 9985

Linear mipmap nearest filtering

Nearest = 9728

Nearest neighbor filtering

NearestMipmapLinear = 9986

Nearest mipmap linear filtering

NearestMipmapNearest = 9984

Nearest mipmap nearest filtering

Undefined = 0

Undefined filter

class WrapMode(*args, **kwds)

Bases: enum.Enum

Texture wrap mode

Clamp = 1

Coordinates outside [0, 1] are clamped to the nearest value

Decal = 2

If the texture coordinates for a pixel are outside [0, 1], the texture is not applied

Mirror = 3

Mirror wrap mode

Wrap = 0

u|v becomes u%1|v%1

property extensions: Extensions

Texture extensions

Return type:

Extensions

property image: int | None

Index of image in scene.images vector (None if invalid)

Return type:

int | None

property mag_filter: Texture

Texture magnification filter, used when texture appears larger on screen than the source image

Return type:

Texture

property min_filter: Texture

Texture minification filter, used when the texture appears smaller on screen than the source image

Return type:

Texture

property name: str

Texture name

Return type:

str

property offset: Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=2, order='C')]

Texture offset

Return type:

Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=2, order=’C’)]

property rotation: float

Texture rotation

Return type:

float

property scale: Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=2, order='C')]

Texture scale

Return type:

Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=2, order=’C’)]

property wrap_u: Texture

Texture wrap mode for U coordinate

Return type:

Texture

property wrap_v: Texture

Texture wrap mode for V coordinate

Return type:

Texture

__repr__()

Return repr(self).

Return type:

str

class lagrange.scene.TextureInfo

Pair of texture index (which texture to use) and texture coordinate index (which set of UVs to use)

property index: int | None

Texture index. Index in scene.textures vector. None if not set

Return type:

int | None

property texcoord: int

Index of UV coordinates. Usually stored in the mesh as texcoord_x attribute where x is this variable. This is typically 0

Return type:

int

__repr__()

Return repr(self).

Return type:

str

class lagrange.scene.TextureList
class lagrange.scene.TextureList(arg)
class lagrange.scene.TextureList(arg, /)
__bool__()

Check whether the vector is nonempty

Return type:

bool

__contains__(arg: Texture, /) bool
__contains__(arg: object, /) bool
__delitem__(arg: int, /) None
__delitem__(arg: slice, /) None
__eq__(arg, /)

Return self==value.

Parameters:

arg (object)

Return type:

bool

__getitem__(arg: int, /) Texture
__getitem__(arg: slice, /) TextureList
__iter__()
Return type:

collections.abc.Iterator[Texture]

__len__()
Return type:

int

__ne__(arg, /)

Return self!=value.

Parameters:

arg (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__setitem__(arg0: int, arg1: Texture, /) None
__setitem__(arg0: slice, arg1: TextureList, /) None
append(arg, /)

Append arg to the end of the list.

Parameters:

arg (Texture)

Return type:

None

clear()

Remove all items from list.

Return type:

None

count(arg, /)

Return number of occurrences of arg.

Parameters:

arg (Texture)

Return type:

int

extend(arg, /)

Extend self by appending elements from arg.

Parameters:

arg (TextureList)

Return type:

None

insert(arg0, arg1, /)

Insert object arg1 before index arg0.

Parameters:
Return type:

None

pop(index=-1)

Remove and return item at index (default last).

Parameters:

index (int)

Return type:

Texture

remove(arg, /)

Remove first occurrence of arg.

Parameters:

arg (Texture)

Return type:

None

lagrange.scene.compute_global_node_transform(scene, node_idx)

Compute the global transform associated with a node.

Parameters:
  • scene (Scene) – The input scene.

  • node_idx (int) – The index of the target node.

Returns:

The global transform of the target node, which is the combination of transforms from this node all the way to the root.

Return type:

Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=(4, 4), order=’F’)]

lagrange.scene.mesh_to_scene(mesh)

Converts a single mesh into a scene with a single identity instance of the input mesh.

Parameters:

mesh (lagrange.core.SurfaceMesh) – Input mesh to convert.

Returns:

Scene containing the input mesh.

Return type:

Scene

lagrange.scene.mesh_to_simple_scene(mesh)

Converts a single mesh into a simple scene with a single identity instance of the input mesh.

Parameters:

mesh (lagrange.core.SurfaceMesh) – Input mesh to convert.

Returns:

Simple scene containing the input mesh.

Return type:

SimpleScene3D

lagrange.scene.meshes_to_scene(meshes)

Converts a list of meshes into a scene with a single identity instance of each input mesh.

Parameters:

meshes (collections.abc.Sequence[lagrange.core.SurfaceMesh]) – Input meshes to convert.

Returns:

Scene containing the input meshes.

Return type:

Scene

lagrange.scene.meshes_to_simple_scene(meshes)

Converts a list of meshes into a simple scene with a single identity instance of each input mesh.

Parameters:

meshes (collections.abc.Sequence[lagrange.core.SurfaceMesh]) – Input meshes to convert.

Returns:

Simple scene containing the input meshes.

Return type:

SimpleScene3D

lagrange.scene.scene_to_mesh(scene, normalize_normals=True, normalize_tangents_bitangents=True, preserve_attributes=True)

Converts a scene into a concatenated mesh with all the transforms applied.

Parameters:
  • scene (Scene) – Scene to convert.

  • normalize_normals (bool) – If enabled, normals are normalized after transformation.

  • normalize_tangents_bitangents (bool) – If enabled, tangents and bitangents are normalized after transformation.

  • preserve_attributes (bool) – Preserve shared attributes and map them to the output mesh.

Returns:

Concatenated mesh.

Return type:

lagrange.core.SurfaceMesh

lagrange.scene.simple_scene_to_mesh(scene, normalize_normals=True, normalize_tangents_bitangents=True, preserve_attributes=True)

Converts a scene into a concatenated mesh with all the transforms applied.

Parameters:
  • scene (SimpleScene3D) – Scene to convert.

  • normalize_normals (bool) – If enabled, normals are normalized after transformation.

  • normalize_tangents_bitangents (bool) – If enabled, tangents and bitangents are normalized after transformation.

  • preserve_attributes (bool) – Preserve shared attributes and map them to the output mesh.

Returns:

Concatenated mesh.

Return type:

lagrange.core.SurfaceMesh