The glb_materials.py module#

Summary#

get_material_index

Resolve GLTF material index from USD bindings or displayColor fallback.

Description#

Material and texture conversion helpers for GLB export.

Module detail#

glb_materials.get_material_index(prim: Any, display_colors: Any, color_interpolation: Any, gltf: 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]) int | None#

Resolve GLTF material index from USD bindings or displayColor fallback.

Parameters:
primAny

The USD prim to get the material for.

display_colorsAny

The displayColor values to use for the material.

color_interpolationAny

The interpolation method for the display colors.

gltfAny

The glTF document to modify with new textures, images, and samplers as needed.

builderGLBBuilder

The GLBBuilder instance managing the binary buffer.

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

Cache mapping (file_path, wrap_s, wrap_t) to glTF texture indices.

image_cachedict[str, int]

Cache mapping file paths to glTF image indices.

sampler_cachedict[tuple[int, int], int]

Cache mapping (wrap_s, wrap_t) to glTF sampler indices.

Returns:
int | None

The index of the resolved GLTF material, or None if no material is found.