Răsfoiți Sursa

GLTFLoader: add getDependency( type, index ) implementation (#24252)

* add getDependency('light') implementation

* switch to getDependency ( type, index ) instead of special case getDependency ( 'light' )

* implement getDependency for the light extension
hybridherbst 2 ani în urmă
părinte
comite
cd017c65bf
1 a modificat fișierele cu 21 adăugiri și 1 ștergeri
  1. 21 1
      examples/jsm/loaders/GLTFLoader.js

+ 21 - 1
examples/jsm/loaders/GLTFLoader.js

@@ -590,6 +590,14 @@ class GLTFLightsExtension {
 
 	}
 
+	getDependency( type, index ) {	
+
+		if ( type !== 'light' ) return;
+
+		return this._loadLight( index );
+
+	}
+
 	createNodeAttachment( nodeIndex ) {
 
 		const self = this;
@@ -2917,7 +2925,19 @@ class GLTFParser {
 					break;
 
 				default:
-					throw new Error( 'Unknown type: ' + type );
+					dependency = this._invokeOne( function ( ext ) {
+
+						return ext != this && ext.getDependency && ext.getDependency( type, index );
+
+					} );
+
+					if ( ! dependency ) {
+
+						throw new Error( 'Unknown type: ' + type );
+
+					}
+
+					break;
 
 			}