Skip to content

Commit 27f2f4e

Browse files
committed
USDComposer: Added primvars:displayOpacity support.
1 parent 30776bb commit 27f2f4e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

examples/jsm/loaders/usd/USDComposer.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,35 @@ class USDComposer {
856856

857857
}
858858

859+
// Apply displayOpacity for transparency
860+
const displayOpacity = attrs[ 'primvars:displayOpacity' ];
861+
if ( displayOpacity && displayOpacity.length >= 1 ) {
862+
863+
const opacity = displayOpacity[ 0 ];
864+
865+
const applyDisplayOpacity = ( mat ) => {
866+
867+
if ( opacity < 1 ) {
868+
869+
mat.opacity = opacity;
870+
mat.transparent = true;
871+
872+
}
873+
874+
};
875+
876+
if ( Array.isArray( material ) ) {
877+
878+
material.forEach( applyDisplayOpacity );
879+
880+
} else {
881+
882+
applyDisplayOpacity( material );
883+
884+
}
885+
886+
}
887+
859888
let mesh;
860889

861890
if ( hasSkinning ) {

0 commit comments

Comments
 (0)