From 7cea57f0123d08cde8c2463a1a51f0809d5154c4 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Tue, 30 Jun 2015 14:39:17 -0700 Subject: [PATCH] eod --- js/cam/assemblers/Assembler.js | 12 ++++++------ js/cam/assemblers/Crab.js | 26 ++++++++++++++++++++++---- js/cam/assemblers/StaplerAssembler.js | 22 ---------------------- js/lattice/LatticeBase.js | 2 +- js/main.js | 1 - js/menus/AssemblerMenuView.js | 5 +++++ js/menus/CamMenuView.js | 5 +++++ js/menus/MenuWrapperView.js | 4 ++-- js/plists/PList.js | 15 +++++++++------ js/three/FillGeometry.js | 13 ++++++++----- 10 files changed, 58 insertions(+), 47 deletions(-) diff --git a/js/cam/assemblers/Assembler.js b/js/cam/assemblers/Assembler.js index b08fdab4..e53d0404 100644 --- a/js/cam/assemblers/Assembler.js +++ b/js/cam/assemblers/Assembler.js @@ -48,6 +48,12 @@ define(['underscore', 'appState', 'lattice', 'three', 'threeModel', 'cam', 'comp Assembler.prototype._setTranslucent = function(){ assemblerMaterial.transparent = (appState.get("currentTab") == "cam"); }; + + Assembler.prototype.moveMachine = function(){//origin selection + var origin = cam.get("originPosition"); + this.object3D.position.set(origin.x, origin.y, origin.z); + three.render(); + }; @@ -138,12 +144,6 @@ define(['underscore', 'appState', 'lattice', 'three', 'threeModel', 'cam', 'comp Assembler.prototype.pause = function(){ }; - Assembler.prototype.moveMachine = function(){ - var origin = cam.get("originPosition"); - this.object3D.position.set(origin.x, origin.y, origin.z); - three.render(); - }; - Assembler.prototype.moveTo = function(x, y, z, speed, wcs, callback){ x = this._makeAbsPosition(x, wcs.x); y = this._makeAbsPosition(y, wcs.y); diff --git a/js/cam/assemblers/Crab.js b/js/cam/assemblers/Crab.js index ee3b92b8..bfd0fe51 100644 --- a/js/cam/assemblers/Crab.js +++ b/js/cam/assemblers/Crab.js @@ -3,7 +3,7 @@ */ -define(['stlLoader', 'bin!crabSTL', 'threeModel'], function(THREE, geometry, three){ +define(['stlLoader', 'bin!assets/stls/crab/crab.stl', 'threeModel', 'assembler'], function(THREE, geometry, three, Assembler){ var loader = new THREE.STLLoader(); @@ -16,8 +16,26 @@ define(['stlLoader', 'bin!crabSTL', 'threeModel'], function(THREE, geometry, thr return geo; } - var mesh = new THREE.Mesh(unitGeo, new THREE.MeshLambertMaterial({color:0x777777, shading:THREE.FlatShading})); - three.sceneAdd(mesh); - three.render(); + function CrabAssembler(){ + this.stockAttachedToEndEffector = true;//no need for "stock position" + Assembler.call(this); + } + CrabAssembler.prototype = Object.create(Assembler.prototype); + + CrabAssembler.prototype._buildStock = function(){ + return null; +// return new StockClass({}); + }; + + CrabAssembler.prototype._configureAssemblerMovementDependencies = function(){ + this.object3D.add(this.frame.getObject3D()); + }; + + CrabAssembler.prototype._getSTLs = function(){ + return { + frame: unitGeo + } + }; + return CrabAssembler; }); \ No newline at end of file diff --git a/js/cam/assemblers/StaplerAssembler.js b/js/cam/assemblers/StaplerAssembler.js index e340f952..6c58aa87 100644 --- a/js/cam/assemblers/StaplerAssembler.js +++ b/js/cam/assemblers/StaplerAssembler.js @@ -62,28 +62,6 @@ define(['underscore', 'assembler', 'stlLoader', 'gikSuperCell', } }; - StaplerAssembler.prototype._moveXAxis = function(startingPos, target, axis, speed, callback){ - if (target == null || target === undefined) { - callback(); - return; - } - this._animateObjects([this.xAxis], axis, speed, startingPos, target, callback); - }; - StaplerAssembler.prototype._moveYAxis = function(startingPos, target, axis, speed, callback){ - if (target == null || target === undefined) { - callback(); - return; - } - this._animateObjects([this.yAxis], axis, speed, startingPos, target, callback); - }; - StaplerAssembler.prototype._moveZAxis = function(startingPos, target, axis, speed, callback){ - if (target == null || target === undefined) { - callback(); - return; - } - this._animateObjects([this.zAxis], axis, speed, startingPos, target, callback); - }; - return StaplerAssembler; }); \ No newline at end of file diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js index 6cdbccc7..ef6c404a 100644 --- a/js/lattice/LatticeBase.js +++ b/js/lattice/LatticeBase.js @@ -231,7 +231,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre if (!cells) { console.warn("no cells specified in matrix expansion"); - return; + cells = this.sparseCells; } if (!this.get("cellsMax") || !this.get("cellsMin")){ diff --git a/js/main.js b/js/main.js index b464bbbb..bb162098 100644 --- a/js/main.js +++ b/js/main.js @@ -167,7 +167,6 @@ require.config({ kennyTeqPartSTL: 'assets/stls/parts/KennyTeqPart.stl', kennyTeqPartHighResSTL: 'assets/stls/parts/KennyTeqPartHighRes.stl', samTeqPartSTL: 'assets/stls/parts/SamTeqPart.stl', - crabSTL: 'assets/stls/crab/crab.stl' }, diff --git a/js/menus/AssemblerMenuView.js b/js/menus/AssemblerMenuView.js index 4de97b64..dcac5a1f 100644 --- a/js/menus/AssemblerMenuView.js +++ b/js/menus/AssemblerMenuView.js @@ -15,6 +15,11 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'cam', 'lattice', 'text!a this.listenTo(cam, "change", this.render);//todo handle this in wrapper $(document).bind('keyup', {}, this._onKeyup); }, + + getPropertyOwner: function($target){ + if ($target.hasClass("assembler")) return cam; + return null; + }, _onKeyup: function(e){ if (this.model.get("currentTab") != "assembler") return; diff --git a/js/menus/CamMenuView.js b/js/menus/CamMenuView.js index 851ea2ec..a8e77198 100644 --- a/js/menus/CamMenuView.js +++ b/js/menus/CamMenuView.js @@ -19,6 +19,11 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'cam', 'lattice', 'text!c this.listenTo(lattice, "change", this.render); }, + getPropertyOwner: function($target){ + if ($target.hasClass("assembler")) return cam; + return null; + }, + _selectOrigin: function(e){ e.preventDefault(); this.model.set("manualSelectOrigin", !this.model.get("manualSelectOrigin")); diff --git a/js/menus/MenuWrapperView.js b/js/menus/MenuWrapperView.js index 5b509a8c..17f8b42d 100644 --- a/js/menus/MenuWrapperView.js +++ b/js/menus/MenuWrapperView.js @@ -161,7 +161,6 @@ define(['jquery', 'underscore', 'plist', 'backbone', 'lattice', 'appState', 'tex _getPropertyOwner: function($target){ if ($target.hasClass("lattice")) return lattice; - if ($target.hasClass("assembler")) return globals.cam; if ($target.hasClass("appState")) return this.model; if (this.menu) { var owner = this.menu.getPropertyOwner($target); @@ -186,9 +185,10 @@ define(['jquery', 'underscore', 'plist', 'backbone', 'lattice', 'appState', 'tex return; } if (key){ + console.log(this._getOwnerProperty(owner, property)); var propObject = this._getOwnerProperty(owner, property).clone(); propObject[key] = newVal; - this._setOwnerProperty(owner, property, newVal); + this._setOwnerProperty(owner, property, propObject); } else { this._setOwnerProperty(owner, property, newVal); } diff --git a/js/plists/PList.js b/js/plists/PList.js index 969fc919..c01abc06 100644 --- a/js/plists/PList.js +++ b/js/plists/PList.js @@ -209,10 +209,11 @@ define(['three'], function(THREE){ octa:{ face: {handOfGod: "Hand of God"}, edgeRot: { + crab: "Crab", shopbot: "Shopbot", - oneBitBot: "One Bit Bot", - oneBitBotLegs: "One Bit Bot with Legs", - handOfGod: "Hand of God" + oneBitBot: "One Bit Bot", + oneBitBotLegs: "One Bit Bot with Legs", + handOfGod: "Hand of God" }, vertex: {handOfGod: "Hand of God"} }, @@ -247,7 +248,8 @@ define(['three'], function(THREE){ tinyG: "TinyG" }, stapler: {gcode: "G-Code"}, - staplerDual: {gcode: "G-Code"} + staplerDual: {gcode: "G-Code"}, + crab: {gcode: "G-Code"} }, allMachineDefaults: { @@ -264,7 +266,8 @@ define(['three'], function(THREE){ originPosition: new THREE.Vector3(0,0,0), rapidSpeeds:{xy: 3, z: 2}, feedRate:{xy: 0.1, z: 0.1} - } + }, + crab: null }, allScripts: { @@ -273,7 +276,7 @@ define(['three'], function(THREE){ allUnitTypes: { inches: "Inches", - mm: "mm" + mm: "mm" //um: "micron" } diff --git a/js/three/FillGeometry.js b/js/three/FillGeometry.js index de91c17c..6cab1f0a 100644 --- a/js/three/FillGeometry.js +++ b/js/three/FillGeometry.js @@ -35,6 +35,7 @@ define(['three', 'underscore', 'backbone', 'lattice', 'threeModel'], opacity:0.4, side:THREE.DoubleSide })); + mesh.position.set(0,0,-0.5); this.set({mesh: mesh}); three.sceneAdd(mesh); three.render(); @@ -44,13 +45,14 @@ define(['three', 'underscore', 'backbone', 'lattice', 'threeModel'], var boundingBox = this.get("mesh").geometry.boundingBox; var scale = this.get("scale"); - var scaledMin = boundingBox.min.clone().multiplyScalar(scale); + var offset = this.get("mesh").position.clone(); + console.log(offset); + var scaledMin = boundingBox.min.clone().multiplyScalar(scale);//.add(offset) var scaledMax = boundingBox.max.clone().multiplyScalar(scale); - console.log(scaledMin); - console.log(scaledMax); var minIndex = lattice.getIndexForPosition(scaledMin); var maxIndex = lattice.getIndexForPosition(scaledMax); + minIndex.z -= 1; console.log(minIndex); console.log(maxIndex); lattice.checkForMatrixExpansion(null, maxIndex, minIndex);//expand cells matrix before @@ -73,15 +75,16 @@ define(['three', 'underscore', 'backbone', 'lattice', 'threeModel'], for (var z=minIndex.z;z<=maxIndex.z;z++){ var index = new THREE.Vector3(x, y, z); var position = lattice.getPositionForIndex(index); + index.z -= 1; if (!inside){ if (position.z<nextIntersection) continue; else { inside = true; - lattice.getUItarget().addCellAtIndex(index, true, true); + lattice.addCellAtIndex(index, true, true); } } else { if (position.z<nextIntersection) { - lattice.getUItarget().addCellAtIndex(index, true, true); + lattice.addCellAtIndex(index, true, true); continue; } else inside = false; -- GitLab