Bläddra i källkod

Merge pull request #16601 from mrschofield/dev-gltf-file-loader-with-credentials

Changing the example GLTFLoader to honour the crossOrigin option by
Mr.doob 6 år sedan
förälder
incheckning
282062a7e0
2 ändrade filer med 24 tillägg och 0 borttagningar
  1. 12 0
      examples/js/loaders/GLTFLoader.js
  2. 12 0
      examples/jsm/loaders/GLTFLoader.js

+ 12 - 0
examples/js/loaders/GLTFLoader.js

@@ -68,6 +68,12 @@ THREE.GLTFLoader = ( function () {
 			loader.setPath( this.path );
 			loader.setPath( this.path );
 			loader.setResponseType( 'arraybuffer' );
 			loader.setResponseType( 'arraybuffer' );
 
 
+			if ( scope.crossOrigin === 'use-credentials' ) {
+
+				loader.setWithCredentials( true );
+
+			}
+
 			loader.load( url, function ( data ) {
 			loader.load( url, function ( data ) {
 
 
 				try {
 				try {
@@ -1609,6 +1615,12 @@ THREE.GLTFLoader = ( function () {
 		this.fileLoader = new THREE.FileLoader( this.options.manager );
 		this.fileLoader = new THREE.FileLoader( this.options.manager );
 		this.fileLoader.setResponseType( 'arraybuffer' );
 		this.fileLoader.setResponseType( 'arraybuffer' );
 
 
+		if ( this.options.crossOrigin === 'use-credentials' ) {
+
+			this.fileLoader.setWithCredentials( true );
+
+		}
+
 	}
 	}
 
 
 	GLTFParser.prototype.parse = function ( onLoad, onError ) {
 	GLTFParser.prototype.parse = function ( onLoad, onError ) {

+ 12 - 0
examples/jsm/loaders/GLTFLoader.js

@@ -160,6 +160,12 @@ var GLTFLoader = ( function () {
 			loader.setPath( this.path );
 			loader.setPath( this.path );
 			loader.setResponseType( 'arraybuffer' );
 			loader.setResponseType( 'arraybuffer' );
 
 
+			if ( this.options.crossOrigin === 'use-credentials' ) {
+
+				this.fileLoader.setWithCredentials( true );
+
+			}
+
 			loader.load( url, function ( data ) {
 			loader.load( url, function ( data ) {
 
 
 				try {
 				try {
@@ -1701,6 +1707,12 @@ var GLTFLoader = ( function () {
 		this.fileLoader = new FileLoader( this.options.manager );
 		this.fileLoader = new FileLoader( this.options.manager );
 		this.fileLoader.setResponseType( 'arraybuffer' );
 		this.fileLoader.setResponseType( 'arraybuffer' );
 
 
+		if ( this.options.crossOrigin === 'use-credentials' ) {
+
+			this.fileLoader.setWithCredentials( true );
+
+		}
+
 	}
 	}
 
 
 	GLTFParser.prototype.parse = function ( onLoad, onError ) {
 	GLTFParser.prototype.parse = function ( onLoad, onError ) {