From 8fb4376871823337b7b80b4f87ffb6eaadceaecc Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Tue, 18 Aug 2015 20:22:39 -0400
Subject: [PATCH] rotation center on component

---
 js/cam/assemblers/Component.js                |  4 +++-
 js/menus/templates/EditComponentMenuView.html | 12 +++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/js/cam/assemblers/Component.js b/js/cam/assemblers/Component.js
index 25b611dd..8de54342 100644
--- a/js/cam/assemblers/Component.js
+++ b/js/cam/assemblers/Component.js
@@ -18,6 +18,7 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
         this.isStatic = json.isStatic;
         this.rotary = json.rotary;
         this.motionVector = new THREE.Vector3();
+        if (json.centerOfRotation) this.centerOfRotation = new THREE.Vector3(json.centerOfRotation.x, json.centerOfRotation.y, json.centerOfRotation.z);
         if (json.motionVector) this.motionVector.set(json.motionVector.x, json.motionVector.y, json.motionVector.z);
     }
 
@@ -219,7 +220,8 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
             rotation: this.object3D.rotation,
             isStatic: this.isStatic,
             rotary: this.rotary,
-            motionVector: this.motionVector
+            motionVector: this.motionVector,
+            centerOfRotation: this.centerOfRotation
         }
     };
 
diff --git a/js/menus/templates/EditComponentMenuView.html b/js/menus/templates/EditComponentMenuView.html
index 6bcdff9b..5d6c8ac5 100644
--- a/js/menus/templates/EditComponentMenuView.html
+++ b/js/menus/templates/EditComponentMenuView.html
@@ -44,11 +44,17 @@ Parent: &nbsp;&nbsp;
             <input id="isRotary" data-property="rotary" type="checkbox" <% if (thisComponent.rotary){ %> checked="checked"<% } %> value="" data-toggle="checkbox" class="component custom-checkbox">
             <span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>
             Rotary Axis (default is Linear)</label>
-            Vector (xyz):&nbsp;&nbsp;
+            Vector of Motion (xyz):<br/>
             <input data-property="motionVector" data-key="x" value="<%= thisComponent.motionVector.x %>" placeholder="X" class="form-control floatInput component" type="text">&nbsp;
             <input data-property="motionVector" data-key="y" value="<%= thisComponent.motionVector.y %>" placeholder="Y" class="form-control floatInput component" type="text">&nbsp;
-            <input data-property="motionVector" data-key="z" value="<%= thisComponent.motionVector.z %>" placeholder="Z" class="form-control floatInput component" type="text"><br/>
-            <!--Jog<br/>-->
+            <input data-property="motionVector" data-key="z" value="<%= thisComponent.motionVector.z %>" placeholder="Z" class="form-control floatInput component" type="text"><br/><br/>
+            <% if (thisComponent.rotary){ %>
+                Center of Rotation, relative to Origin (xyz):<br/>
+                <input data-property="centerOfRotation" data-key="x" value="<%= thisComponent.centerOfRotation.x %>" placeholder="X" class="form-control floatInput component" type="text">&nbsp;
+                <input data-property="centerOfRotation" data-key="y" value="<%= thisComponent.centerOfRotation.y %>" placeholder="Y" class="form-control floatInput component" type="text">&nbsp;
+                <input data-property="centerOfRotation" data-key="z" value="<%= thisComponent.centerOfRotation.z %>" placeholder="Z" class="form-control floatInput component" type="text"><br/><br/>
+            <% } %>
+            Jog: &nbsp;&nbsp;<br/>
         <% } %>
         <br/>
     <a id="uploadStl" href="#" class="btn btn-block btn-lg btn-default">Upload STL</a><br/>
-- 
GitLab