提交 18d14c26 编写于 作者: K Kevan Stannard

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

上级 767690c0
......@@ -184,11 +184,6 @@ Object.assign( FileLoader.prototype, {
if ( this.responseType !== undefined ) request.responseType = this.responseType;
if ( this.withCredentials !== undefined ) request.withCredentials = this.withCredentials;
// 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';
if ( request.overrideMimeType ) request.overrideMimeType( this.mimeType !== undefined ? this.mimeType : 'text/plain' );
request.send( null );
......
......@@ -48,6 +48,13 @@ Object.assign( ImageLoader.prototype, {
loader.setPath( this.path );
loader.setResponseType( 'blob' );
loader.setWithCredentials( this.withCredentials );
// By default the FileLoader requests files to be loaded with a MIME
// type of `text/plain`. Using `URL.createObjectURL()` with SVGs that
// have a MIME type of `text/plain` results in an error, so explicitly
// set the SVG MIME type.
if ( /\.svg$/.test( url ) ) loader.setMimeType( 'image/svg+xml' );
loader.load( url, function ( blob ) {
image.src = URL.createObjectURL( blob );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册