Browse Source

Editor: Changed the snapping code for my own peace of mind :P

Mr.doob 12 năm trước cách đây
mục cha
commit
69bc8aa04a
1 tập tin đã thay đổi với 3 bổ sung3 xóa
  1. 3 3
      editor/js/ui/Viewport.js

+ 3 - 3
editor/js/ui/Viewport.js

@@ -148,9 +148,9 @@ var Viewport = function ( signals ) {
 			var point = intersects[ 0 ].point.sub( offset );
 
 			if (snapDist) {
-				point.x = point.x - point.x % snapDist;
-				point.y = point.y - point.y % snapDist;
-				point.z = point.z - point.z % snapDist;
+				point.x = Math.round( point.x / snapDist ) * snapDist;
+				point.y = Math.round( point.y / snapDist ) * snapDist;
+				point.z = Math.round( point.z / snapDist ) * snapDist;
 			}
 
 			selected.position.x = modifierAxis.x === 1 ? point.x : intersectionPlane.position.x;