|
@@ -9,6 +9,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
var _isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && _gl instanceof WebGL2RenderingContext );
|
|
var _isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && _gl instanceof WebGL2RenderingContext );
|
|
var _videoTextures = {};
|
|
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 ) {
|
|
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;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|