فهرست منبع

WebGLTextures: Moved createCanvas function outside of resizeImage.

Mr.doob 6 سال پیش
والد
کامیت
16128d244b
1فایلهای تغییر یافته به همراه12 افزوده شده و 12 حذف شده
  1. 12 12
      src/renderers/webgl/WebGLTextures.js

+ 12 - 12
src/renderers/webgl/WebGLTextures.js

@@ -12,6 +12,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;
@@ -32,18 +44,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 			if ( image instanceof ImageBitmap || image instanceof HTMLImageElement || image instanceof HTMLCanvasElement ) {
 
-				// Use an offscreen canvas to resize the image if available, otherwise a canvas element will be created but this won't work in web workers
-
-				var useOffscreenCanvas = typeof OffscreenCanvas !== 'undefined';
-
-				function createCanvas( width, height ) {
-
-					return useOffscreenCanvas ?
-						new OffscreenCanvas( width, height ) :
-						document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );
-
-				}
-
 				var floor = needsPowerOfTwo ? _Math.floorPowerOfTwo : Math.floor;
 
 				var width = floor( scale * image.width );