浏览代码

Ninja-hack to make minecraft AO example working again after big deflipping.

Don't try this at home kids. Finally had to do it like this, alternative was just getting slowly insane (I spent lot of time on futile attempts to make it in the "right" way, it doesn't even show any texture with UNPACK_FLIP_Y_WEBGL toggled on).
alteredq 13 年之前
父节点
当前提交
e5ad64e8fe
共有 1 个文件被更改,包括 20 次插入2 次删除
  1. 20 2
      examples/webgl_geometry_minecraft_ao.html

+ 20 - 2
examples/webgl_geometry_minecraft_ao.html

@@ -375,6 +375,20 @@
 
 
 						cube = new THREE.CubeGeometry( 100, 100, 100, 1, 1, 1, materials, sides );
 						cube = new THREE.CubeGeometry( 100, 100, 100, 1, 1, 1, materials, sides );
 
 
+						// revert back to old flipped UVs
+
+						for ( i = 0; i < cube.faceVertexUvs[ 0 ].length; i ++ ) {
+
+							uv = cube.faceVertexUvs[ 0 ][ i ];
+
+							for ( j = 0; j < uv.length; j++ ) {
+
+								uv[j].v = 1 - uv[j].v;
+
+							}
+
+						}
+
 						// set UV tiles
 						// set UV tiles
 
 
 						for ( i = 0; i < cube.faceVertexUvs[ 0 ].length; i ++ ) {
 						for ( i = 0; i < cube.faceVertexUvs[ 0 ].length; i ++ ) {
@@ -496,6 +510,7 @@
 				canvas.width = canvas.height = size;
 				canvas.width = canvas.height = size;
 
 
 				var texture = new THREE.Texture( canvas, new THREE.UVMapping(), THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping, THREE.NearestFilter, THREE.LinearMipMapLinearFilter );
 				var texture = new THREE.Texture( canvas, new THREE.UVMapping(), THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping, THREE.NearestFilter, THREE.LinearMipMapLinearFilter );
+				texture.flipY = false;
 
 
 				function generateTexture() {
 				function generateTexture() {
 
 
@@ -535,6 +550,7 @@
 				canvas.width = canvas.height = size;
 				canvas.width = canvas.height = size;
 
 
 				var texture = new THREE.Texture( canvas, new THREE.UVMapping(), THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping, THREE.NearestFilter, THREE.LinearMipMapLinearFilter );
 				var texture = new THREE.Texture( canvas, new THREE.UVMapping(), THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping, THREE.NearestFilter, THREE.LinearMipMapLinearFilter );
+				texture.flipY = false;
 
 
 				function generateTexture() {
 				function generateTexture() {
 
 
@@ -563,6 +579,7 @@
 				return new THREE.MeshLambertMaterial( { map: texture } );
 				return new THREE.MeshLambertMaterial( { map: texture } );
 
 
 			}
 			}
+
 			function generateMegamaterialDebug() {
 			function generateMegamaterialDebug() {
 
 
 				var canvas = document.createElement( 'canvas' ),
 				var canvas = document.createElement( 'canvas' ),
@@ -576,9 +593,9 @@
 				ctx.textBaseline = "top";
 				ctx.textBaseline = "top";
 				ctx.font = "8pt arial";
 				ctx.font = "8pt arial";
 
 
-				for ( i = 0; i < tile; i++ ) {
+				for ( i = 0; i < tile; i ++ ) {
 
 
-					for ( j = 0; j < tile; j++ ) {
+					for ( j = 0; j < tile; j ++ ) {
 
 
 						h = i * tile + j;
 						h = i * tile + j;
 						ctx.fillStyle = "hsl(" + h + ",90%, 50%)";
 						ctx.fillStyle = "hsl(" + h + ",90%, 50%)";
@@ -645,6 +662,7 @@
 					ctx.fillRect( sx + a * i, sy + b * i, width, height );
 					ctx.fillRect( sx + a * i, sy + b * i, width, height );
 
 
 				}
 				}
+
 			}
 			}
 
 
 			function drawAOSides( ctx, image, row, column, sides, tile, strength, debug_texture, debug_numbers ) {
 			function drawAOSides( ctx, image, row, column, sides, tile, strength, debug_texture, debug_numbers ) {