This commit enhances the WebAssembly bindings with two major improvements:
1. **Zero-Copy Asset Loading** (`setAssetFromRawPointer`):
- Direct Uint8Array access using raw pointers
- Eliminates intermediate copying during JS↔C++ transfer
- 67% reduction in memory copies (from 3 to 1)
- Optimal performance for large binary assets (textures, meshes, USD files)
2. **Memory View Access** (`getAssetCacheDataAsMemoryView`):
- Direct typed memory view of cached asset data
- Returns Uint8Array for existing assets, undefined otherwise
- Consistent with existing getAsset method
**Technical Details:**
- Added AssetCacheEntry struct with SHA-256 hash validation
- Implemented raw pointer method with emscripten::allow_raw_pointers()
- Enhanced error handling and data integrity checks
- Backward compatible with existing setAsset/getAsset methods
**JavaScript Usage:**
```javascript
// Zero-copy loading
const dataPtr = Module.HEAPU8.subarray(uint8Array.byteOffset,
uint8Array.byteOffset + uint8Array.byteLength).byteOffset;
loader.setAssetFromRawPointer('texture.jpg', dataPtr, uint8Array.length);
// Direct memory view
const memView = loader.getAssetCacheDataAsMemoryView('texture.jpg');
```
**Testing:**
- Comprehensive Node.js test suite with mock implementations
- Performance benchmarking utilities
- Data integrity validation
- Zero-copy helper functions for real-world usage
Ideal for USD workflows with large textures, geometry data, and binary scene files.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>