Skip to content

Commit 96432fc

Browse files
committed
USDComposer: Support variant overrides on ancestor prims.
1 parent 4fbef51 commit 96432fc

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

examples/jsm/loaders/usd/USDComposer.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ class USDComposer {
769769

770770
this._collectAttributesFromPath( path, attrs );
771771

772-
// Collect overrides from sibling variants
772+
// Collect overrides from sibling variants (when path is inside a variant)
773773
const variantMatch = path.match( /^(.+?)\/\{(\w+)=(\w+)\}\/(.+)$/ );
774774
if ( variantMatch ) {
775775

@@ -786,6 +786,25 @@ class USDComposer {
786786

787787
}
788788

789+
} else {
790+
791+
// Check for variant overrides at ancestor levels
792+
const parts = path.split( '/' );
793+
for ( let i = 1; i < parts.length - 1; i ++ ) {
794+
795+
const ancestorPath = parts.slice( 0, i + 1 ).join( '/' );
796+
const relativePath = parts.slice( i + 1 ).join( '/' );
797+
const variantPaths = this._getVariantPaths( ancestorPath );
798+
799+
for ( const vp of variantPaths ) {
800+
801+
const overridePath = vp + '/' + relativePath;
802+
this._collectAttributesFromPath( overridePath, attrs );
803+
804+
}
805+
806+
}
807+
789808
}
790809

791810
return attrs;

0 commit comments

Comments
 (0)