浏览代码

Updated builds.

Mr.doob 6 年之前
父节点
当前提交
a16e76f078
共有 3 个文件被更改,包括 383 次插入349 次删除
  1. 27 10
      build/three.js
  2. 329 329
      build/three.min.js
  3. 27 10
      build/three.module.js

+ 27 - 10
build/three.js

@@ -20073,6 +20073,18 @@
 
 		//
 
+		var useOffscreenCanvas = typeof OffscreenCanvas !== 'undefined';
+
+		function createCanvas( width, height ) {
+
+			// Use OffscreenCanvas when available. Specially needed in web workers
+
+			return useOffscreenCanvas ?
+				new OffscreenCanvas( width, height ) :
+				document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );
+
+		}
+
 		function resizeImage( image, needsPowerOfTwo, needsNewCanvas, maxSize ) {
 
 			var scale = 1;
@@ -20091,25 +20103,28 @@
 
 				// only perform resize for certain image types
 
-				if ( image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof ImageBitmap ) {
+				if ( image instanceof ImageBitmap || image instanceof HTMLImageElement || image instanceof HTMLCanvasElement ) {
 
-					if ( _canvas === undefined ) _canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );
+					var floor = needsPowerOfTwo ? _Math.floorPowerOfTwo : Math.floor;
 
-					// cube textures can't reuse the same canvas
+					var width = floor( scale * image.width );
+					var height = floor( scale * image.height );
 
-					var canvas = needsNewCanvas ? document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ) : _canvas;
+					if ( _canvas === undefined ) _canvas = createCanvas( width, height );
 
-					var floor = needsPowerOfTwo ? _Math.floorPowerOfTwo : Math.floor;
+					// cube textures can't reuse the same canvas
 
-					canvas.width = floor( scale * image.width );
-					canvas.height = floor( scale * image.height );
+					var canvas = needsNewCanvas ? createCanvas( width, height ) : _canvas;
+
+					canvas.width = width;
+					canvas.height = height;
 
 					var context = canvas.getContext( '2d' );
-					context.drawImage( image, 0, 0, canvas.width, canvas.height );
+					context.drawImage( image, 0, 0, width, height );
 
-					console.warn( 'THREE.WebGLRenderer: Texture has been resized from (' + image.width + 'x' + image.height + ') to (' + canvas.width + 'x' + canvas.height + ').' );
+					console.warn( 'THREE.WebGLRenderer: Texture has been resized from (' + image.width + 'x' + image.height + ') to (' + width + 'x' + height + ').' );
 
-					return canvas;
+					return useOffscreenCanvas ? canvas.transferToImageBitmap() : canvas;
 
 				} else {
 
@@ -38975,6 +38990,8 @@
 
 			} );
 
+			scope.manager.itemStart( url );
+
 		},
 
 		setCrossOrigin: function ( /* value */ ) {

文件差异内容过多而无法显示
+ 329 - 329
build/three.min.js


+ 27 - 10
build/three.module.js

@@ -20067,6 +20067,18 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 	//
 
+	var useOffscreenCanvas = typeof OffscreenCanvas !== 'undefined';
+
+	function createCanvas( width, height ) {
+
+		// Use OffscreenCanvas when available. Specially needed in web workers
+
+		return useOffscreenCanvas ?
+			new OffscreenCanvas( width, height ) :
+			document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );
+
+	}
+
 	function resizeImage( image, needsPowerOfTwo, needsNewCanvas, maxSize ) {
 
 		var scale = 1;
@@ -20085,25 +20097,28 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 			// only perform resize for certain image types
 
-			if ( image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof ImageBitmap ) {
+			if ( image instanceof ImageBitmap || image instanceof HTMLImageElement || image instanceof HTMLCanvasElement ) {
 
-				if ( _canvas === undefined ) _canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );
+				var floor = needsPowerOfTwo ? _Math.floorPowerOfTwo : Math.floor;
 
-				// cube textures can't reuse the same canvas
+				var width = floor( scale * image.width );
+				var height = floor( scale * image.height );
 
-				var canvas = needsNewCanvas ? document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ) : _canvas;
+				if ( _canvas === undefined ) _canvas = createCanvas( width, height );
 
-				var floor = needsPowerOfTwo ? _Math.floorPowerOfTwo : Math.floor;
+				// cube textures can't reuse the same canvas
 
-				canvas.width = floor( scale * image.width );
-				canvas.height = floor( scale * image.height );
+				var canvas = needsNewCanvas ? createCanvas( width, height ) : _canvas;
+
+				canvas.width = width;
+				canvas.height = height;
 
 				var context = canvas.getContext( '2d' );
-				context.drawImage( image, 0, 0, canvas.width, canvas.height );
+				context.drawImage( image, 0, 0, width, height );
 
-				console.warn( 'THREE.WebGLRenderer: Texture has been resized from (' + image.width + 'x' + image.height + ') to (' + canvas.width + 'x' + canvas.height + ').' );
+				console.warn( 'THREE.WebGLRenderer: Texture has been resized from (' + image.width + 'x' + image.height + ') to (' + width + 'x' + height + ').' );
 
-				return canvas;
+				return useOffscreenCanvas ? canvas.transferToImageBitmap() : canvas;
 
 			} else {
 
@@ -38969,6 +38984,8 @@ ImageBitmapLoader.prototype = {
 
 		} );
 
+		scope.manager.itemStart( url );
+
 	},
 
 	setCrossOrigin: function ( /* value */ ) {

部分文件因为文件数量过多而无法显示