提交 a16e76f0 编写于 作者: M Mr.doob

Updated builds.

上级 16128d24
......@@ -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 */ ) {
此差异已折叠。
......@@ -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 */ ) {
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册