@@ -2731,7 +2731,7 @@ THREE.WebGLRenderer = function ( parameters ) {
2731
2731
}
2732
2732
2733
2733
var image = texture . image ,
2734
- isImagePowerOfTwo = isPowerOfTwo ( image ) , // TODO: Always true at this step?
2734
+ isImagePowerOfTwo = isPowerOfTwo ( image ) ,
2735
2735
glFormat = paramThreeToGL ( texture . format ) ,
2736
2736
glType = paramThreeToGL ( texture . type ) ;
2737
2737
@@ -2898,16 +2898,22 @@ THREE.WebGLRenderer = function ( parameters ) {
2898
2898
2899
2899
function makePowerOfTwo ( image ) {
2900
2900
2901
- var canvas = document . createElement ( 'canvas' ) ;
2902
- canvas . width = THREE . Math . nearestPowerOfTwo ( image . width ) ;
2903
- canvas . height = THREE . Math . nearestPowerOfTwo ( image . height ) ;
2901
+ if ( image instanceof HTMLImageElement || image instanceof HTMLCanvasElement ) {
2904
2902
2905
- var context = canvas . getContext ( '2d' ) ;
2906
- context . drawImage ( image , 0 , 0 , canvas . width , canvas . height ) ;
2903
+ var canvas = document . createElement ( 'canvas' ) ;
2904
+ canvas . width = THREE . Math . nearestPowerOfTwo ( image . width ) ;
2905
+ canvas . height = THREE . Math . nearestPowerOfTwo ( image . height ) ;
2906
+
2907
+ var context = canvas . getContext ( '2d' ) ;
2908
+ context . drawImage ( image , 0 , 0 , canvas . width , canvas . height ) ;
2909
+
2910
+ console . warn ( 'THREE.WebGLRenderer: image is not power of two (' + image . width + 'x' + image . height + '). Resized to ' + canvas . width + 'x' + canvas . height , image ) ;
2907
2911
2908
- console . warn ( 'THREE.WebGLRenderer: image is not power of two (' + image . width + 'x' + image . height + '). Resized to ' + canvas . width + 'x' + canvas . height , image ) ;
2912
+ return canvas ;
2913
+
2914
+ }
2909
2915
2910
- return canvas ;
2916
+ return image ;
2911
2917
2912
2918
}
2913
2919
0 commit comments