USDComposer handles scene composition from parsed USD data. This includes reference resolution, variant selection, transform handling, and building the Three.js scene graph.
Works with specsByPath format from USDCParser.
Apply material binding from a prim path to a mesh. Used when merging referenced geometry into a prim that has material binding.
Shared helper for applying texture or value from shader attribute. Reduces duplication between _applyPreviewSurface and _applyOpenPBRSurface.
Build the scene hierarchy recursively. Uses childrenByPath index for O(1) child lookup instead of O(n) iteration.
Build indexes for efficient lookups. Called once during compose() to avoid O(n) scans per lookup.
Build a mesh from a Mesh spec.
Find a single mesh in the group's shallow hierarchy. Only returns a mesh if it's at depth 0 or 1, not deeply nested. This preserves transforms in complex hierarchies like Kitchen Set while supporting USDZExporter round-trip (Xform > Xform > Mesh pattern).
Get attributes for a path from attribute specs.
Get the base path (directory) from a file path.
Extract variant selections from a spec's fields.
Get material binding target path, checking variant paths if needed.
Get the material path for a mesh, checking various binding sources.
Get reference value from a prim spec.
Get variant paths for a parent path based on variant selections.
Check if an object has a non-identity local transform.
Check if a path is a direct child of parentPath.
Resolve a file path relative to basePath.
Resolve a USD reference and return the composed content.
refValue
Reference value like "@./path/to/file.usdc@"
localVariants
Variant selections to apply
Returns: Composed content or null
Apply USD transforms to a Three.js object. Handles xformOpOrder with proper matrix composition. USD uses row-vector convention, Three.js uses column-vector.
Compose a Three.js scene from parsed USD data.
parsedData
Data from USDCParser or USDAParser
assets
Dictionary of referenced assets (specsByPath or blob URLs)
variantSelections
External variant selections
basePath
Base path for resolving relative references
Returns: Three.js scene graph