|
@@ -12,6 +12,7 @@ import {
|
|
Box3,
|
|
Box3,
|
|
BufferAttribute,
|
|
BufferAttribute,
|
|
BufferGeometry,
|
|
BufferGeometry,
|
|
|
|
+ CanvasTexture,
|
|
ClampToEdgeWrapping,
|
|
ClampToEdgeWrapping,
|
|
Color,
|
|
Color,
|
|
DirectionalLight,
|
|
DirectionalLight,
|
|
@@ -1477,14 +1478,16 @@ var GLTFLoader = ( function () {
|
|
// BufferGeometry caching
|
|
// BufferGeometry caching
|
|
this.primitiveCache = {};
|
|
this.primitiveCache = {};
|
|
|
|
|
|
- this.textureLoader = new TextureLoader( this.options.manager );
|
|
|
|
- this.textureLoader.setCrossOrigin( this.options.crossOrigin );
|
|
|
|
|
|
+ this.useImageBitmap = typeof createImageBitmap !== 'undefined';
|
|
|
|
|
|
// Use an ImageBitmapLoader if imageBitmaps are supported. Moves much of the
|
|
// Use an ImageBitmapLoader if imageBitmaps are supported. Moves much of the
|
|
// expensive work of uploading a texture to the GPU off the main thread.
|
|
// expensive work of uploading a texture to the GPU off the main thread.
|
|
- if ( typeof createImageBitmap !== 'undefined' ) {
|
|
|
|
- this.textureLoader.setImageLoader( new ImageBitmapLoader( this.options.manager ) );
|
|
|
|
|
|
+ if ( this.useImageBitmap ) {
|
|
|
|
+ this.textureLoader = new ImageBitmapLoader( this.options.manager );
|
|
|
|
+ } else {
|
|
|
|
+ this.textureLoader = new TextureLoader( this.options.manager );
|
|
}
|
|
}
|
|
|
|
+ this.textureLoader.setCrossOrigin( this.options.crossOrigin );
|
|
|
|
|
|
this.fileLoader = new FileLoader( this.options.manager );
|
|
this.fileLoader = new FileLoader( this.options.manager );
|
|
this.fileLoader.setResponseType( 'arraybuffer' );
|
|
this.fileLoader.setResponseType( 'arraybuffer' );
|
|
@@ -1902,6 +1905,7 @@ var GLTFLoader = ( function () {
|
|
var parser = this;
|
|
var parser = this;
|
|
var json = this.json;
|
|
var json = this.json;
|
|
var options = this.options;
|
|
var options = this.options;
|
|
|
|
+ var useImageBitmap = this.useImageBitmap;
|
|
var textureLoader = this.textureLoader;
|
|
var textureLoader = this.textureLoader;
|
|
|
|
|
|
var URL = self.URL || self.webkitURL;
|
|
var URL = self.URL || self.webkitURL;
|
|
@@ -1956,7 +1960,19 @@ var GLTFLoader = ( function () {
|
|
|
|
|
|
return new Promise( function ( resolve, reject ) {
|
|
return new Promise( function ( resolve, reject ) {
|
|
|
|
|
|
- loader.load( resolveURL( sourceURI, options.path ), resolve, undefined, reject );
|
|
|
|
|
|
+ var onLoad = resolve;
|
|
|
|
+
|
|
|
|
+ if ( useImageBitmap ) {
|
|
|
|
+
|
|
|
|
+ onLoad = function ( imageBitmap ) {
|
|
|
|
+
|
|
|
|
+ resolve( new CanvasTexture( imageBitmap ) );
|
|
|
|
+
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ loader.load( resolveURL( sourceURI, options.path ), onLoad, undefined, reject );
|
|
|
|
|
|
} );
|
|
} );
|
|
|
|
|