class documentation

Represents a scene graph which contains a hierarchy of 3D objects.

Example usage:

import fiftyone as fo

scene = fo.Scene()

obj_mesh = fo.ObjMesh(
    "obj_mesh_name", "/path/to/mesh.obj", mtl_path="/path/to/mesh.mtl"
)
gltf_mesh = fo.GltfMesh("gltf_mesh_name", "/path/to/mesh.gltf")
pcd = fo.PointCloud("pcd_name", "/path/to/points.pcd")

scene.add(obj_mesh)
scene.add(gltf_mesh)
scene.add(pcd)

scene.write("/path/to/scene.fo3d")

sample = fo.Sample("/path/to/scene.fo3d")

dataset = fo.Dataset()
dataset.add_sample(sample)
Parameters
camerathe default camera of the scene. If None, a default fiftyone.core.threed.PerspectiveCamera is created with reasonable defaults
lightsa list of lights in the scene. If``None``, a default set of lights is used, which includes an ambient light and six directional lights placed at different angles around the scene
backgroundthe background for the scene. May be a color, image, or a skybox
Static Method from_fo3d Loads a scene from an FO3D file.
Method __init__ Undocumented
Method __repr__ Undocumented
Method copy Returns a deep copy of the scene.
Method get_asset_paths Returns a list of all asset paths in the scene.
Method get_scene_summary Returns a summary of the scene.
Method traverse Traverse the scene graph.
Method update_asset_paths Update asset paths in this scene according to an input dict mapping.
Method write Export the scene to a .fo3d file.
Instance Variable background Undocumented
Instance Variable camera Undocumented
Instance Variable lights Undocumented
Static Method _from_fo3d_dict Undocumented
Method _resolve_asset_path Undocumented
Method _resolve_node_asset_paths Undocumented
Method _to_dict_extra Returns the extra data to include in the dict representation.

Inherited from Object3D:

Method __eq__ Undocumented
Method __iter__ Undocumented
Method __str__ Undocumented
Method add Add one or more objects as children of this one.
Method as_dict Converts the object to a dict.
Method clear Remove all children from this object.
Method local_transform_matrix.setter Undocumented
Method position.setter Undocumented
Method quaternion.setter Undocumented
Method rotation.setter Undocumented
Method scale.setter Undocumented
Instance Variable children Undocumented
Instance Variable name Undocumented
Instance Variable visible Undocumented
Property local_transform_matrix The local transform matrix of the object.
Property position The position of the object in object space.
Property quaternion The quaternion of the object in object space.
Property rotation The rotation of the object in object space.
Property scale The scale of the object in object space.
Property uuid The unique ID of the object.
Static Method _from_dict Creates an Object3D (or its subclass) from a dict.
Method _get_asset_paths Get asset paths for this node
Method _update_matrix Undocumented
Class Variable _asset_path_fields Undocumented
Instance Variable _local_transform_matrix Undocumented
Instance Variable _position Undocumented
Instance Variable _quaternion Undocumented
Instance Variable _rotation Undocumented
Instance Variable _scale Undocumented
Instance Variable _uuid Undocumented
@staticmethod
def from_fo3d(path: str): (source)

Loads a scene from an FO3D file.

Parameters
path:strthe path to an .fo3d file
Returns
a Scene
def __init__(self, camera: PerspectiveCamera | None = None, lights: list[Light] | None = None, background: SceneBackground | None = None): (source)
def copy(self): (source)

Returns a deep copy of the scene.

def get_asset_paths(self): (source)

Returns a list of all asset paths in the scene.

Note that any relative asset paths are not resolved to absolute paths.

Returns
a list of asset paths
def get_scene_summary(self): (source)

Returns a summary of the scene.

def traverse(self, include_self=False): (source)

Traverse the scene graph.

Parameters
include_selfwhether to include the current node in the traversal
Returns
a generator that yields Object3D instances
def update_asset_paths(self, asset_rewrite_paths: dict): (source)

Update asset paths in this scene according to an input dict mapping.

Asset path is unchanged if it does not exist in asset_rewrite_paths

Parameters
asset_rewrite_paths:dictdict mapping asset path to new asset path
Returns
True if the scene was modified.
def write(self, fo3d_path: str, resolve_relative_paths=False, pprint=False): (source)

Export the scene to a .fo3d file.

Parameters
fo3d_path:strthe path to write the scene to
resolve_relative_pathswhether to resolve relative paths in the scene to absolute paths. If True, all asset paths in the scene are resolved to absolute paths. If False, asset paths are left as-is. Defaults to False.
pprintwhether to pretty-print the JSON output. Defaults to False.
background: None = (source)

Undocumented

Undocumented

Undocumented

@staticmethod
def _from_fo3d_dict(dict_data: dict): (source)

Undocumented

def _resolve_asset_path(self, root: str, path: str): (source)

Undocumented

def _resolve_node_asset_paths(self, node, fo3d_path_dir): (source)

Undocumented

def _to_dict_extra(self): (source)

Returns the extra data to include in the dict representation.