86 Commits

Author SHA1 Message Date
Syoyo Fujita
4e37545c9b add test scene with envmap(DomeLight) 2025-12-17 02:16:46 +09:00
Syoyo Fujita
9b02a97a5b Merge branch 'mtlx-2025' into usdlux-2025 2025-11-18 22:02:52 +09:00
Syoyo Fujita
db55d902b5 Fix data corruption issue by reverting TypedArray to std::vector
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>
2025-11-12 10:26:06 +09:00
Syoyo Fujita
ba612f0389 Merge branch 'mtlx-2025' into usdlux-2025 2025-11-10 03:30:03 +09:00
Syoyo Fujita
dd522def5b initial working MaterialX + USD demo. 2025-11-06 10:00:19 +09:00
Syoyo Fujita
99e05822cc Merge branch 'release' into mtlx-2025 with compilation fixes
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>
2025-11-04 21:55:27 +09:00
Syoyo Fujita
a58c48e105 add test models for SkinAnimation.
improve a bit for skinning-anim.js demo.
2025-11-04 08:57:12 +09:00
Syoyo Fujita
a54f18475c Add multiple UV set support and MaterialX example library
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>
2025-11-02 07:22:45 +09:00
Syoyo Fujita
a4f42e29fc Fix PropertyBinding UUID syntax for Three.js AnimationMixer
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>
2025-10-30 08:20:06 +09:00
Syoyo Fujita
af2115490e Fix segfault in TimeSamples::get when accessing empty _samples vector
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>
2025-10-28 10:12:09 +09:00
Syoyo Fujita
53a21e0331 Add matrix decomposition support for Transform xformOp animations
Implement TRS decomposition to enable animated matrix transforms in Tydra
render-scene conversion. Transform xformOps with time samples are now
decomposed into separate Translation/Rotation/Scale animation channels
compatible with glTF and Three.js.

Changes:
- Add decompose() function to xform.cc using Shepperd's method for stable
  quaternion extraction from rotation matrices
- Extend ExtractXformOpAnimation() to handle Transform xformOps by
  decomposing each matrix time sample into TRS components
- Fix TimeSamples API usage: change ts.get_as<T>() to sample_value.as<T>()
  for correct access pattern with FOREACH_TIMESAMPLES_BEGIN macro
- Fix atomic library linking in CMakeLists.txt for Emscripten builds
- Fix AnimationChannel validation method call (valid -> is_valid)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-27 23:34:51 +09:00
Syoyo Fujita
d926905030 add xformop example model. 2025-10-21 12:35:16 +09:00
Syoyo Fujita
db3e703a9f fix type is not printed.
fix array print is shorten up to 10 items.
2025-10-21 07:36:20 +09:00
dependabot[bot]
ee48d5ca76 Bump vite from 6.3.5 to 6.3.6 in /web/demo
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.3.5 to 6.3.6.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.3.6/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.3.6/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 6.3.6
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-10 02:00:41 +00:00
Syoyo Fujita
ee730671cb update to use memory64 version. 2025-08-26 13:13:38 +09:00
Syoyo Fujita
396cfd7c87 support wasm64. 2025-08-26 12:52:01 +09:00
Syoyo Fujita
44314c7cd6 Add memory limit support for web binding with architecture-specific defaults
- Add USDLoadOptions with memory limits to web binding C++ code
- Implement architecture-specific defaults: 2GB for WASM32, 8GB for WASM64
- Add TINYUSDZ_WASM_MEMORY64 preprocessor define for WASM64 builds
- Update JavaScript wrapper with memory limit configuration API
- Add getNativeDefaultMemoryLimitMB() method to query architecture defaults
- Support per-operation memory limit overrides in load/parse methods
- Update documentation and examples for both build architectures
- Add build examples script for WASM32/WASM64 configurations

Security enhancement to prevent memory exhaustion attacks when loading
potentially malicious USD files in web environments.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-22 02:36:44 +09:00
Syoyo Fujita
3134a0ef00 add group selection feature. 2025-08-09 12:10:42 +09:00
Syoyo Fujita
76fedba291 initial support of Transform Gizmo 2025-08-07 09:22:59 +09:00
Syoyo Fujita
a0ad418d8c fix build
bump npm version.
2025-08-06 11:31:14 +09:00
Syoyo Fujita
5225d31ad5 cosmetics 2025-08-06 11:06:03 +09:00
Syoyo Fujita
79b5fb745a transform guizmo w.i.p 2025-08-06 10:41:35 +09:00
Syoyo Fujita
3150697508 Support instancing in MCP select_assets and read_asset 2025-08-05 10:26:40 +09:00
Syoyo Fujita
795677d0b1 improve MCP protocol. 2025-08-04 15:57:16 +09:00
Syoyo Fujita
d8c306d950 mcp minimal working demos. 2025-07-29 11:52:06 +09:00
Syoyo Fujita
38c9ec4c08 mcp demo.
disable alpha map for a while.
2025-07-29 11:19:28 +09:00
Syoyo Fujita
1b03cf0dc0 Improve MCP tools. 2025-07-28 14:55:03 +09:00
Syoyo Fujita
16fa5f101f [mcp] add screenshot read/write
[mcp] initial Browser MCP client sample.
2025-07-26 11:25:57 +09:00
Syoyo Fujita
a01d175568 Add screenshot save/read tool. 2025-07-25 12:03:48 +09:00
Syoyo Fujita
7cd0016526 optimzie base64
mcp w.i.p.
2025-07-25 05:11:04 +09:00
Syoyo Fujita
884e281f63 dev -> release 2025-06-28 07:56:22 +09:00
Syoyo Fujita
2f8fd55141 update README. 2025-06-28 06:23:43 +09:00
Syoyo Fujita
75bb6eb0b1 bump tinyusdz version. 2025-06-28 06:00:02 +09:00
Syoyo Fujita
d40dfe062c use 0.9.0 2025-06-27 11:19:11 +09:00
Syoyo Fujita
190aaa3188 add a card to source code. 2025-06-27 10:42:30 +09:00
Syoyo Fujita
ecc32ad70b enable zstd compressed wasm for USD-composition example. 2025-06-27 10:23:58 +09:00
Syoyo Fujita
55bb674986 use zstd compressed by default for usda-load demo. 2025-06-27 10:19:41 +09:00
Syoyo Fujita
0768deb2a0 compress files.
use zstd compressed wasm by default for main.js
2025-06-27 10:06:00 +09:00
Syoyo Fujita
4faca41c4b remove console.log 2025-06-26 12:06:08 +09:00
Syoyo Fujita
5dc2f25917 fix asset path 2025-06-26 11:35:19 +09:00
Syoyo Fujita
f121e1629c fix asset path.
move .css to public/
2025-06-26 10:56:13 +09:00
Syoyo Fujita
2ef72eb16a Fix version specify to tinyusdz package. 2025-06-26 10:17:35 +09:00
Syoyo Fujita
8d052241a0 Support envMapIntensity change during the rendering. 2025-06-26 10:02:20 +09:00
Syoyo Fujita
6a7884f5b6 minor update to html&package.json 2025-06-26 09:40:55 +09:00
Syoyo Fujita
b432cefd0b bump tinyusdz npm version
Use URL for texture file.
2025-06-26 09:21:18 +09:00
Syoyo Fujita
967a19daf6 add doubleSided support.
some code cleanups.
Change file layout for web demos.
Add demo list web page.
2025-06-26 08:47:45 +09:00
Syoyo Fujita
a62ee0704e update threejs to 0.177 2025-06-25 23:29:46 +09:00
Syoyo Fujita
a624a50388 change file layout. 2025-06-24 06:32:24 +09:00
Syoyo Fujita
238d6438ea Move web demo asset files to assets folder.
Add assetSearchPath and baseWorkingDir(w.i.p)
improve vite config.
2025-06-21 09:10:32 +09:00
Syoyo Fujita
d7043d8ce3 add note on vite + tinyusdz npm package. 2025-06-18 08:55:47 +09:00