Explorar el Código

Implement manager.resolveResourceURL()

Don McCurdy hace 8 años
padre
commit
91e73b65ff
Se han modificado 3 ficheros con 24 adiciones y 0 borrados
  1. 2 0
      src/loaders/FileLoader.js
  2. 2 0
      src/loaders/ImageLoader.js
  3. 20 0
      src/loaders/LoadingManager.js

+ 2 - 0
src/loaders/FileLoader.js

@@ -19,6 +19,8 @@ Object.assign( FileLoader.prototype, {
 
 
 		if ( this.path !== undefined ) url = this.path + url;
 		if ( this.path !== undefined ) url = this.path + url;
 
 
+		url = this.manager.resolveResourceURL( url );
+
 		var scope = this;
 		var scope = this;
 
 
 		var cached = Cache.get( url );
 		var cached = Cache.get( url );

+ 2 - 0
src/loaders/ImageLoader.js

@@ -22,6 +22,8 @@ Object.assign( ImageLoader.prototype, {
 
 
 		if ( this.path !== undefined ) url = this.path + url;
 		if ( this.path !== undefined ) url = this.path + url;
 
 
+		url = this.manager.resolveResourceURL( url );
+
 		var scope = this;
 		var scope = this;
 
 
 		var cached = Cache.get( url );
 		var cached = Cache.get( url );

+ 20 - 0
src/loaders/LoadingManager.js

@@ -13,6 +13,8 @@ function LoadingManager( onLoad, onProgress, onError ) {
 	this.onProgress = onProgress;
 	this.onProgress = onProgress;
 	this.onError = onError;
 	this.onError = onError;
 
 
+	this.resourceTransform = undefined;
+
 	this.itemStart = function ( url ) {
 	this.itemStart = function ( url ) {
 
 
 		itemsTotal ++;
 		itemsTotal ++;
@@ -65,6 +67,24 @@ function LoadingManager( onLoad, onProgress, onError ) {
 
 
 	};
 	};
 
 
+	this.resolveResourceURL = function ( url ) {
+
+		if ( this.resourceTransform ) {
+
+			return this.resourceTransform( url );
+
+		}
+
+		return url;
+
+	};
+
+	this.setResourceTransform = function ( transform ) {
+
+		this.resourceTransform = transform;
+
+	};
+
 }
 }
 
 
 var DefaultLoadingManager = new LoadingManager();
 var DefaultLoadingManager = new LoadingManager();