Browse Source

Matrix4 clean up. Workaround for Android's browser touch event bug.

Mr.doob 15 years ago
parent
commit
d7c890eab8

File diff suppressed because it is too large
+ 0 - 0
build/three.js


+ 5 - 18
examples/geometry/cube.html

@@ -23,7 +23,6 @@
 
 			var SCREEN_WIDTH = window.innerWidth;
 			var SCREEN_HEIGHT = window.innerHeight;
-			var AMOUNT = 100;
 
 			var container;
 			var stats;
@@ -59,7 +58,7 @@
 				info.innerHTML = 'Drag to spin the cube';
 				container.appendChild(info);
 			
-				camera = new Camera(0, 150, 300);
+				camera = new Camera(0, 150, 400);
 				camera.focus = 300;
 				camera.target.y = 150;
 				camera.updateMatrix();
@@ -95,12 +94,15 @@
 				
 				document.addEventListener('mousedown', onDocumentMouseDown, false);
 				document.addEventListener('touchstart', onDocumentTouchStart, false);
+				document.addEventListener('touchmove', onDocumentTouchMove, false);
 			}
 
 			//
 
 			function onDocumentMouseDown( event )
 			{
+				event.preventDefault();
+				
 				document.addEventListener('mousemove', onDocumentMouseMove, false);
 				document.addEventListener('mouseup', onDocumentMouseUp, false);
 				
@@ -123,15 +125,12 @@
 			
 			function onDocumentTouchStart( event )
 			{
-				if(event.touches.length > 1)
+				if(event.touches.length == 1)
 				{
 					event.preventDefault();
 
 					mouseXOnMouseDown = event.touches[0].pageX - windowHalfX;
 					targetRotationOnMouseDown = targetRotation;
-
-					document.addEventListener('touchmove', onDocumentTouchMove, false);
-					document.addEventListener('touchend', onDocumentTouchEnd, false);
 				}
 			}
 
@@ -142,22 +141,10 @@
 					event.preventDefault();
 					
 					mouseX = event.touches[0].pageX - windowHalfX;
-					
 					targetRotation = targetRotationOnMouseDown + (mouseX - mouseXOnMouseDown) * 0.05;
 				}
 			}
 
-			function onDocumentTouchEnd( event )
-			{
-				if(event.touches.length == 0)
-				{
-					event.preventDefault();
-
-					document.removeEventListener('touchmove', onDocumentTouchMove, false);
-					document.removeEventListener('touchend', onDocumentTouchEnd, false);
-				}
-			}			
-
 			//
 
 			function loop()

+ 1 - 14
examples/particles/floor.html

@@ -85,6 +85,7 @@
 				
 				document.addEventListener('mousemove', onDocumentMouseMove, false);
 				document.addEventListener('touchstart', onDocumentTouchStart, false);
+				document.addEventListener('touchmove', onDocumentTouchMove, false);
 			}
 
 			//
@@ -103,9 +104,6 @@
 
 					mouseX = event.touches[0].pageX - windowHalfX;
 					mouseY = event.touches[0].pageY - windowHalfY;
-
-					document.addEventListener('touchmove', onDocumentTouchMove, false);
-					document.addEventListener('touchend', onDocumentTouchEnd, false);
 				}
 			}
 
@@ -119,17 +117,6 @@
 					mouseY = event.touches[0].pageY - windowHalfY;
 				}
 			}
-
-			function onDocumentTouchEnd( event )
-			{
-				if(event.touches.length == 0)
-				{
-					event.preventDefault();
-
-					document.removeEventListener('touchmove', onDocumentTouchMove, false);
-					document.removeEventListener('touchend', onDocumentTouchEnd, false);
-				}
-			}
 			
 			//
 

+ 1 - 14
examples/particles/random.html

@@ -75,6 +75,7 @@
 				
 				document.addEventListener('mousemove', onDocumentMouseMove, false);
 				document.addEventListener('touchstart', onDocumentTouchStart, false);
+				document.addEventListener('touchmove', onDocumentTouchMove, false);
 			}
 
 			//
@@ -93,9 +94,6 @@
 
 					mouseX = event.touches[0].pageX - windowHalfX;
 					mouseY = event.touches[0].pageY - windowHalfY;
-
-					document.addEventListener('touchmove', onDocumentTouchMove, false);
-					document.addEventListener('touchend', onDocumentTouchEnd, false);
 				}
 			}
 
@@ -109,17 +107,6 @@
 					mouseY = event.touches[0].pageY - windowHalfY;
 				}
 			}
-
-			function onDocumentTouchEnd( event )
-			{
-				if(event.touches.length == 0)
-				{
-					event.preventDefault();
-
-					document.removeEventListener('touchmove', onDocumentTouchMove, false);
-					document.removeEventListener('touchend', onDocumentTouchEnd, false);
-				}
-			}
 			
 			//
 

+ 1 - 14
examples/particles/waves.html

@@ -89,6 +89,7 @@
 				
 				document.addEventListener('mousemove', onDocumentMouseMove, false);
 				document.addEventListener('touchstart', onDocumentTouchStart, false);
+				document.addEventListener('touchmove', onDocumentTouchMove, false);				
 			}
 
 			//
@@ -107,9 +108,6 @@
 
 					mouseX = event.touches[0].pageX - windowHalfX;
 					mouseY = event.touches[0].pageY - windowHalfY;
-
-					document.addEventListener('touchmove', onDocumentTouchMove, false);
-					document.addEventListener('touchend', onDocumentTouchEnd, false);
 				}
 			}
 
@@ -123,17 +121,6 @@
 					mouseY = event.touches[0].pageY - windowHalfY;
 				}
 			}
-
-			function onDocumentTouchEnd( event )
-			{
-				if(event.touches.length == 0)
-				{
-					event.preventDefault();
-
-					document.removeEventListener('touchmove', onDocumentTouchMove, false);
-					document.removeEventListener('touchend', onDocumentTouchEnd, false);
-				}
-			}
 			
 			//
 

+ 0 - 27
src/core/Matrix4.js

@@ -171,30 +171,3 @@ Matrix4.rotationZMatrix = function(theta)
 
 	return rot;
 }
-
-Matrix4.rotationMatrix = function(ry, rx, rz)
-{
-	var sx, sy, sz;
-	var cx, cy, cz;
-
-	sx = Math.sin(rx);
-	sy = Math.sin(ry);
-	sz = Math.sin(rz);
-	cx = Math.cos(rx);
-	cy = Math.cos(ry);
-	cz = Math.cos(rz);
-
-	var rot = new Matrix4();
-
-	rot.n11 = cx * cz - sx * sy * sz;
-	rot.n12 = -cy * sz;
-	rot.n13 = sx * cz + cx * sy * sz;
-	rot.n21 = cx * sz + sx * sy * cz;
-	rot.n22 = cy * cz;
-	rot.n23 = sx * sz - cx * sy * cz;
-	rot.n31 = -sx * cy;
-	rot.n32 = sy;
-	rot.n33 = cx * cy;
-
-	return rot;
-}

Some files were not shown because too many files changed in this diff