Skip to content

Commit

Permalink
Shadow casting / exception catching
Browse files Browse the repository at this point in the history
  • Loading branch information
kaischroeder committed Feb 2, 2022
1 parent de19d0d commit 34250f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ set(CMAKE_CXX_FLAGS "${_PXR_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")

if(PXR_ENABLE_JS_SUPPORT)
# Add EMSCRIPTEN specific compiler flags (is this the right place)?
set(EMSCRIPTEN_COMPILE_FLAGS "-s ALLOW_MEMORY_GROWTH=1 -s MAXIMUM_MEMORY=4GB -s ASSERTIONS=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=2 -s MODULARIZE=1 -s EXPORT_NAME='getUsdModule' -s 'EXTRA_EXPORTED_RUNTIME_METHODS=[\"FS\"]' -s FORCE_FILESYSTEM=1 -lidbfs.js")
set(EMSCRIPTEN_COMPILE_FLAGS "-s ALLOW_MEMORY_GROWTH=1 -s MAXIMUM_MEMORY=4GB -s ASSERTIONS=1 -s DISABLE_EXCEPTION_CATCHING=0 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=2 -s MODULARIZE=1 -s EXPORT_NAME='getUsdModule' -s 'EXTRA_EXPORTED_RUNTIME_METHODS=[\"FS\"]' -s FORCE_FILESYSTEM=1 --pre-js ${CMAKE_SOURCE_DIR}/js/prejs.js")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EMSCRIPTEN_COMPILE_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EMSCRIPTEN_COMPILE_FLAGS}")

Expand Down
12 changes: 9 additions & 3 deletions pxr/usdImaging/hdEmscripten/js/ThreeJsRenderDelegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ class HydraMesh {

const material = new THREE.MeshPhysicalMaterial( {
side: THREE.DoubleSide,
color: new THREE.Color(0x00ff00) // a green color to indicate a missing material
} );
color: new THREE.Color(0xa0a0a0) // a gray default color
});

this._mesh = new THREE.Mesh( this._geometry, material );
this._mesh.castShadow = true;
this._mesh.receiveShadow = true;

window.scene.add(this._mesh); // FIXME
}

Expand Down Expand Up @@ -254,7 +257,7 @@ class HydraMaterial {
if (!defaultMaterial) {
defaultMaterial = new THREE.MeshPhysicalMaterial({
side: THREE.DoubleSide,
color: new THREE.Color(0xff2997), // a bright pink color to indicate a missing material
color: new THREE.Color(0xa0a0a0), // a gray default color
envMap: window.envMap,
});
}
Expand Down Expand Up @@ -310,6 +313,9 @@ class HydraMaterial {
const clonedTexture = texture.clone();
clonedTexture.format = HydraMaterial.channelMap[channel];
clonedTexture.needsUpdate = true;
clonedTexture.wrapS = THREE.RepeatWrapping;
clonedTexture.wrapT = THREE.RepeatWrapping;

this._material[materialParameterMapName] = clonedTexture;

this._material.needsUpdate = true;
Expand Down

0 comments on commit 34250f5

Please sign in to comment.