Browse Source

ImageLoader/XHRLoader: Added .setPath()

Mr.doob 9 years ago
parent
commit
b858a99cf8
2 changed files with 18 additions and 2 deletions
  1. 8 0
      src/loaders/ImageLoader.js
  2. 10 2
      src/loaders/XHRLoader.js

+ 8 - 0
src/loaders/ImageLoader.js

@@ -14,6 +14,8 @@ THREE.ImageLoader.prototype = {
 
 	load: function ( url, onLoad, onProgress, onError ) {
 
+		if ( this.path !== undefined ) url = this.path + url;
+
 		var scope = this;
 
 		var cached = THREE.Cache.get( url );
@@ -86,6 +88,12 @@ THREE.ImageLoader.prototype = {
 
 		this.crossOrigin = value;
 
+	},
+
+	setPath: function ( value ) {
+
+		this.path = value;
+
 	}
 
 };

+ 10 - 2
src/loaders/XHRLoader.js

@@ -14,6 +14,8 @@ THREE.XHRLoader.prototype = {
 
 	load: function ( url, onLoad, onProgress, onError ) {
 
+		if ( this.path !== undefined ) url = this.path + url;
+
 		var scope = this;
 
 		var cached = THREE.Cache.get( url );
@@ -79,15 +81,21 @@ THREE.XHRLoader.prototype = {
 
 	},
 
+	setCrossOrigin: function ( value ) {
+
+		this.crossOrigin = value;
+
+	},
+
 	setResponseType: function ( value ) {
 
 		this.responseType = value;
 
 	},
 
-	setCrossOrigin: function ( value ) {
+	setPath: function ( value ) {
 
-		this.crossOrigin = value;
+		this.path = value;
 
 	},