diff --git a/js/cam/Assembler.js b/js/cam/Assembler.js index 7a6e56229a10b03b027a57c6680c3f0b35df16fe..780f734107d8b601ced2a6b82e6acb98aac06201 100644 --- a/js/cam/Assembler.js +++ b/js/cam/Assembler.js @@ -164,6 +164,7 @@ Assembler = Backbone.Model.extend({ var position = this.get("originPosition"); this.get("origin").position.set(position.x, position.y, position.z); dmaGlobals.three.render(); + if (this.get("machine").setMachinePosition) this.get("machine").setMachinePosition(); }, _moveStock: function(){ diff --git a/js/cam/Machine.js b/js/cam/Machine.js index f999f713dcc8af2262046bcaf1f7e249fedc877d..9b0096fc6e32b99b5deb3a19642148e3673ab3c1 100644 --- a/js/cam/Machine.js +++ b/js/cam/Machine.js @@ -15,6 +15,7 @@ function Machine() { _.each(_.values(meshes), function(mesh){ dmaGlobals.three.sceneAdd(mesh); }); + if (this.setMachinePosition) this.setMachinePosition(); self.setVisibility(); }); this.setVisibility(false); @@ -197,6 +198,7 @@ Machine.prototype.destroy = function(){ mesh = null; }); this.meshes = null; + this.position = null; }; diff --git a/js/cam/MachineOneBit.js b/js/cam/MachineOneBit.js index 2e120f16ea30ea37139f47f342fc4bc517a1087e..b1e2765102ac1a85237421f4df22eefd840e4c60 100644 --- a/js/cam/MachineOneBit.js +++ b/js/cam/MachineOneBit.js @@ -7,6 +7,18 @@ function OneBitBot(){ } OneBitBot.prototype = Object.create(Machine.prototype); +OneBitBot.prototype.setMachinePosition = function(){ + if (!dmaGlobals.assembler) return; + this.position = dmaGlobals.assembler.get("originPosition"); + var self = this; + _.each(_.values(this.meshes), function(mesh){ + mesh.position.x += self.position.x; + mesh.position.y += self.position.y; + mesh.position.z += self.position.z; + }); + dmaGlobals.three.render(); +}; + OneBitBot.prototype._buildMeshes = function(callback){ var meshes = []; var numMeshes = 7; @@ -66,6 +78,9 @@ OneBitBot.prototype._moveTo = function(x, y, z, speed, wcs, callback){ if (totalThreads > 0) return; callback(); } + x += this.position.x; + y += this.position.y; + z += this.position.z; var startingPos = this.meshes["zAxis"].position.clone(); speed = this._normalizeSpeed(startingPos, x, y, this._reorganizeSpeed(speed)); this._moveXAxis(startingPos.x, x, "x", speed.x, sketchyCallback);