diff --git a/assets/stls/oneBitBot/foot1.stl b/assets/stls/oneBitBot/foot1.stl new file mode 100644 index 0000000000000000000000000000000000000000..b2e6d8be1b76eb4c90539b5910386ef94f64e8fe Binary files /dev/null and b/assets/stls/oneBitBot/foot1.stl differ diff --git a/assets/stls/oneBitBot/foot2.stl b/assets/stls/oneBitBot/foot2.stl new file mode 100644 index 0000000000000000000000000000000000000000..285a9abe693f23e995815ce6ed88c4da69919708 Binary files /dev/null and b/assets/stls/oneBitBot/foot2.stl differ diff --git a/js/cam/Assembler.js b/js/cam/Assembler.js index f409cb10b7faae17b61698aa681c382d81febbe0..7a6e56229a10b03b027a57c6680c3f0b35df16fe 100644 --- a/js/cam/Assembler.js +++ b/js/cam/Assembler.js @@ -88,6 +88,8 @@ Assembler = Backbone.Model.extend({ } else if (machineName == "handOfGod"){ this.set("machine", new God()); this.set("camProcess", "gcode"); + this.set("originPosition", {x:0,y:0,z:0}); + this.set("stockPosition", {x:0,y:0,z:50});//todo calculate a good stock position } else if (machineName == "oneBitBot"){ this.set("machine", new OneBitBot()); this.set("camProcess", "gcode"); diff --git a/js/cam/GCodeExporter.js b/js/cam/GCodeExporter.js index a4bd29602f6342910021cda5e9e2cbc27a27dfc7..dec78ede65b224d1705fa93c8a56683524594ccf 100644 --- a/js/cam/GCodeExporter.js +++ b/js/cam/GCodeExporter.js @@ -97,7 +97,7 @@ GCodeExporter.prototype.simulate = function(line, machine, wcs, callback){ } if (line.substr(0,3) == "G01"){ //return this._simulateGetPosition(line, dmaGlobals.assembler.get("feedRate"), machine, wcs, callback); - return this._simulateGetPosition(line, dmaGlobals.assembler.get("feedRate"), machine, wcs, callback); + return this._simulateGetPosition(line, dmaGlobals.assembler.get("rapidSpeeds"), machine, wcs, callback); } else { console.warn("problem parsing gcode: " + line); return callback(); diff --git a/js/cam/Machine.js b/js/cam/Machine.js index 87e8da80a4474c4ef170eff0e75a762705a4dce9..f999f713dcc8af2262046bcaf1f7e249fedc877d 100644 --- a/js/cam/Machine.js +++ b/js/cam/Machine.js @@ -8,6 +8,7 @@ function Machine() { this.hasStock = false; this.meshes = {}; + this.cell = this._makeStockCell(); var self = this; this._buildMeshes(function(meshes){ self.meshes = meshes; @@ -16,12 +17,14 @@ function Machine() { }); self.setVisibility(); }); - this.cell = this._makeStockCell(); this.setVisibility(false); } Machine.prototype.setVisibility = function(visible){ - if (visible == null || visible === undefined) visible = dmaGlobals.assembler.isVisible(); + if (visible == null || visible === undefined) { + if (dmaGlobals.assembler) visible = dmaGlobals.assembler.isVisible(); + else visible = false; + } if (visible && this.hasStock) this.cell.draw(); else this.cell.hide(); this._setMeshesVisiblity(visible); @@ -253,17 +256,7 @@ function God(){ God.prototype = Object.create(Machine.prototype); God.prototype._buildMeshes = function(callback){ - var meshes = {}; - (new THREE.STLLoader()).load("assets/stls/shopbot/shopbotEndEffector.stl", function(geometry){ - geometry.computeBoundingBox(); - var unitScale = 1.5/geometry.boundingBox.max.y; - geometry.applyMatrix(new THREE.Matrix4().makeScale(unitScale, unitScale, unitScale)); - geometry.applyMatrix(new THREE.Matrix4().makeTranslation(0,0, Math.sqrt(2)/2)); - var mesh = new THREE.Mesh(geometry, new THREE.MeshLambertMaterial({color:0xaaaaaa, shading: THREE.FlatShading})); - mesh.visible = false; - meshes.endEffector = mesh; - callback(meshes); - }); + callback({}); }; God.prototype._moveTo = function(x, y, z, speed, wcs, callback){ @@ -273,7 +266,7 @@ God.prototype._moveTo = function(x, y, z, speed, wcs, callback){ if (totalThreads > 0) return; callback(); } - var startingPos = this.meshes.endEffector.position.clone(); + var startingPos = this.cell.getPosition(); speed = this._normalizeSpeed(startingPos, x, y, this._reorganizeSpeed(speed)); this._moveAxis(startingPos.x, x, "x", speed.x, sketchyCallback); this._moveAxis(startingPos.y, y, "y", speed.y, sketchyCallback); @@ -285,7 +278,25 @@ God.prototype._moveAxis = function(startingPos, target, axis, speed, callback){ callback(); return; } - this._animateObjects([this.meshes.endEffector, this.cell], axis, speed, startingPos, target, callback); + this._animateObjects([this.cell], axis, speed, startingPos, target, callback); +}; + +God.prototype._postPickUpStock = function(exporter, stockPosition, rapidHeight, wcs, safeHeight){ + var data = ""; + data += exporter.moveZ(stockPosition.z-wcs.z); + return data; +}; + +God.prototype._postReleaseStock = function(cell, exporter, rapidHeight, wcs, safeHeight){ + var data = ""; + var cellPosition = cell.getPosition(); + data += exporter.rapidXY(cellPosition.x-wcs.x, cellPosition.y-wcs.y); + data += exporter.addComment("get stock"); + data += exporter.rapidZ(cellPosition.z-wcs.z+safeHeight); + data += exporter.moveZ(cellPosition.z-wcs.z); + data += exporter.addComment(JSON.stringify(cell.indices)); + data += exporter.moveZ(cellPosition.z-wcs.z+safeHeight); + return data; }; diff --git a/js/cam/MachineOneBit.js b/js/cam/MachineOneBit.js index 25947da95308269f37838a57223e7de1a6fe86ed..2e120f16ea30ea37139f47f342fc4bc517a1087e 100644 --- a/js/cam/MachineOneBit.js +++ b/js/cam/MachineOneBit.js @@ -9,7 +9,7 @@ OneBitBot.prototype = Object.create(Machine.prototype); OneBitBot.prototype._buildMeshes = function(callback){ var meshes = []; - var numMeshes = 4; + var numMeshes = 7; function allLoaded(){ numMeshes -= 1; return numMeshes <= 0; @@ -45,6 +45,18 @@ OneBitBot.prototype._buildMeshes = function(callback){ geometryScale(geometry); meshPrep(geometry, "basePlate"); }); + loader.load("assets/stls/oneBitBot/footMount1.stl", function(geometry){ + geometryScale(geometry); + meshPrep(geometry, "footMount1"); + }); + loader.load("assets/stls/oneBitBot/footMount2.stl", function(geometry){ + geometryScale(geometry); + meshPrep(geometry, "footMount2"); + }); + loader.load("assets/stls/oneBitBot/backFootMount.stl", function(geometry){ + geometryScale(geometry); + meshPrep(geometry, "backFootMount"); + }); }; OneBitBot.prototype._moveTo = function(x, y, z, speed, wcs, callback){ diff --git a/js/menus/AnimationMenuView.js b/js/menus/AnimationMenuView.js index a2597cbf9e5f81fd7f7d8bf2cdcc5551d9d38920..938f957282d337744230b61fd717bc8e536527d4 100644 --- a/js/menus/AnimationMenuView.js +++ b/js/menus/AnimationMenuView.js @@ -117,7 +117,7 @@ AnimationMenuView = Backbone.View.extend({ <a href="#" id="playStockSim" class=" btn btn-block btn-lg btn-success">Play</a>\ <% } %>\ <% } %>\ - <input id="speedSlider" data-slider-id="speedSlider" type="text" data-slider-min="1" data-slider-max="10" data-slider-step="1" data-slider-value="<%= simSpeed %>"/>\ + <input id="speedSlider" data-slider-id="speedSlider" type="text" data-slider-min="1" data-slider-max="20" data-slider-step="1" data-slider-value="<%= simSpeed %>"/>\ <br/><a href="#" id="saveSendMenu" class=" btn btn-block btn-lg btn-default">Save</a><br/>\ Assembly Time: <br/><br/>\ <% if (editsMadeToProgram && needsPostProcessing){ %>\ diff --git a/js/menus/AssemblerMenuView.js b/js/menus/AssemblerMenuView.js index a27e1aaea2ba2d8b4ff25e4c85be0fbf304531e3..5aa7e5eb5843becd642047cd9913b17c78242a5b 100644 --- a/js/menus/AssemblerMenuView.js +++ b/js/menus/AssemblerMenuView.js @@ -48,7 +48,7 @@ AssemblerMenuView = Backbone.View.extend({ _selectMachine: function(e){ e.preventDefault(); - this.assembler.set("MachineName", $(e.target).data("type")); + this.assembler.set("machineName", $(e.target).data("type")); }, render: function(){ diff --git a/js/models/AppState.js b/js/models/AppState.js index 7594d9b0406be7e2de238e1ae336ba8a26e64acf..996b413bfb3d24a1298e1e2a7af1184f2eda563e 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -91,6 +91,7 @@ AppState = Backbone.Model.extend({ edgeRot: { shopbot: "Shopbot", oneBitBot: "One Bit Bot", + oneBitBotLegs: "One Bit Bot with Legs", handOfGod: "Hand of God" }, vertex: {handOfGod: "Hand of God"} diff --git a/js/models/ThreeModel.js b/js/models/ThreeModel.js index 55eae6015a6a92c3a429bc69e61fc7f17b987c2f..f416c2ee87ea64452d417bb6552d8373d5f43e02 100644 --- a/js/models/ThreeModel.js +++ b/js/models/ThreeModel.js @@ -112,13 +112,12 @@ function ThreeModel(){ } function _loop(){ + _render(); if (stopAnimationFlag) { animationLoopRunning = false; console.log("animation stopped"); return; } -// console.log("loop"); - _render(); requestAnimationFrame(_loop); }