提交 bea91359 编写于 作者: M Mugen87

WebGLTextures: Make makePowerOfTwo() more memory friendly

上级 f09e1a6a
......@@ -9,6 +9,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
var _isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && _gl instanceof WebGL2RenderingContext );
var _videoTextures = {};
var _canvas;
//
......@@ -48,16 +49,17 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
if ( image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof ImageBitmap ) {
var canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );
canvas.width = _Math.floorPowerOfTwo( image.width );
canvas.height = _Math.floorPowerOfTwo( image.height );
if ( _canvas === undefined ) _canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );
var context = canvas.getContext( '2d' );
context.drawImage( image, 0, 0, canvas.width, canvas.height );
_canvas.width = _Math.floorPowerOfTwo( image.width );
_canvas.height = _Math.floorPowerOfTwo( image.height );
console.warn( 'THREE.WebGLRenderer: image is not power of two (' + image.width + 'x' + image.height + '). Resized to ' + canvas.width + 'x' + canvas.height, image );
var context = _canvas.getContext( '2d' );
context.drawImage( image, 0, 0, _canvas.width, _canvas.height );
return canvas;
console.warn( 'THREE.WebGLRenderer: image is not power of two (' + image.width + 'x' + image.height + '). Resized to ' + _canvas.width + 'x' + _canvas.height, image );
return _canvas;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册