Forráskód Böngészése

Merge pull request #14331 from Mugen87/dev12

Loaders: Harmonize crossOrigin default value
Mr.doob 7 éve
szülő
commit
b7c1b680a5

+ 1 - 1
docs/api/loaders/CubeTextureLoader.html

@@ -56,7 +56,7 @@ scene.background = new THREE.CubeTextureLoader()
 		<p>
 		If set, assigns the [link:https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes crossOrigin]
 	 attribute of the image to the value of *crossOrigin*,
-		prior to starting the load. Default is *"Anonymous"*.
+		prior to starting the load. Default is *"anonymous"*.
 		</p>
 
 		<h3>[property:LoadingManager manager]</h3>

+ 1 - 1
docs/api/loaders/ImageLoader.html

@@ -69,7 +69,7 @@
 		<h3>[property:String crossOrigin]</h3>
 		<p>
 		If set, assigns the [link:https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes crossOrigin]
-	 attribute of the image to the value of *crossOrigin*, prior to starting the load. Default is *"Anonymous"*.
+	 attribute of the image to the value of *crossOrigin*, prior to starting the load. Default is *"anonymous"*.
 		</p>
 
 		<h3>[property:LoadingManager manager]</h3>

+ 1 - 0
docs/api/loaders/Loader.html

@@ -39,6 +39,7 @@
 		<h3>[property:string crossOrigin]</h3>
 		<p>
 		The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
+		Default is *"anonymous"*.
 		</p>
 
 		<h2>Methods</h2>

+ 1 - 1
docs/api/loaders/TextureLoader.html

@@ -72,7 +72,7 @@
 		<h3>[property:String crossOrigin]</h3>
 		<p>
 		If set, assigns the [link:https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes crossOrigin]
-	 attribute of the image to the value of *crossOrigin*, prior to starting the load. Default is *"Anonymous"*.
+	 attribute of the image to the value of *crossOrigin*, prior to starting the load. Default is *"anonymous"*.
 		</p>
 
 

+ 7 - 6
docs/examples/loaders/MTLLoader.html

@@ -44,7 +44,7 @@
 		</p>
 
 
-		<h3>[method:null setPath]( [param:String path] )</h3>
+		<h3>[method:MTLLoader setPath]( [param:String path] )</h3>
 		<p>
 			[page:String path] — required<br />
 		</p>
@@ -53,7 +53,7 @@
 		</p>
 
 
-		<h3>[method:null setTexturePath]( [param:String path] )</h3>
+		<h3>[method:MTLLoader setTexturePath]( [param:String path] )</h3>
 		<p>
 			[page:String path] — required<br />
 		</p>
@@ -62,16 +62,17 @@
 		</p>
 
 
-		<h3>[method:null setCrossOrigin]( [param:boolean useCrossOrigin] )</h3>
+		<h3>[method:MTLLoader setCrossOrigin]( [param:String value] )</h3>
 		<p>
-			[page:boolean useCrossOrigin] — required<br />
+			[page:String value] — required<br />
 		</p>
 		<p>
-			Set to true if you need to load textures from a different origin.
+			If set, assigns the [link:https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes crossOrigin]
+		 attribute of the image to the value of *crossOrigin*, prior to starting the load. Default is *"anonymous"*.
 		</p>
 
 
-		<h3>[method:null setMaterialOptions]( [param:Object options] )</h3>
+		<h3>[method:MTLLoader setMaterialOptions]( [param:Object options] )</h3>
 		<p>
 			[page:Object options] — required
 			<ul>

+ 4 - 1
examples/js/loaders/AssimpJSONLoader.js

@@ -21,7 +21,7 @@ THREE.AssimpJSONLoader.prototype = {
 
 	constructor: THREE.AssimpJSONLoader,
 
-	crossOrigin: 'Anonymous',
+	crossOrigin: 'anonymous',
 
 	load: function ( url, onLoad, onProgress, onError ) {
 
@@ -67,6 +67,7 @@ THREE.AssimpJSONLoader.prototype = {
 	setCrossOrigin: function ( value ) {
 
 		this.crossOrigin = value;
+		return this;
 
 	},
 
@@ -221,8 +222,10 @@ THREE.AssimpJSONLoader.prototype = {
 
 					case '$mat.opacity':
 						if ( value < 1 ) {
+
 							material.opacity = value;
 							material.transparent = true;
+
 						}
 						break;
 

+ 4 - 3
examples/js/loaders/AssimpLoader.js

@@ -12,7 +12,7 @@ THREE.AssimpLoader.prototype = {
 
 	constructor: THREE.AssimpLoader,
 
-	crossOrigin: 'Anonymous',
+	crossOrigin: 'anonymous',
 
 	load: function ( url, onLoad, onProgress, onError ) {
 
@@ -34,6 +34,7 @@ THREE.AssimpLoader.prototype = {
 	setCrossOrigin: function ( value ) {
 
 		this.crossOrigin = value;
+		return this;
 
 	},
 
@@ -1129,7 +1130,7 @@ THREE.AssimpLoader.prototype = {
 			}
 
 			if ( ! key ) {
-				
+
 				return null;
 
 			} else if ( nextKey ) {
@@ -1150,7 +1151,7 @@ THREE.AssimpLoader.prototype = {
 				var l = T / dT;
 
 				return lerp( key.mValue.toTHREE(), nextKey.mValue.toTHREE(), l );
-				
+
 			}
 
 		}

+ 4 - 1
examples/js/loaders/BinaryLoader.js

@@ -19,7 +19,7 @@ THREE.BinaryLoader.prototype = {
 
 	constructor: THREE.BinaryLoader,
 
-	crossOrigin: 'Anonymous',
+	crossOrigin: 'anonymous',
 
 	// Load models generated by slim OBJ converter with BINARY option (converter_obj_three_slim.py -t binary)
 	//  - binary models consist of two files: JS and BIN
@@ -66,18 +66,21 @@ THREE.BinaryLoader.prototype = {
 	setBinaryPath: function ( value ) {
 
 		this.binaryPath = value;
+		return this;
 
 	},
 
 	setCrossOrigin: function ( value ) {
 
 		this.crossOrigin = value;
+		return this;
 
 	},
 
 	setTexturePath: function ( value ) {
 
 		this.texturePath = value;
+		return this;
 
 	},
 

+ 3 - 1
examples/js/loaders/ColladaLoader.js

@@ -13,7 +13,7 @@ THREE.ColladaLoader.prototype = {
 
 	constructor: THREE.ColladaLoader,
 
-	crossOrigin: 'Anonymous',
+	crossOrigin: 'anonymous',
 
 	load: function ( url, onLoad, onProgress, onError ) {
 
@@ -33,6 +33,7 @@ THREE.ColladaLoader.prototype = {
 	setPath: function ( value ) {
 
 		this.path = value;
+		return this;
 
 	},
 
@@ -49,6 +50,7 @@ THREE.ColladaLoader.prototype = {
 	setCrossOrigin: function ( value ) {
 
 		this.crossOrigin = value;
+		return this;
 
 	},
 

+ 2 - 10
examples/js/loaders/DRACOLoader.js

@@ -42,9 +42,6 @@ THREE.DRACOLoader.prototype = {
         var loader = new THREE.FileLoader(scope.manager);
         loader.setPath(this.path);
         loader.setResponseType('arraybuffer');
-        if (this.crossOrigin !== undefined) {
-          loader.crossOrigin = this.crossOrigin;
-        }
         loader.load(url, function(blob) {
             scope.decodeDracoFile(blob, onLoad);
         }, onProgress, onError);
@@ -55,11 +52,6 @@ THREE.DRACOLoader.prototype = {
         return this;
     },
 
-    setCrossOrigin: function(value) {
-        this.crossOrigin = value;
-        return this;
-    },
-
     setVerbosity: function(level) {
         this.verbosity = level;
         return this;
@@ -146,7 +138,7 @@ THREE.DRACOLoader.prototype = {
     },
 
     addAttributeToGeometry: function(dracoDecoder, decoder, dracoGeometry,
-                                     attributeName, attributeType, attribute, 
+                                     attributeName, attributeType, attribute,
                                      geometry, geometryBuffer) {
       if (attribute.ptr === 0) {
         var errorMsg = 'THREE.DRACOLoader: No attribute ' + attributeName;
@@ -224,7 +216,7 @@ THREE.DRACOLoader.prototype = {
           throw new Error( errorMsg );
 
       }
-      
+
       // Copy data from decoder.
       for (var i = 0; i < numValues; i++) {
         geometryBuffer[attributeName][i] = attributeData.GetValue(i);

+ 12 - 1
examples/js/loaders/FBXLoader.js

@@ -32,6 +32,8 @@
 
 	Object.assign( THREE.FBXLoader.prototype, {
 
+		crossOrigin: 'anonymous',
+
 		load: function ( url, onLoad, onProgress, onError ) {
 
 			var self = this;
@@ -63,6 +65,13 @@
 
 		},
 
+		setCrossOrigin: function ( value ) {
+
+			this.crossOrigin = value;
+			return this;
+
+		},
+
 		parse: function ( FBXBuffer, resourceDirectory ) {
 
 			var FBXTree;
@@ -93,9 +102,11 @@
 
 			// console.log( FBXTree );
 
+			var textureLoader = new THREE.TextureLoader( this.manager ).setPath( resourceDirectory ).setCrossOrigin( this.crossOrigin );
+
 			var connections = parseConnections( FBXTree );
 			var images = parseImages( FBXTree );
-			var textures = parseTextures( FBXTree, new THREE.TextureLoader( this.manager ).setPath( resourceDirectory ), images, connections );
+			var textures = parseTextures( FBXTree, textureLoader, images, connections );
 			var materials = parseMaterials( FBXTree, textures, connections );
 			var deformers = parseDeformers( FBXTree, connections );
 			var geometryMap = parseGeometries( FBXTree, connections, deformers );

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

@@ -19,7 +19,7 @@ THREE.GLTFLoader = ( function () {
 
 		constructor: GLTFLoader,
 
-		crossOrigin: 'Anonymous',
+		crossOrigin: 'anonymous',
 
 		load: function ( url, onLoad, onProgress, onError ) {
 

+ 1 - 1
examples/js/loaders/LoaderSupport.js

@@ -1240,7 +1240,7 @@ THREE.LoaderSupport.WorkerDirector = (function () {
 
 		this.maxQueueSize = MAX_QUEUE_SIZE ;
 		this.maxWebWorkers = MAX_WEB_WORKER;
-		this.crossOrigin = null;
+		this.crossOrigin = 'anonymous';
 
 		if ( ! Validator.isValid( classDef ) ) throw 'Provided invalid classDef: ' + classDef;
 

+ 4 - 4
examples/js/loaders/MMDLoader.js

@@ -50,7 +50,7 @@ THREE.MMDLoader = ( function () {
 
 		constructor: MMDLoader,
 
-		crossOrigin: undefined,
+		crossOrigin: 'anonymous',
 
 		/**
 		 * @param {string} value
@@ -329,7 +329,7 @@ THREE.MMDLoader = ( function () {
 
 		constructor: MeshBuilder,
 
-		crossOrigin: undefined,
+		crossOrigin: 'anonymous',
 
 		/**
 		 * @param {string} crossOrigin
@@ -876,7 +876,7 @@ THREE.MMDLoader = ( function () {
 
 		constructor: MaterialBuilder,
 
-		crossOrigin: undefined,
+		crossOrigin: 'anonymous',
 
 		texturePath: undefined,
 
@@ -946,7 +946,7 @@ THREE.MMDLoader = ( function () {
 				params.shininess = Math.max( material.shininess, 1e-4 ); // to prevent pow( 0.0, 0.0 )
 				params.transparent = params.opacity !== 1.0;
 
-				// 
+				//
 
 				params.skinning = geometry.bones.length > 0 ? true : false;
 				params.morphTargets = geometry.morphTargets.length > 0 ? true : false;

+ 2 - 1
examples/js/loaders/MTLLoader.js

@@ -208,11 +208,12 @@ THREE.MTLLoader.MaterialCreator.prototype = {
 
 	constructor: THREE.MTLLoader.MaterialCreator,
 
-	crossOrigin: 'Anonymous',
+	crossOrigin: 'anonymous',
 
 	setCrossOrigin: function ( value ) {
 
 		this.crossOrigin = value;
+		return this;
 
 	},
 

+ 2 - 1
examples/js/loaders/VRMLLoader.js

@@ -26,7 +26,7 @@ THREE.VRMLLoader.prototype = {
 
 	recordingFieldname: null,
 
-	crossOrigin: 'Anonymous',
+	crossOrigin: 'anonymous',
 
 	load: function ( url, onLoad, onProgress, onError ) {
 
@@ -44,6 +44,7 @@ THREE.VRMLLoader.prototype = {
 	setCrossOrigin: function ( value ) {
 
 		this.crossOrigin = value;
+		return this;
 
 	},
 

+ 1 - 1
examples/js/loaders/VRMLoader.js

@@ -26,7 +26,7 @@ THREE.VRMLoader = ( function () {
 
 		constructor: VRMLoader,
 
-		crossOrigin: 'Anonymous',
+		crossOrigin: 'anonymous',
 
 		load: function ( url, onLoad, onProgress, onError ) {
 

+ 2 - 1
examples/js/loaders/deprecated/LegacyGLTFLoader.js

@@ -17,7 +17,7 @@ THREE.LegacyGLTFLoader = ( function () {
 
 		constructor: LegacyGLTFLoader,
 
-		crossOrigin: 'Anonymous',
+		crossOrigin: 'anonymous',
 
 		load: function ( url, onLoad, onProgress, onError ) {
 
@@ -40,6 +40,7 @@ THREE.LegacyGLTFLoader = ( function () {
 		setCrossOrigin: function ( value ) {
 
 			this.crossOrigin = value;
+			return this;
 
 		},
 

+ 1 - 1
src/loaders/CubeTextureLoader.js

@@ -15,7 +15,7 @@ function CubeTextureLoader( manager ) {
 
 Object.assign( CubeTextureLoader.prototype, {
 
-	crossOrigin: 'Anonymous',
+	crossOrigin: 'anonymous',
 
 	load: function ( urls, onLoad, onProgress, onError ) {
 

+ 1 - 1
src/loaders/ImageLoader.js

@@ -14,7 +14,7 @@ function ImageLoader( manager ) {
 
 Object.assign( ImageLoader.prototype, {
 
-	crossOrigin: 'Anonymous',
+	crossOrigin: 'anonymous',
 
 	load: function ( url, onLoad, onProgress, onError ) {
 

+ 1 - 1
src/loaders/Loader.js

@@ -61,7 +61,7 @@ Loader.Handlers = {
 
 Object.assign( Loader.prototype, {
 
-	crossOrigin: undefined,
+	crossOrigin: 'anonymous',
 
 	onLoadStart: function () {},
 

+ 1 - 1
src/loaders/TextureLoader.js

@@ -16,7 +16,7 @@ function TextureLoader( manager ) {
 
 Object.assign( TextureLoader.prototype, {
 
-	crossOrigin: 'Anonymous',
+	crossOrigin: 'anonymous',
 
 	load: function ( url, onLoad, onProgress, onError ) {