From bc60d28de354b993fd364cd9ec162b811b3eb1cc Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Tue, 18 Aug 2015 13:21:54 -0400 Subject: [PATCH] stock offset for stapler --- js/cam/Cam.js | 7 +++++++ js/cam/assemblers/Assembler.js | 10 +++++++++- js/cam/assemblers/Component.js | 4 ++++ js/cam/assemblers/StockComponent.js | 8 ++++++++ js/plists/CamPList.js | 6 +++++- 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/js/cam/Cam.js b/js/cam/Cam.js index 4aad7f5e..a1588522 100644 --- a/js/cam/Cam.js +++ b/js/cam/Cam.js @@ -109,6 +109,7 @@ define(['underscore', 'three', 'backbone', 'appState', 'latticeCAM', 'threeModel } var machineJSON = camPlist.allMachines[machineName]; if (machineJSON.defaults) this._setMachineDefaults(machineJSON.defaults); + if (machineJSON.lattice) this._setLatticeDefaults(machineJSON.lattice) var self = this; require(['assembler'], function(Assembler){ @@ -116,6 +117,12 @@ define(['underscore', 'three', 'backbone', 'appState', 'latticeCAM', 'threeModel }); }, + _setLatticeDefaults: function(defaults){ + _.each(defaults, function(value, key){ + lattice.set(key, value); + }); + }, + _setMachineDefaults: function(defaults){ var self = this; _.each(defaults, function(value, key){ diff --git a/js/cam/assemblers/Assembler.js b/js/cam/assemblers/Assembler.js index 59e21767..7e78d7cc 100644 --- a/js/cam/assemblers/Assembler.js +++ b/js/cam/assemblers/Assembler.js @@ -261,7 +261,15 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', ' Assembler.prototype._postReleaseStock = function(index, position, material, settings, exporter){ var data = ""; - if (material == "fiberGlass") position.x -= 26.1*settings.scale; + var stock = _.find(this.stock, function(thisStock){ + return thisStock.getMaterial() == material + }); + if (stock === undefined) { + console.warn("no stock defined of type " + material + " for this assembler"); + return data; + } + position.sub(stock.getPosition().multiplyScalar(settings.scale)); + position.sub(settings.originPosition); data += this._postMoveXY(position, settings, exporter); diff --git a/js/cam/assemblers/Component.js b/js/cam/assemblers/Component.js index 7718c4be..25b611dd 100644 --- a/js/cam/assemblers/Component.js +++ b/js/cam/assemblers/Component.js @@ -79,6 +79,10 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){ return this.id; }; + Component.prototype.getPosition = function(){ + return this.object3D.position.clone(); + }; + Component.prototype.setTranslucent = function(translucent){ if (this.stl === undefined) return; this.stl.material.transparent = translucent; diff --git a/js/cam/assemblers/StockComponent.js b/js/cam/assemblers/StockComponent.js index 3af06323..6ae114be 100644 --- a/js/cam/assemblers/StockComponent.js +++ b/js/cam/assemblers/StockComponent.js @@ -34,11 +34,19 @@ define(['underscore', 'cam', 'three', 'component', 'lattice', 'threeModel'], //todo rotation }; + StockComponent.prototype.getPosition = function(){ + return this.cell.getPosition(); + }; + StockComponent.prototype.setMaterial = function(materialName){ this.cell.changeMaterial(materialName); three.render(); }; + StockComponent.prototype.getMaterial = function(){ + return this.cell.getMaterialName(); + }; + diff --git a/js/plists/CamPList.js b/js/plists/CamPList.js index 9a4259c2..b4074cec 100644 --- a/js/plists/CamPList.js +++ b/js/plists/CamPList.js @@ -132,9 +132,13 @@ define(['three'], function(THREE){ }, name: "Stock 2", parent: "zAxis", - position: {x:26.1,y:0,z:0} + position: {x:26,y:0.236,z:0} } }, + lattice:{ + scale: 1.27, + units: 'mm' + }, defaults: { camStrategy: "raster", placementOrder: "XYZ",//used for raster strategy entry -- GitLab