diff --git a/js/cam/Cam.js b/js/cam/Cam.js index 4aad7f5e726c4cd5abea4c4658d1a3888a5b2ec8..a1588522b4e0a12c25739790e3bc9ae53cdb6bfa 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 59e21767f52704db3968401c6b6d00bdc75a6179..7e78d7ccef98a9ff15a336a145e359aa020a8a0c 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 7718c4bed1a1b5ebf729ceed9e3fddcee164ad29..25b611ddd93fe699390641140bc3f7a374a7cb06 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 3af063233213ec9e4138ddcac7608797a30c14f4..6ae114be96c1920a3b425641ab295e33e45786f4 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 9a4259c2e8bfab9652b0278fe020ce022bdb9b0c..b4074cec2317f3c431104ba6831bcd5c99bdd048 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