Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for USDC (binary crate format) files to the USDLoader, significantly expanding the loader's capability to handle USD files beyond the existing ASCII (USDA) format support.
Changes:
- Implements a comprehensive USDC parser with LZ4 decompression and integer compression decoding
- Adds support for geometry, materials (UsdPreviewSurface), multi-material meshes via GeomSubsets, and PBR textures
- Updates USDLoader to detect and route USDC files to the new parser
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| examples/jsm/loaders/usd/USDCParser.js | New 2656-line parser implementing complete USDC binary format support including LZ4 decompression, integer compression, binary data reading, and Three.js scene building |
| examples/jsm/loaders/USDLoader.js | Updated to detect USDC files via magic header check and route them to the new USDC parser |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const file = findUSD( zip ); | ||
|
|
||
| // Check if the main file is USDC (binary) or USDA (ASCII) | ||
| if ( isCrateFile( file ) ) { | ||
|
|
||
| return usdc.parse( file.buffer, assets ); | ||
|
|
||
| } | ||
|
|
||
| const text = fflate.strFromU8( file ); | ||
|
|
||
| return usda.parse( text, assets ); |
There was a problem hiding this comment.
The findUSD function can return undefined if no matching file is found (e.g., when zip has no .usda/.usdc/.usd file, or when the first file doesn't match any conditions). This would cause errors at line 213 when isCrateFile tries to access file.buffer or at line 219 when fflate.strFromU8 tries to process an undefined file. Consider adding validation to check if file is undefined and throw a descriptive error.
|
|
||
| get payload() { | ||
|
|
||
| // 48-bit payload: lo (32 bits) + hi lower 16 bits |
There was a problem hiding this comment.
The payload calculation uses JavaScript number arithmetic for a 48-bit value. While this should be safe for most USD files, values larger than Number.MAX_SAFE_INTEGER (2^53 - 1) could lose precision. However, for typical file offsets this should be acceptable. Consider adding a comment explaining the limitation if file offsets ever exceed this range.
| // 48-bit payload: lo (32 bits) + hi lower 16 bits | |
| // 48-bit payload: lo (32 bits) + hi lower 16 bits. | |
| // This is safe with JavaScript Number arithmetic because 48 bits < 53 bits | |
| // of mantissa precision (Number.MAX_SAFE_INTEGER). If the payload width or | |
| // file offsets are ever extended beyond this range, this calculation will | |
| // lose precision and should be reimplemented (e.g., using BigInt). |
|
We got animations working ✌️ Screen.Recording.2026-01-11.at.19.40.28.mov |
|
The drummer asset is cute 😊 . |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 2 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Merging this for now. |
Related issue: #24574
Description
Implements a USDC (crate format) parser supporting:
Not yet supported: cameras, lights, variants, references.
(Made with Claude Opus 4.5)