Преглед изворни кода

Explicitly set the SVG MIME type (to fix loading SVGs as textures)

Kevan Stannard пре 8 година
родитељ
комит
767690c0ba
1 измењених фајлова са 5 додато и 6 уклоњено
  1. 5 6
      src/loaders/FileLoader.js

+ 5 - 6
src/loaders/FileLoader.js

@@ -184,13 +184,12 @@ Object.assign( FileLoader.prototype, {
 			if ( this.responseType !== undefined ) request.responseType = this.responseType;
 			if ( this.withCredentials !== undefined ) request.withCredentials = this.withCredentials;
 
-			if ( ! this.mimeType && this.responseType !== 'blob' ) {
+			// Setting 'text/plain' as the MIME type for SVG files will cause a
+			// problem when the ImageLoader tries to use it as the src of an image,
+			// so explicitly set the SVG MIME type.
+			if ( /\.svg$/.test( url ) ) this.mimeType = 'image/svg+xml';
 
-				this.setMimeType( 'text/plain' );
-
-			}
-
-			if ( this.mimeType && request.overrideMimeType ) request.overrideMimeType( this.mimeType );
+			if ( request.overrideMimeType ) request.overrideMimeType( this.mimeType !== undefined ? this.mimeType : 'text/plain' );
 
 			request.send( null );