pyvista_wasm.GLTFReader#
- class pyvista_wasm.GLTFReader(path: str | Path, gltf_url: str | None = None)#
Bases:
objectReader for glTF (GL Transmission Format) files (
.gltfor.glb).Reads a glTF file and produces a
Meshthat delegates parsing to VTK.wasm’svtkGLTFImporterat render time. Python extracts vertex coordinates from the JSON structure so that camera framing and bounding-sphere queries work before rendering.- Parameters:
path (str or Path) – Path to the
.gltfor.glbfile.
See also
- using-download-damaged-helmet
Interactive browser tutorial for glTF rendering.
Examples
>>> import pyvista_wasm as pv >>> reader = pv.GLTFReader("model.gltf") >>> mesh = reader.read()
- __init__(path: str | Path, gltf_url: str | None = None) None#
Initialize the reader with a file path.
- Parameters:
path (str or Path) – Path to the
.gltfor.glbfile.gltf_url (str or None, optional) – Source URL of the glTF file. When provided, the returned mesh will render using the URL directly (avoiding large base64 embedding).
Methods
__init__(path[, gltf_url])Initialize the reader with a file path.
read()Read the glTF file and return a Mesh.
Attributes
Return the file path.
- property path: Path#
Return the file path.
- Returns:
The path to the glTF file.
- Return type:
Path
- read() _GLTFMesh#
Read the glTF file and return a Mesh.
The full file content is base64-encoded and stored so that VTK.wasm can parse it at render time. Vertex coordinates are extracted on the Python side for bounding-sphere and camera-framing calculations.
- Returns:
A mesh backed by the glTF file content.
- Return type:
Mesh
- Raises:
ValueError – If the file format is invalid.