Browse Source

Merge pull request #6775 from dubejf/transformctrls

TransformControls: undefined intersection
Ricardo Cabello 10 years ago
parent
commit
51da9b992e
1 changed files with 16 additions and 10 deletions
  1. 16 10
      examples/js/controls/TransformControls.js

+ 16 - 10
examples/js/controls/TransformControls.js

@@ -795,16 +795,20 @@
 
 
 					var planeIntersect = intersectObjects( pointer, [ scope.gizmo[_mode].activePlane ] );
 					var planeIntersect = intersectObjects( pointer, [ scope.gizmo[_mode].activePlane ] );
 
 
-					oldPosition.copy( scope.object.position );
-					oldScale.copy( scope.object.scale );
+					if ( planeIntersect ) {
 
 
-					oldRotationMatrix.extractRotation( scope.object.matrix );
-					worldRotationMatrix.extractRotation( scope.object.matrixWorld );
+						oldPosition.copy( scope.object.position );
+						oldScale.copy( scope.object.scale );
 
 
-					parentRotationMatrix.extractRotation( scope.object.parent.matrixWorld );
-					parentScale.setFromMatrixScale( tempMatrix.getInverse( scope.object.parent.matrixWorld ) );
+						oldRotationMatrix.extractRotation( scope.object.matrix );
+						worldRotationMatrix.extractRotation( scope.object.matrixWorld );
 
 
-					offset.copy( planeIntersect.point );
+						parentRotationMatrix.extractRotation( scope.object.parent.matrixWorld );
+						parentScale.setFromMatrixScale( tempMatrix.getInverse( scope.object.parent.matrixWorld ) );
+
+						offset.copy( planeIntersect.point );
+
+					}
 
 
 				}
 				}
 
 
@@ -818,13 +822,15 @@
 
 
 			if ( scope.object === undefined || scope.axis === null || _dragging === false ) return;
 			if ( scope.object === undefined || scope.axis === null || _dragging === false ) return;
 
 
-			event.preventDefault();
-			event.stopPropagation();
-
 			var pointer = event.changedTouches ? event.changedTouches[0] : event;
 			var pointer = event.changedTouches ? event.changedTouches[0] : event;
 
 
 			var planeIntersect = intersectObjects( pointer, [ scope.gizmo[_mode].activePlane ] );
 			var planeIntersect = intersectObjects( pointer, [ scope.gizmo[_mode].activePlane ] );
 
 
+			if ( planeIntersect === false ) return;
+
+			event.preventDefault();
+			event.stopPropagation();
+
 			point.copy( planeIntersect.point );
 			point.copy( planeIntersect.point );
 
 
 			if ( _mode == "translate" ) {
 			if ( _mode == "translate" ) {