Skip to content

Asset3D

Represents a generic 3D asset (e.g. mesh, point cloud, or scene) stored as raw bytes with an optional MIME type. Instances can be constructed from a file path (contents read from disk) or from in-memory contents. Common extensions (.ply, .obj, .glb, .gltf, .stl, .dae, etc.) are used for media-type inference when loading from path. This datatype is used for 3D asset inputs and outputs within the Telekinesis ecosystem.

Field

Required

Provide exactly one of path or contents.

FieldTypeDescription
pathstr or pathlib.Path or StringPath to file; contents are read from disk (str or Path).
contentsbytesRaw asset bytes. Use instead of path when supplying data in memory.

Optional

FieldTypeDescription
media_typestrMIME type string (e.g. model/gltf-binary, point_cloud/ply). Inferred from path when loading from file if not set.

Example

python
from pathlib import Path
from datatypes import datatypes
from loguru import logger

# ------------------------------------------------
# 1. Create Asset3D instance (from file path)
# ------------------------------------------------
asset = datatypes.Asset3D(path=Path("model.glb"))

# ------------------------------------------------
# 2. Create Asset3D instance (from bytes)
# ------------------------------------------------
raw_bytes = b"..."
asset = datatypes.Asset3D(contents=raw_bytes, media_type="model/gltf-binary")

# ------------------------------------------------
# 3. Access contents and media_type
# ------------------------------------------------
contents = asset.contents
media_type = asset.media_type
logger.info("Asset3D contents length (bytes)={}", len(contents))
logger.info("Asset3D media_type={}", media_type)