Jelajahi Sumber

Support ImageDate Texture serialization

Takahiro 8 tahun lalu
induk
melakukan
aa8a76af47
1 mengubah file dengan 11 tambahan dan 1 penghapusan
  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 );
+
+				}
 
 			}