The glb_mesh.py module#

Summary#

triangulate_faces

Convert polygon faces to triangles using fan triangulation.

iter_usd_mesh_prims

Collect mesh prims from a USD stage.

convert_mesh_prim_to_gltf

Convert one USD mesh prim into GLTF mesh/node entries.

Description#

Mesh geometry conversion helpers for GLB export.

Module detail#

glb_mesh.triangulate_faces(indices: list[int], counts: list[int]) list[int]#

Convert polygon faces to triangles using fan triangulation.

Parameters:
indiceslist[int]

The list of vertex indices for all faces, as defined by USD’s faceVertexIndices.

countslist[int]

The list of vertex counts for each face, as defined by USD’s faceVertexCounts.

Returns:
list[int]

The list of triangle indices.

glb_mesh.iter_usd_mesh_prims(stage: Any) list[Any]#

Collect mesh prims from a USD stage.

Parameters:
stageAny

The USD stage to traverse for mesh prims.

Returns:
list[Any]

A list of USD mesh prims found in the stage.

glb_mesh.convert_mesh_prim_to_gltf(prim: Any, gltf: Any, scene: Any, builder: ansys.tools.visualization_interface.backends.usd.web.glb_builder.GLBBuilder, texture_cache: dict[tuple[str, str, str], int], image_cache: dict[str, int], sampler_cache: dict[tuple[int, int], int]) None#

Convert one USD mesh prim into GLTF mesh/node entries.

Parameters:
primAny

The USD mesh prim to convert.

gltfAny

The GLTF object to which the mesh will be added.

sceneAny

The GLTF scene to which the mesh node will be added.

builderGLBBuilder

The GLBBuilder instance used for constructing the GLTF.

texture_cachedict[tuple[str, str, str], int]

A cache mapping texture identifiers to GLTF texture indices.

image_cachedict[str, int]

A cache mapping image file paths to GLTF image indices.

sampler_cachedict[tuple[int, int], int]

A cache mapping sampler settings to GLTF sampler indices.