Revert TypedArray usage back to std::vector in crate-reader.cc and
usdGeom.cc to fix memory corruption issues that caused crashes when
loading certain USDZ files. The TypedArray view mode with mmap was
causing uninitialized memory access.
Changes:
- Replace TypedArray with std::vector in usdGeom.cc flatten_with_indices
- Remove TypedArray usage for float2, double2, double3, half2, half4 in crate-reader.cc
- Add sanity check for array size to catch corrupted data
- Fix missing return statement in material-serializer.cc switch case
- Fix typo TUSD_LOG_I -> TUSDZ_LOG_I in crate-reader.cc
This fixes crashes when loading fancy-teapot-mtlx.usdz and similar files.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Resolved merge conflicts and fixed compilation errors introduced by animation system refactoring and API changes:
- Updated AnimationClip API usage in threejs-exporter (channels/samplers)
- Fixed PropertyMap const-correctness in MaterialX shader reconstructors
- Fixed 32-bit build warnings (sign conversion, variable shadowing)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit implements comprehensive multiple UV coordinate set support across
the entire TinyUSDZ MaterialX/OpenPBR stack, and adds a curated collection of
MaterialX example files with an automated texture download system.
## Part 1: Multiple UV Set Support
Enables different textures on the same material to use different UV mappings,
essential for complex materials (e.g., base color on UV0, detail maps on UV1).
### C++ Core (src/usdShade.hh)
- Add UVSetInfo struct for UV set metadata
- Enhance UsdUVTexture with uv_set (int) and uv_set_name (token)
- Default to UV set 0 for backward compatibility
### WASM Binding (web/binding.cc)
- Modified getMesh() to export ALL UV sets, not just UV0
- New JavaScript structure: uvSets: {uv0: {...}, uv1: {...}}
- Each UV set includes data, vertexCount, and slotId metadata
- Maintain backward compatibility with texcoords field
### Three.js Demo (web/js/materialx.js)
- Load all UV sets from WASM to Three.js geometry attributes
- Add UV set selector dropdown in texture panel (shown when multiple UV sets exist)
- Track selection in textureUVSet[materialIndex][mapName]
- Export UV set info in both JSON and MaterialX XML formats
- Zero UI overhead for single-UV-set meshes
### Documentation
- Update MATERIALX-SUPPORT-STATUS.md feature matrix
- Add UV_SET_SUPPORT.md with comprehensive examples and API docs
- Document all three layers: C++, WASM, and JavaScript
**Changes**: 4 files, 254 lines added
**Features**: Per-texture UV selection, automatic detection, export support
## Part 2: MaterialX Example Library
Add curated MaterialX examples from official repository with on-demand texture
downloads to keep git repository lean.
### MaterialX Files (web/demo/public/assets/mtlx/)
Downloaded from MaterialX GitHub repository:
- 11 Standard Surface materials (copper, gold, glass, brass, brick, etc.)
- 4 Custom OpenPBR materials (metal, glass, plastic)
- Ranges from simple (683 bytes) to complex (32 KB chess set)
- Total: 15 .mtlx files
### Texture Download System
- download_textures.sh: Automated bash script with 3 modes
* --minimal: 5 essential textures (~10 MB)
* (default): All ~54 textures (~50 MB)
* --clean: Remove downloaded textures
- Colored output with progress indicators
- Downloads from MaterialX GitHub on-demand
- .gitignore excludes images/ directory (saves 50 MB in repo)
### Documentation
- Comprehensive README.md with usage examples
- Texture coverage table and testing recommendations
- C++ and JavaScript code examples
- Source attributions and license info
**Benefits**:
- Lean repository (no binary images in git)
- Easy testing with real MaterialX files
- Flexible download options
- Well-documented with examples
**Files Added**: 18 files (15 .mtlx + script + docs + .gitignore)
**Repository Impact**: +68 KB text files, -50 MB by excluding images
## Testing
### UV Set Support
- ✅ C++ structures compile
- ✅ WASM binding exports uvSets correctly
- ✅ Three.js loads multiple UV sets
- ✅ UI dropdown works
- ✅ JSON/MaterialX export includes UV sets
- ✅ Backward compatibility maintained
### MaterialX Examples
- ✅ Script executable and tested
- ✅ Minimal download works (brass textures)
- ✅ .gitignore properly excludes images/
- ✅ All .mtlx files valid XML
## Summary
- Multiple UV set support: Complete stack implementation
- MaterialX library: 15 example files + download system
- Documentation: 2 new docs, 1 updated feature matrix
- Total changes: 22 files modified/added
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit fixes the PropertyBinding error that occurred when playing USD animations.
**Root Cause:**
- Three.js PropertyBinding expects UUID-based track names in the format `<uuid>.<property>`
- The code was incorrectly using `.uuid[<uuid>].<property>` format which PropertyBinding doesn't support
- PropertyBinding resolves nodes by checking `childNode.name === nodeName || childNode.uuid === nodeName`
**Changes Made:**
1. **Animation track UUID syntax** (track-based and channel-based):
- Changed from: `.uuid[${targetUUID}].position`
- Changed to: `${targetUUID}.position`
- Applied to position, quaternion, and scale tracks
2. **UUID validation and lookup logic**:
- Changed from regex matching `.uuid[...]`
- Changed to: `track.name.split('.')[0]` to extract UUID from first part
- Applied to track validation and object lookup code
3. **AnimationMixer attachment**:
- Added `usdContentNode` global variable to store actual USD root node
- Mixer now created on `usdContentNode` (threeNode) instead of `usdSceneRoot`
- Ensures mixer root matches the root used for animation extraction
4. **Additional improvements**:
- Enhanced shadow map quality (2048x2048 resolution)
- Shadow camera frustum scaling with scene scale to prevent artifacts
- Bounding box visualization feature for animated objects
- Improved animation track name matching (exact match then prefix match)
- Scene graph tree UI with per-object animation controls
**Result:**
- ✅ PropertyBinding successfully resolves all UUID-based animation tracks
- ✅ Timeline slider updates all animated objects correctly
- ✅ Per-object animation toggles work in Scene Graph UI
- ✅ Hierarchical node animations work properly
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Added bounds check before accessing _samples[0] to prevent crash when
using unified storage mode where _samples is empty but empty() returns false.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>