From 5fc82bde59a3820b06e8985486371459a9d613ba Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Tue, 25 Aug 2015 16:29:18 -0400
Subject: [PATCH] eod

---
 js/cam/assemblers/FixedJoint.js     |  3 +
 js/cam/assemblers/PrismaticJoint.js |  3 +
 js/cam/assemblers/RevoluteJoint.js  |  3 +
 js/cam/assemblers/URDFJoint.js      | 93 +++++++++++++++++++++++++++++
 js/cam/assemblers/URDFLink.js       | 41 +++++++++++++
 js/main.js                          |  2 +
 js/plists/CamPList.js               |  9 +++
 js/plists/PList.js                  |  2 +-
 8 files changed, 155 insertions(+), 1 deletion(-)
 create mode 100644 js/cam/assemblers/FixedJoint.js
 create mode 100644 js/cam/assemblers/PrismaticJoint.js
 create mode 100644 js/cam/assemblers/RevoluteJoint.js
 create mode 100644 js/cam/assemblers/URDFJoint.js
 create mode 100644 js/cam/assemblers/URDFLink.js

diff --git a/js/cam/assemblers/FixedJoint.js b/js/cam/assemblers/FixedJoint.js
new file mode 100644
index 00000000..d986be6b
--- /dev/null
+++ b/js/cam/assemblers/FixedJoint.js
@@ -0,0 +1,3 @@
+/**
+ * Created by aghassaei on 8/25/15.
+ */
diff --git a/js/cam/assemblers/PrismaticJoint.js b/js/cam/assemblers/PrismaticJoint.js
new file mode 100644
index 00000000..d986be6b
--- /dev/null
+++ b/js/cam/assemblers/PrismaticJoint.js
@@ -0,0 +1,3 @@
+/**
+ * Created by aghassaei on 8/25/15.
+ */
diff --git a/js/cam/assemblers/RevoluteJoint.js b/js/cam/assemblers/RevoluteJoint.js
new file mode 100644
index 00000000..d986be6b
--- /dev/null
+++ b/js/cam/assemblers/RevoluteJoint.js
@@ -0,0 +1,3 @@
+/**
+ * Created by aghassaei on 8/25/15.
+ */
diff --git a/js/cam/assemblers/URDFJoint.js b/js/cam/assemblers/URDFJoint.js
new file mode 100644
index 00000000..8d48f67c
--- /dev/null
+++ b/js/cam/assemblers/URDFJoint.js
@@ -0,0 +1,93 @@
+/**
+ * Created by aghassaei on 8/25/15.
+ */
+
+
+define(['underscore', 'three'], function(_, THREE){
+
+    var num = 1;
+
+    function Joint(json){
+
+        this.object3D = new THREE.Object3D();
+
+        this._name = json.name || "Joint " + num++;
+        this._type = json.type || "prismatic";//revolute, continuous, prismatic, fixed, floating, planar
+
+
+
+        this.setParent(json.parent);
+        this._child = json.child;
+
+
+
+        this._origin = json.origin || new THREE.Vector3(0,0,0);//also euler rotation
+        this._axis = json.axis || new THREE.Vector3(1,0,0);
+
+        //this.limit
+
+    }
+
+    Joint.prototype.getName = function(){
+        return this._name;
+    };
+
+    Joint.prototype.setName = function(name){
+        this._name = name;
+    };
+
+    Joint.prototype.getType = function(){
+        return this._type;
+    };
+
+    Joint.prototype.setType = function(type){
+        this._type = type;
+        require([type.charAt(0).toUpperCase() + type.slice(1) + "Joint"], function(SubClass){
+            //init subclass
+        });
+
+    };
+
+    Joint.prototype.getParent = function(){
+        return this._parent;
+    };
+
+    Joint.prototype.setParent = function(parent){
+        if (this._parent === parent) return;
+        if (this._checkDescendants(parent)) {
+            console.warn("parent is already a child");
+            return;
+        }
+
+        this._parent = parent;
+    };
+
+    Joint.prototype._checkDescendants = function(parent){
+        if (this._child){
+            if (this._child === parent) return true;
+            else return this._child._checkDescendants(parent);
+        } else return false;
+    };
+
+    Joint.prototype.getChild = function(){
+        return this._child;
+    };
+
+    Joint.prototype.setChild = function(child){
+        this._child = child;
+    };
+
+    Joint.prototype.getObject3D = function(){
+        return this.object3D;
+    };
+
+
+
+    Joint.prototype.toJSON = function(){
+        return {
+
+        };
+    };
+
+    return Joint;
+});
\ No newline at end of file
diff --git a/js/cam/assemblers/URDFLink.js b/js/cam/assemblers/URDFLink.js
new file mode 100644
index 00000000..2c1d418d
--- /dev/null
+++ b/js/cam/assemblers/URDFLink.js
@@ -0,0 +1,41 @@
+/**
+ * Created by aghassaei on 8/25/15.
+ */
+
+
+define(['underscore', 'three'], function(_, THREE){
+
+    var num = 1;
+
+    function Link(json){
+
+        this._name = json.name || "Link " + num++;
+        this._origin = json.origin || new THREE.Vector3(0,0,0);//also euler rotation
+        this._axis = json.axis || new THREE.Vector3(1,0,0);
+
+        this.object3D = new THREE.Object3D();
+
+    }
+
+    Link.prototype.getName = function(){
+        return this._name;
+    };
+
+    Link.prototype.setName = function(name){
+        this._name = name;
+    };
+
+    Link.prototype.getObject3D = function(){
+        return this.object3D;
+    };
+
+
+
+    Link.prototype.toJSON = function(){
+        return {
+
+        };
+    };
+
+    return Link;
+});
\ No newline at end of file
diff --git a/js/main.js b/js/main.js
index 6c55137e..b9210064 100644
--- a/js/main.js
+++ b/js/main.js
@@ -193,6 +193,8 @@ require.config({
         assemblerPost: 'cam/assemblers/AssemblerPost',
         component: 'cam/assemblers/Component',
         stockComponent: 'cam/assemblers/StockComponent',
+        urdfJoint: 'cam/assemblers/URDFJoint',
+        urdfLink: 'cam/assemblers/URDfLink',
 
         //processes
         gcode: 'cam/processes/GCodeExporter',
diff --git a/js/plists/CamPList.js b/js/plists/CamPList.js
index 6d9e5b6a..b65812bc 100644
--- a/js/plists/CamPList.js
+++ b/js/plists/CamPList.js
@@ -185,6 +185,15 @@ define(['three'], function(THREE){
             }
         },
 
+        allJointTypes: {
+            revolute: "Revolute",
+            continuous: "Continuous",
+            prismatic: "Prismatic",
+            fixed: "Fixed",
+            floating: "Floating",
+            planar: "Planar"
+        },
+
         allAssemblyStrategies: {
             raster: "Raster"
         },
diff --git a/js/plists/PList.js b/js/plists/PList.js
index 58d70c30..6defac6a 100644
--- a/js/plists/PList.js
+++ b/js/plists/PList.js
@@ -67,7 +67,7 @@ define(['three'], function(THREE){
                 tabs:{
                     assembler:"Assembler",
                     assemblerSetup: "Setup",
-                    cam: "Process",
+                    cam: "Globals",
     //                editCamOutput: "Edit",
                     animate:"Preview"
                 },
-- 
GitLab