Răsfoiți Sursa

USDAParser/USDComposer: Clean up.

Mr.doob 1 lună în urmă
părinte
comite
3cd3e5b87e

+ 10 - 10
examples/jsm/loaders/usd/USDAParser.js

@@ -203,23 +203,23 @@ class USDAParser {
 			// Skip nested defs (handled by walkTree)
 			if ( key.startsWith( 'def ' ) ) continue;
 
-			// Handle references/payloads
-			if ( key === 'prepend references' || key === 'payload' ) {
+			if ( key === 'prepend references' ) {
 
-				// Store as relationship
-				const relPath = path + '.' + key.replace( ' ', ':' );
-				specsByPath[ relPath ] = {
-					specType: SpecType.Relationship,
-					fields: { default: data[ key ] }
-				};
+				primFields.references = [ data[ key ] ];
+				continue;
+
+			}
+
+			if ( key === 'payload' ) {
+
+				primFields.payload = data[ key ];
 				continue;
 
 			}
 
-			// Handle material binding
 			if ( key.startsWith( 'rel ' ) ) {
 
-				const relName = key.slice( 4 ); // Remove 'rel '
+				const relName = key.slice( 4 );
 				const relPath = path + '.' + relName;
 				const target = data[ key ].replace( /[<>]/g, '' );
 				specsByPath[ relPath ] = {

+ 2 - 26
examples/jsm/loaders/usd/USDComposer.js

@@ -359,7 +359,7 @@ class USDComposer {
 			const typeName = spec.fields.typeName;
 
 			// Check for references/payloads
-			const refValue = this._getReference( path, spec );
+			const refValue = this._getReference( spec );
 			if ( refValue ) {
 
 				// Get local variant selections from this prim
@@ -729,22 +729,17 @@ class USDComposer {
 
 	/**
 	 * Get reference value from a prim spec.
-	 * Checks for references in USDC format (fields.references) and
-	 * USDA format (relationship specs).
 	 */
-	_getReference( path, spec ) {
+	_getReference( spec ) {
 
-		// USDC format: references stored in fields
 		if ( spec.fields.references && spec.fields.references.length > 0 ) {
 
 			const ref = spec.fields.references[ 0 ];
-			// Reference can be string or object with assetPath
 			if ( typeof ref === 'string' ) return ref;
 			if ( ref.assetPath ) return '@' + ref.assetPath + '@';
 
 		}
 
-		// USDC format: payload stored in fields
 		if ( spec.fields.payload ) {
 
 			const payload = spec.fields.payload;
@@ -753,23 +748,6 @@ class USDComposer {
 
 		}
 
-		// USDA format: check relationship specs
-		const prependRefPath = path + '.prepend:references';
-		const prependRefSpec = this.specsByPath[ prependRefPath ];
-		if ( prependRefSpec && prependRefSpec.fields.default ) {
-
-			return prependRefSpec.fields.default;
-
-		}
-
-		const payloadPath = path + '.payload';
-		const payloadSpec = this.specsByPath[ payloadPath ];
-		if ( payloadSpec && payloadSpec.fields.default ) {
-
-			return payloadSpec.fields.default;
-
-		}
-
 		return null;
 
 	}
@@ -877,7 +855,6 @@ class USDComposer {
 			mesh = new SkinnedMesh( geometry, material );
 
 			// Find skeleton path from skel:skeleton relationship
-			// USDC uses ".skel:skeleton", USDA uses ".rel skel:skeleton"
 			let skelBindingSpec = this.specsByPath[ path + '.skel:skeleton' ];
 			if ( ! skelBindingSpec ) {
 
@@ -895,7 +872,6 @@ class USDComposer {
 
 				} else if ( skelBindingSpec.fields.default ) {
 
-					// USDA stores relationship targets in default field with angle brackets
 					skeletonPath = skelBindingSpec.fields.default.replace( /<|>/g, '' );
 
 				}

粤ICP备19079148号