Goal
Itemize list of low-hanging fruits, tasks and operations to lower the cost of maintaining the USD WebAssembly prototype, and to eventually merge back components into the main USD branch.
Intent:
- Prevent WebAssembly prototype from lagging too far behind most recent USD version
- Automate builds, publishing to NPM, Wasmer or other repositories to facilitate integrations and adoption by other parties.
- Facilitate contributions and collaboration with other parties not necessarily intricately familiar with USD (web community, ThreeJS, etc.)
Itemized list
Items in this list are ordered by ascending order of priority for the WebAssembly project (i.e. from "mandatory" to "optional").
Prerequisite work
Target a recent, stable version of the USD main branch. At the time of writing, USD 22.11
is the latest known public stable version.
High-level prioritized item list
0. Legal requirements
Clarify ASWF vs. USD contribution guidelines regarding attributions.
1. Build system changes
- Add
Dockerfile
to standardize Emscripten build (using an Ubunutu 22.04 LTS base image)- Using known good Emscripten version (
2.0.24
)
- Using known good Emscripten version (
- Update
build_usd.py
build script to support:- Adding an
--emscripten
build option to specify a WebAssembly target - Using
emcmake
/emmake
as a drop-in replacement forcmake
when targeting WebAssembly build - Replacing TBB with WasmTBB
- Listing USD components incompatible with WebAssembly build to warn Users that
Python
,usdview
,imaging
have been disabled
- Adding an
- Add
CMakeLists.txt
for JavaScript/WebAssembly bindings in order to:- List USD binding dependencies (
usd
,usdLux
,usdGeom
,usdUtils
,sdf
,tf
) - Specify location of WebAssembly build artifacts (WASM bundle, WebWorker, JavaScript bindings)
- List USD binding dependencies (
- Include tests to validate WebAssembly build, using a NodeJS dependency in order to enable tests from headless environments. Test examples include (but are not limited to):
- Loading a USDA stage
- Exporting USDA stage to string
- Traversing the USDA stage
- Running WebWorkers
- etc.
2. Core USD changes
arch
library
- Add
#if defined(__EMSCRIPTEN__)
guards to integrate Emscripten as an alternative to Linux platform:ArchDebuggerTrap()
,ArchAbort()
,ARCH_BITS_32
ArchStatIsWritable()
,ArchGetModificationTime()
,ArchGetAccessTime()
,ArchGetStatusChangeTime()
,ArchGetFileLength()
ArchLibraryOpen()
,ArchLibraryError()
,ArchLibraryClose()
,ArchLibraryGetSymbolAddress()
ArchGetStartTickTime()
,ArchGetStopTickTime()
tf
library
- Add type registration for USD symbols to be exposed to/from C++/JavaScript
- Used to wrap
TfToken
,double
,int
, etc.
- Used to wrap
- Add
TfPointerAndBits
to specify operations on 32-bit architectures (as USD only specifies 64-bit operations by default)
vt
library
- Add type registration for USD symbols to be exposed to/from C++/JavaScript
- Add
getJsObj
toVtValue
(similar to the existinggetPyObj
for Python)
- Add
sdf
library
- Add type registration for USD symbols to be exposed to/from C++/JavaScript
- Used to wrap
SdfPath
objects
- Used to wrap
usd
library
- Add type registration for USD symbols to be exposed to/from C++/JavaScript
- Used to wrap
UsdPrim,
UsdStage
objects to exposeCreateNew()
,ExportToString()
and other API bindings.
- Used to wrap
3. ThreeJS Hydra renderer
TBD: Separate project/branch? Engage with ThreeJS/web community for collaboration opportunity on this aspect?