Просмотр исходного кода

Merge pull request #11595 from takahirox/ImageDataTextureSerialization

Support ImageDate Texture serialization
Mr.doob 8 лет назад
Родитель
Сommit
bbfcdb0b0f
1 измененных файлов с 11 добавлено и 1 удалено
  1. 11 1
      src/textures/Texture.js

+ 11 - 1
src/textures/Texture.js

@@ -135,7 +135,17 @@ Object.assign( Texture.prototype, EventDispatcher.prototype, {
 				canvas.width = image.width;
 				canvas.height = image.height;
 
-				canvas.getContext( '2d' ).drawImage( image, 0, 0, image.width, image.height );
+				var context = canvas.getContext( '2d' );
+
+				if ( image instanceof ImageData ) {
+
+					context.putImageData( image, 0, 0 );
+
+				} else {
+
+					context.drawImage( image, 0, 0, image.width, image.height );
+
+				}
 
 			}