From a9d96921c1964219047db1be3f72cdd2e8838534 Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Fri, 14 Aug 2015 12:23:59 -0400
Subject: [PATCH] animation starting to work again

---
 js/cam/Cam.js                  |  2 +-
 js/cam/assemblers/Assembler.js | 25 +++++++++++++------------
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/js/cam/Cam.js b/js/cam/Cam.js
index 340b9d4f..b7ea7925 100644
--- a/js/cam/Cam.js
+++ b/js/cam/Cam.js
@@ -76,7 +76,7 @@ define(['underscore', 'three', 'backbone', 'appState', 'latticeCAM', 'threeModel
 //                    "change:cellType " +
 //                    "change:connectionType",
 //                this._setNeedsPostProcessing);
-//            this.listenTo(appState, "change:stockSimulationPlaying", this._stockSimulation);
+            this.listenTo(appState, "change:stockSimulationPlaying", this._stockSimulation);
 
             this.listenTo(lattice, "change:partType", this._updatePartType);
             this.listenTo(appState, "change:cellMode", this._updateCellMode);
diff --git a/js/cam/assemblers/Assembler.js b/js/cam/assemblers/Assembler.js
index 48289100..1e331a0c 100644
--- a/js/cam/assemblers/Assembler.js
+++ b/js/cam/assemblers/Assembler.js
@@ -138,7 +138,7 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
     
         lattice.rasterCells(cam._getOrder(cam.get("camStrategy")), function(cell){
             if (!cell) return;
-            if (this.stockAttachedToEndEffector){
+            if (!self.shouldPickUpStock){
                 data += self._postGetStock(exporter);
             } else {
                 var thisStockPosition = _.clone(stockPosition);
@@ -149,9 +149,10 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
                     if (stockNum >= stockArraySize.x * stockArraySize.y) stockNum = 0;
                 }
                 data += self._postMoveXY(exporter, stockPosition.x-wcs.x, stockPosition.y-wcs.y);
-                data += self._postPickUpStock(exporter, thisStockPosition, rapidHeight, wcs, safeHeight);
+                data += self._postMoveToStock(exporter, thisStockPosition, rapidHeight, wcs, safeHeight);
             }
-            var cellPosition = cell.getPosition();
+            var cellPosition = cell.getPosition();//todo cell.getAbsolutePosition();
+            console.log(cellPosition);
             data += self._postMoveXY(exporter, cellPosition.x-wcs.x, cellPosition.y-wcs.y);
             data += self._postReleaseStock(cellPosition, cell, exporter, rapidHeight, wcs, safeHeight);
             data += "\n";
@@ -163,7 +164,7 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
         return exporter.rapidXY(x, y);
     };
     
-    Assembler.prototype._postPickUpStock = function(exporter, stockPosition, rapidHeight, wcs, safeHeight){
+    Assembler.prototype._postMoveToStock = function(exporter, stockPosition, rapidHeight, wcs, safeHeight){
         var data = "";
         data += exporter.rapidZ(stockPosition.z-wcs.z+safeHeight);
         data += exporter.moveZ(stockPosition.z-wcs.z);
@@ -181,7 +182,7 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
         var data = "";
         data += exporter.rapidZ(cellPosition.z-wcs.z+safeHeight);
         data += exporter.moveZ(cellPosition.z-wcs.z);
-        data += exporter.addComment(JSON.stringify(cell.indices));
+        data += exporter.addComment(JSON.stringify(cell.index));
         data += exporter.moveZ(cellPosition.z-wcs.z+safeHeight);
         data += exporter.rapidZ(rapidHeight);
         return data;
@@ -232,11 +233,11 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
             if (totalThreads > 0) return;
             callback();
         }
-        var startingPos = {x:this.xAxis.getPosition(), y:this.yAxis.getPosition(), z:this.zAxis.getPosition()};
+        var startingPos = {x:this.components.xAxis.getPosition(), y:this.components.yAxis.getPosition(), z:this.components.zAxis.getPosition()};
         speed = this._normalizeSpeed(startingPos, x, y, this._reorganizeSpeed(speed));
-        this.xAxis.moveTo(this._makeAxisVector(x, "x"), speed.x, sketchyCallback);
-        this.yAxis.moveTo(this._makeAxisVector(y, "y"), speed.y, sketchyCallback);
-        this.zAxis.moveTo(this._makeAxisVector(z, "z"), speed.z, sketchyCallback);
+        this.components.xAxis.moveTo(this._makeAxisVector(x, "x"), speed.x, sketchyCallback);
+        this.components.yAxis.moveTo(this._makeAxisVector(y, "y"), speed.y, sketchyCallback);
+        this.components.zAxis.moveTo(this._makeAxisVector(z, "z"), speed.z, sketchyCallback);
     };
     
     Assembler.prototype._makeAbsPosition = function(target, wcs){
@@ -293,9 +294,9 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
         this.components = null;
         three.sceneRemove(this.object3D);
         this.stock = null;
-        this.zAxis = null;
-        this.xAxis = null;
-        this.yAxis = null;
+        this.components.zAxis = null;
+        this.components.xAxis = null;
+        this.components.yAxis = null;
         this.frame = null;
         this.substrate = null;
         this.object3D = null;
-- 
GitLab