Przeglądaj źródła

Editor: Fix usage of TGA textures. (#26316)

Michael Herzog 2 lat temu
rodzic
commit
aef2151780
1 zmienionych plików z 10 dodań i 6 usunięć
  1. 10 6
      editor/js/libs/ui.three.js

+ 10 - 6
editor/js/libs/ui.three.js

@@ -76,18 +76,22 @@ class UITexture extends UISpan {
 
 				reader.addEventListener( 'load', function ( event ) {
 
-					const canvas = new TGALoader().parse( event.target.result );
+					const loader = new TGALoader();
+					loader.load( event.target.result, function ( texture ) {
 
-					const texture = new THREE.CanvasTexture( canvas, mapping );
-					texture.sourceFile = file.name;
+						texture.colorSpace = THREE.SRGBColorSpace;
+						texture.sourceFile = file.name;
+
+						scope.setValue( texture );
 
-					scope.setValue( texture );
+						if ( scope.onChangeCallback ) scope.onChangeCallback( texture );
 
-					if ( scope.onChangeCallback ) scope.onChangeCallback( texture );
+
+					} );
 
 				}, false );
 
-				reader.readAsArrayBuffer( file );
+				reader.readAsDataURL( file );
 
 			} else if ( file.type.match( 'image.*' ) ) {