Browse Source

Merge pull request #8403 from daoshengmu/fix_tga_flipY

Solve the bug of handling horizontal origin at TGA format header.
Mr.doob 9 years ago
parent
commit
574dc64a5a
2 changed files with 12 additions and 14 deletions
  1. 12 12
      examples/js/loaders/TGALoader.js
  2. 0 2
      examples/webgl_materials_texture_tga.html

+ 12 - 12
examples/js/loaders/TGALoader.js

@@ -390,36 +390,36 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
 				x_start = 0;
 				x_start = 0;
 				x_step = 1;
 				x_step = 1;
 				x_end = width;
 				x_end = width;
-				y_start = 0;
-				y_step = 1;
-				y_end = height;
+				y_start = height - 1;
+				y_step = -1;
+				y_end = -1;
 				break;
 				break;
 
 
 			case TGA_ORIGIN_BL:
 			case TGA_ORIGIN_BL:
 				x_start = 0;
 				x_start = 0;
 				x_step = 1;
 				x_step = 1;
 				x_end = width;
 				x_end = width;
-				y_start = height - 1;
-				y_step = - 1;
-				y_end = - 1;
+				y_start = 0;
+				y_step = 1;
+				y_end = height;
 				break;
 				break;
 
 
 			case TGA_ORIGIN_UR:
 			case TGA_ORIGIN_UR:
 				x_start = width - 1;
 				x_start = width - 1;
 				x_step = - 1;
 				x_step = - 1;
 				x_end = - 1;
 				x_end = - 1;
-				y_start = 0;
-				y_step = 1;
-				y_end = height;
+				y_start = height - 1;
+				y_step = -1;
+				y_end = -1;
 				break;
 				break;
 
 
 			case TGA_ORIGIN_BR:
 			case TGA_ORIGIN_BR:
 				x_start = width - 1;
 				x_start = width - 1;
 				x_step = - 1;
 				x_step = - 1;
 				x_end = - 1;
 				x_end = - 1;
-				y_start = height - 1;
-				y_step = - 1;
-				y_end = - 1;
+				y_start = 0;
+				y_step = 1;
+				y_end = height;
 				break;
 				break;
 
 
 		}
 		}

+ 0 - 2
examples/webgl_materials_texture_tga.html

@@ -77,7 +77,6 @@
 
 
 				// add box 1 - grey8 texture
 				// add box 1 - grey8 texture
 				var texture1 = loader.load( 'textures/crate_grey8.tga' );
 				var texture1 = loader.load( 'textures/crate_grey8.tga' );
-				texture1.flipY = true;
 
 
 				var material1 = new THREE.MeshPhongMaterial( { color: 0xffffff, map: texture1 } );
 				var material1 = new THREE.MeshPhongMaterial( { color: 0xffffff, map: texture1 } );
 
 
@@ -89,7 +88,6 @@
 
 
 				// add box 2 - tga texture
 				// add box 2 - tga texture
 				var texture2 = loader.load( 'textures/crate_color8.tga' );
 				var texture2 = loader.load( 'textures/crate_color8.tga' );
-				texture2.flipY = true;
 
 
 				var material2 = new THREE.MeshPhongMaterial( { color: 0xffffff, map: texture2 } );
 				var material2 = new THREE.MeshPhongMaterial( { color: 0xffffff, map: texture2 } );