forked from PixarAnimationStudios/OpenUSD
-
Notifications
You must be signed in to change notification settings - Fork 26
HdJavaScript and JavaScript API wrappers #2
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
Draft
kaischroeder
wants to merge
15
commits into
usdjs
Choose a base branch
from
hdJavaScript
base: usdjs
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
97140a5
Fixes
kaischroeder 60e4964
Add hdEmscripten and more JavaScript bindings
kaischroeder 9e33f25
Temp
kaischroeder b370d04
Use EMSCRIPTEN as long as PXR_ENABLE_JS_SUPPORT is not defined
kaischroeder e5dea62
initial js render delegate improvements
frericp d6ed694
Merge pull request #2 from frericp/js_renderdelegate
kaischroeder 4db0b9a
Fixes for standard build
kaischroeder 4d45abb
Increase maximum heap memory to 4GB
kaischroeder aa38395
Improve primvar handling to fix displayColor and uv assignments
frericp 2cf6471
Remove debug message
frericp de19d0d
Merge render delegate fixes
kaischroeder 34250f5
Shadow casting / exception catching
kaischroeder b06a194
cleanup and minor fixes
frericp 6d10683
Merge pull request #3 from frericp/hdEmscripten_cleanup
kaischroeder 9a940c3
Fix TBB_EMSCRIPTEN_URL
kaischroeder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,6 @@ | |
| .DS_Store | ||
| .AppleDouble | ||
| USD_emscripten/ | ||
| build | ||
| .vscode/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -868,7 +868,7 @@ def InstallBoost(context, force, buildArgs): | |
| TBB_URL = "https://github.com/oneapi-src/oneTBB/archive/2018_U6.tar.gz" | ||
|
|
||
| # Note: this refers to a fork of tbb for wasm. Is this maintained? | ||
| TBB_EMSCRIPTEN_URL = "https://github.com/hpcwasm/wasmtbb/archive/master.zip" | ||
| TBB_EMSCRIPTEN_URL = "https://github.com/sdunkel/wasmtbb/archive/master.zip" | ||
|
|
||
| def InstallTBB(context, force, buildArgs): | ||
| if context.emscripten: | ||
|
|
@@ -1399,6 +1399,15 @@ def InstallMaterialX(context, force, buildArgs): | |
|
|
||
| MATERIALX = Dependency("MaterialX", InstallMaterialX, "include/MaterialXCore/Library.h") | ||
|
|
||
| ############################################################ | ||
| # Three.js | ||
| THREE_URL = "https://unpkg.com/[email protected]/build/three.js" | ||
|
|
||
| def InstallThreeJs(context, force, buildArgs): | ||
| DownloadURL(THREE_URL, context, force) | ||
|
|
||
| THREE = Dependency("ThreeJs", InstallThreeJs, "src/three.js") | ||
|
|
||
| ############################################################ | ||
| # Embree | ||
| # For MacOS we use version 3.7.0 to include a fix from Intel | ||
|
|
@@ -1610,9 +1619,16 @@ def InstallUSD(context, force, buildArgs): | |
| extraArgs.append('-DOPENSUBDIV_INCLUDE_DIR=' + os.path.join(context.usdInstDir, 'include')) | ||
| extraArgs.append('-DOPENSUBDIV_OSDCPU_LIBRARY=' + os.path.join(context.usdInstDir, 'lib/libosdCPU.a')) | ||
|
|
||
| extraArgs.append('-DTHREE_JS_FILE=' + os.path.join(context.usdInstDir, 'src/three.js')) | ||
|
|
||
| extraArgs.append('-DPXR_ENABLE_GL_SUPPORT=OFF') | ||
| extraArgs.append('-DBUILD_SHARED_LIBS=OFF') | ||
|
|
||
| if context.emscripten == 'EMSCRIPTEN_NODE': | ||
| extraArgs.append('-DPXR_EMSCRIPTEN_NODE=1') | ||
| else: | ||
| extraArgs.append('-DPXR_EMSCRIPTEN_NODE=0') | ||
|
|
||
| RunCMake(context, force, extraArgs) | ||
|
|
||
| USD = Dependency("USD", InstallUSD, "include/pxr/pxr.h") | ||
|
|
@@ -1739,7 +1755,8 @@ def InstallUSD(context, force, buildArgs): | |
| subgroup = group.add_mutually_exclusive_group() | ||
| subgroup.add_argument("--emscripten", dest="emscripten", action="store_const", const='EMSCRIPTEN', | ||
| help="Build for emscripten") | ||
|
|
||
| subgroup.add_argument("--emscriptenNode", dest="emscripten", action="store_const", const='EMSCRIPTEN_NODE', | ||
| help="Build emscripten for NodeJS (embed data into JS)") | ||
| if Linux(): | ||
| group.add_argument("--use-cxx11-abi", type=int, choices=[0, 1], | ||
| help=("Use C++11 ABI for libstdc++. (see docs above)")) | ||
|
|
@@ -2078,13 +2095,13 @@ def ForceBuildDependency(self, dep): | |
| context.buildPython = False | ||
| disabled.append('Python') | ||
|
|
||
| if context.buildImaging: | ||
| context.buildImaging = NO_IMAGING | ||
| disabled.append('imaging') | ||
| # if context.buildImaging: | ||
| # context.buildImaging = NO_IMAGING | ||
| # disabled.append('imaging') | ||
|
|
||
| if context.buildUsdImaging: | ||
| context.buildUsdImaging = NO_IMAGING | ||
| disabled.append('usdImaging') | ||
| # if context.buildUsdImaging: | ||
| # context.buildUsdImaging = NO_IMAGING | ||
| # disabled.append('usdImaging') | ||
|
|
||
| if context.buildExamples: | ||
| context.buildExamples = False | ||
|
|
@@ -2111,6 +2128,9 @@ def ForceBuildDependency(self, dep): | |
| if not context.emscripten: | ||
| requiredDependencies += [ZLIB] | ||
|
|
||
| if context.emscripten and context.buildTests: | ||
| requiredDependencies += [THREE] | ||
|
|
||
| if context.buildAlembic: | ||
| if context.enableHDF5: | ||
| requiredDependencies += [HDF5] | ||
|
|
@@ -2267,6 +2287,7 @@ def _JoinVersion(v): | |
| CMake generator {cmakeGenerator} | ||
| CMake toolset {cmakeToolset} | ||
| Emscripten {emscripten} | ||
| Node {emscriptenNode} | ||
| Downloader {downloader} | ||
|
|
||
| Building {buildType} | ||
|
|
@@ -2327,6 +2348,7 @@ def FormatBuildArguments(buildArgs): | |
| cmakeToolset=("Default" if not context.cmakeToolset | ||
| else context.cmakeToolset), | ||
| emscripten=("Enabled" if context.emscripten else "Disabled"), | ||
| emscriptenNode=("Enabled" if context.emscripten == 'EMSCRIPTEN_NODE' else "Disabled"), | ||
| downloader=(context.downloaderName), | ||
| dependencies=("None" if not dependenciesToBuild else | ||
| ", ".join([d.name for d in dependenciesToBuild])), | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Locate OpenGL | ||
| # This module defines: | ||
| # OPENGL_FOUND - system has OpenGL | ||
| # OPENGL_XMESA_FOUND - system has XMESA | ||
| # OPENGL_GLU_FOUND - system has GLU | ||
| # OPENGL_INCLUDE_DIR - the GL include directory | ||
| # OPENGL_LIBRARIES - Link these to use OpenGL and GLU | ||
| # OPENGL_gl_LIBRARY - Path to OpenGL Library | ||
| # OPENGL_glu_LIBRARY - Path to GLU Library | ||
|
|
||
| # The implementation is based on the standard FindOpenGL.cmake provided with CMake, | ||
| # but customized for targeting Emscripten only. | ||
|
|
||
| # These libraries are provided with Emscripten | ||
| SET(OPENGL_FOUND TRUE) | ||
| SET(OPENGL_GLU_FOUND TRUE) | ||
|
|
||
| # Doesn't look like this one is part of Emscripten | ||
| SET(OPENGL_XMESA_FOUND FALSE) | ||
|
|
||
| # This is the path where <GL/gl.h> is found | ||
| SET(OPENGL_INCLUDE_DIR "${EMSCRIPTEN_ROOT_PATH}/system/include") | ||
|
|
||
| # No library to link against for OpenGL, since Emscripten picks it up automatically from library_gl.js, | ||
| # but need to report something, or CMake thinks we failed in the search. | ||
| SET(OPENGL_LIBRARIES "") | ||
| SET(OPENGL_gl_LIBRARY "") | ||
| SET(OPENGL_glu_LIBRARY "") | ||
|
|
||
| message('EMSCRIPTEN OpenGl') | ||
|
|
||
| mark_as_advanced( | ||
| OPENGL_INCLUDE_DIR | ||
| OPENGL_glu_LIBRARY | ||
| OPENGL_gl_LIBRARY | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
|
|
||
| set(BINDINGS_NAME "jsBindings") | ||
|
|
||
| function(cat IN_FILE OUT_FILE) | ||
| file(READ ${IN_FILE} CONTENTS) | ||
| file(APPEND ${OUT_FILE} "${CONTENTS}") | ||
| endfunction() | ||
|
|
||
| message(STATUS "SOURCE_DIR: ${SOURCE_DIR}") | ||
|
|
||
| set(ES6_MODULE_FILES | ||
| ${CMAKE_BINARY_DIR}/extras/usd/js_bindings/${BINDINGS_NAME}.js | ||
| ${SOURCE_DIR}/js/usd-module-appendix.js | ||
| ) | ||
| file(WRITE ${CMAKE_BINARY_DIR}/extras/usd/js_bindings/usd.js "") | ||
|
|
||
| foreach(ES6_MODULE_FILE ${ES6_MODULE_FILES}) | ||
| cat(${ES6_MODULE_FILE} ${CMAKE_BINARY_DIR}/extras/usd/js_bindings/usd.js) | ||
| endforeach() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| const Module = require("../bindings/Release/jsBindings"); | ||
|
|
||
| let stage; | ||
| let Usd; | ||
|
|
||
| describe('UsdGeomXform', () => { | ||
| beforeEach(async () => { | ||
| Usd = await Module(); | ||
| const fileName = "HelloWorld.usda"; | ||
| stage = Usd.UsdStage.CreateNew(fileName); | ||
| }, 500000); | ||
|
|
||
| afterEach(() => { | ||
| Usd.PThread.runningWorkers.forEach(x => x.onmessage = function() {}); | ||
| Usd.PThread.terminateAllThreads(); | ||
| Usd = null; | ||
| stage = null; | ||
| process.removeAllListeners('unhandledRejection') | ||
| process.removeAllListeners('uncaughtException') | ||
| }); | ||
|
|
||
| it("Define constructor should modify the stage", () => { | ||
| Usd.UsdGeomXform.Define(stage, "/test") | ||
| let data = stage.ExportToString(); | ||
| expect(data).toContain("Xform"); | ||
| expect(data).toContain("test") | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| const Module = require("../bindings/Release/jsBindings"); | ||
|
|
||
| let stage; | ||
| let xform; | ||
| let Usd; | ||
|
|
||
| describe('UsdGeomXformable', () => { | ||
| beforeEach(async () => { | ||
| Usd = await Module(); | ||
| const fileName = "HelloWorld.usda"; | ||
| stage = Usd.UsdStage.CreateNew(fileName); | ||
| xform = Usd.UsdGeomXform.Define(stage, "/test"); | ||
| }, 500000); | ||
|
|
||
| afterEach(() => { | ||
| Usd.PThread.runningWorkers.forEach(x => x.onmessage = function() {}); | ||
| Usd.PThread.terminateAllThreads(); | ||
| Usd = null; | ||
| stage = null; | ||
| xform = null; | ||
| process.removeAllListeners('unhandledRejection') | ||
| process.removeAllListeners('uncaughtException') | ||
| }); | ||
|
|
||
| it("AddScaleOp constructor should modify the stage", () => { | ||
| const scaleOp = xform.AddScaleOp(); | ||
| scaleOp.Set([1, 2, 3]); | ||
| let data = stage.ExportToString(); | ||
| expect(data).toContain("xformOp:scale"); | ||
| expect(data).toContain("(1, 2, 3)"); | ||
| }); | ||
|
|
||
| it("AddTranslateOp constructor should modify the stage", () => { | ||
| const scaleOp = xform.AddTranslateOp(); | ||
| scaleOp.Set([1, 2, 3]); | ||
| let data = stage.ExportToString(); | ||
| expect(data).toContain("xformOp:translate"); | ||
| expect(data).toContain("(1, 2, 3)"); | ||
| }); | ||
|
|
||
| it("SetXformOpOrder should modify the stage", () => { | ||
| xform.SetXformOpOrder([]); | ||
| let data = stage.ExportToString(); | ||
| expect(data).toContain("uniform token[] xformOpOrder = []"); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.