Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build script #22

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 14 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A USD viewer on the web.
[Open USD Viewer](https://usd-viewer.glitch.me/)

There are two main parts:
- [USD WASM bindings by Autodesk](https://autodesk-forks.github.io/USD/usd_for_web_demos/)
- [USD WASM bindings by Autodesk](https://github.com/needle-tools/OpenUSD/tree/needle/feature/wasm-improvements)
- A [Three.js](https://threejs.org/) Hydra Delegate for rendering, originally by Autodesk and improved by hybridherbst

## Info and Known Issues
Expand All @@ -19,11 +19,10 @@ There are two main parts:

### Limitations

- Skinned meshes aren't supported.
- Vertex colors aren't supported.
- Point instancing isn't supported.
- MaterialX isn't supported.
- LightsAPI isn't supported.
- LightsAPI isn't supported.
- Texture paths currently can't be resolved correctly for nested USDZ files. One level is fine.
- Fixing this would require adjustments to the WASM bindings.

Expand Down Expand Up @@ -87,37 +86,14 @@ NOTE: Origins for these instructions can be found [here](https://github.com/auto
4. Run `wasm-opt -Oz -o "../build_dir/bin/emHdBindings.wasm" "../build_dir/bin/emHdBindings.wasm" --enable-bulk-memory --enable-threads` to shrink the wasm file more.
5. Patch emHdBindings.js to enable the following support, unable to currently do these things as part of the normal build process
1. Support for arguments
- `patch emHdBindings.js < patches/arguments_1.patch`
- `patch emHdBindings.js < patches/arguments_2.patch`
- THIS PATCH DOES NOT WORK
- Copy the following lines:
```
return function (
moduleArg = {
// module overrides can be supplied here
locateFile: (path, prefix) => {
if (!prefix)
prefix = _scriptDir.substr(0, _scriptDir.lastIndexOf("/") + 1);
return prefix + path;
},
...args,
},
) {
```
And replace this line:
- `return function (moduleArg = {}) {`
- `patch emHdBindings.js < arguments_1.patch`
- `patch emHdBindings.js -R < arguments_2.patch`
2. Disable ABORT so that one bad file doesn't corrupt the entire session
- `patch emHdBindings.js < patches/abort.patch`
- `patch emHdBindings.js < abort.patch`
3. Add file system functions to the module
- `patch emHdBindings.js < patches/fileSystem.patch`
- THIS PATCH DOES NOT WORK
- Add these lines
```
Module["FS_readdir"] = FS.readdir;
Module["FS_analyzePath"] = FS.analyzePath;
```
right after
- `Module["PThread"] = PThread;`
- `patch emHdBindings.js -R < fileSystem.patch`
4. Include global export
- `echo -e '\nglobalThis["NEEDLE:USD:GET"] = getUsdModule;' >> "emHdBindings.js"`

##### Debug
1. Install [ C/C++ DevTools Support (DWARF)](https://chromewebstore.google.com/detail/cc++-devtools-support-dwa/pdcpmagijalfljmkmjngeonclgbbannb)
Expand All @@ -135,50 +111,23 @@ NOTE: Origins for these instructions can be found [here](https://github.com/auto
6. Patch emHdBindings.js to enable the following support, unable to currently do these things as part of the normal build process
1. Support for arguments
- `patch emHdBindings.js < arguments_1.patch`
- `patch emHdBindings.js < arguments_2.patch`
- THIS PATCH DOES NOT WORK
- Copy the following lines:
```
return function (
moduleArg = {
// module overrides can be supplied here
locateFile: (path, prefix) => {
if (!prefix)
prefix = _scriptDir.substr(0, _scriptDir.lastIndexOf("/") + 1);
return prefix + path;
},
...args,
},
) {
```
And replace this line:
- `return function (moduleArg = {}) {`
- `patch emHdBindings.js -R < arguments_2.patch`
2. Disable ABORT so that one bad file doesn't corrupt the entire session
- `patch emHdBindings.js < abort.patch`
3. Add file system functions to the module
- `patch emHdBindings.js < fileSystem.patch`
- THIS PATCH DOES NOT WORK
- Add these lines
```
Module["FS_readdir"] = FS.readdir;
Module["FS_analyzePath"] = FS.analyzePath;
```
right after
- `Module["PThread"] = PThread;`
- `patch emHdBindings.js -R < fileSystem.patch`
4. Include global export
- `echo -e '\nglobalThis["NEEDLE:USD:GET"] = getUsdModule;' >> "emHdBindings.js"`
7. Run `npm start`
8. Go to http://localhost:3003 (or wherever the app is running)
9. Open up Chrome Dev Tools
10. Go to Sources -> (vertical ellipsis) -> Group by Authored/Deployed
11. Under Authored, you can go through to the pxr files to set breakpoints in the c++ code.

##### Build Script
There is a build script [here](https://github.com/needle-tools/OpenUSD/blob/needle/feature/wasm-improvements/buildAndMove.sh) which tries to make building easier. Set the mode, build directory and destination directory to deal with the file movement.

Usage: `./buildAndMove.sh --mode release --build-dir ../build-wasm --destination-dir /Users/andrewbeers/git/needle/usd-viewer/public`

NOTE: this does not support patching yet as patching doesn't completely work yet
NOTE: this does not update CMakeLists.txt for debug mode automatically
There is a build script [here](https://github.com/needle-tools/OpenUSD/blob/needle/feature/wasm-improvements/buildAndMove.sh) which tries to make building easier. Set the mode, build directory and destination directory to deal with the file movement. This does not update CMakeLists.txt for debug mode automatically. Follow step 2 above to configure this.

Usage: `./buildAndMove.sh --mode release --build-dir ../build-wasm --destination-dir /Users/andrewbeers/git/needle/usd-viewer/usd-wasm/src/bindings --patch-dir /Users/andrewbeers/git/needle/OpenUSD/pxr/usdImaging/hdEmscripten/patches`

## Origin

Expand Down
Loading