diff --git a/js/cam/Assembler.js b/js/cam/Assembler.js index b784ecc074b8b3b445afff2ee4fcab78cf2b4583..bc4a713a2da73c1025c47ce14e8383058f17b7f3 100644 --- a/js/cam/Assembler.js +++ b/js/cam/Assembler.js @@ -7,7 +7,7 @@ Assembler = Backbone.Model.extend({ defaults: { camStrategy: "raster", placementOrder: "XYZ",//used for raster strategy entry - camProcess: "shopbot", + camProcess: "gcode", machineName: "shopbot", machine: null, exporter: null, diff --git a/js/fea/DmaBeam.js b/js/fea/DmaBeam.js index b5cbb9e3b4d362110f5b1465106a6d0ca139f3c9..a32fccdc07a921ea13776c101ff1d67c6e1b5171 100644 --- a/js/fea/DmaBeam.js +++ b/js/fea/DmaBeam.js @@ -35,7 +35,7 @@ DmaBeam.prototype._buildBeamMesh = function(){ var eulerRot = new THREE.Euler().setFromQuaternion(quaternion); mesh.rotation.set(eulerRot.x, eulerRot.y, eulerRot.z); - dmaGlobals.three.sceneAdd(mesh, "part"); + dmaGlobals.three.sceneAdd(mesh);//todo make a type for this return mesh; }; @@ -43,8 +43,8 @@ DmaBeam.prototype.updateForScale = function(scale){//todo make this better if (!this.mesh) this.mesh = this._buildBeamMesh(); var position = this.nodes[0].getPosition(); position.add(this.nodes[1].getPosition()); - position.multiplyScalar(0.5); position.add(this.parentCell.getPosition()); + console.log(this.nodes[1].getPosition()); this.mesh.position.set(position.x, position.y, position.z); this.mesh.scale.set(scale, scale, scale); }; diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index fbf413b131135b0a483921a4c990259f178f0bd1..c3ce1fd712c227cfd74877110dec3e4c05cb561e 100644 --- a/js/fea/DmaCell.js +++ b/js/fea/DmaCell.js @@ -19,9 +19,6 @@ function DMACell(indices, scale, cellMode, partType) { if (!indices) sceneType = null; dmaGlobals.three.sceneAdd(this.cellMesh,sceneType); - this.nodes = this._initNodes(this.cellMesh.children[0].geometry.vertices); - this.beams = this._initBeams(this.nodes, this.cellMesh.children[0].geometry.faces); - this.draw(scale, cellMode, partType); } @@ -30,21 +27,27 @@ DMACell.prototype.draw = function(scale, cellMode, partType){ if (!scale) scale = dmaGlobals.lattice.get("scale"); if (!cellMode) cellMode = dmaGlobals.appState.get("cellMode"); if (!partType) partType = dmaGlobals.lattice.get("partType"); - var beamMode = partType == "beam"; - - //init parts if needed - if (!beamMode && cellMode == "part" && !this.parts) this.parts = this._initParts(); + //var beamMode = partType == "beam"; + var beamMode = false; + var partMode = cellMode == "part"; + + //init parts/beams if needed + if (partMode &&!beamMode && !this.parts) this.parts = this._initParts(); + if (beamMode && !this.beams) { + this.nodes = this._initNodes(this.cellMesh.children[0].geometry.vertices); + this.beams = this._initBeams(this.nodes, this.cellMesh.children[0].geometry.faces); + } //update scale this.updateForScale(scale, cellMode, partType); //set visibility - this._setCellMeshVisibility(cellMode == "cell"); + this._setCellMeshVisibility(!partMode); _.each(this.parts, function(part){ - if (part) part.setVisibility(cellMode == "part" && !beamMode); + if (part) part.setVisibility(partMode && !beamMode); }); _.each(this.beams, function(beam){ - beam.setVisibility(beamMode && cellMode == "part"); + beam.setVisibility(beamMode && partMode); }); }; @@ -58,37 +61,19 @@ DMACell.prototype.hide = function(){ }); }; -DMACell.prototype.destroyParts = function(){ - _.each(this.parts, function(part){ - if (part) part.destroy(); - }); - this.parts = null; -}; - -DMACell.prototype._buildCellMesh = function(material){//called from every subclass - var unitCellGeo = this._getGeometry(); - if (!material) material = cellMaterials; - var mesh = THREE.SceneUtils.createMultiMaterialObject(unitCellGeo, material); - mesh.myParent = this;//we need a reference to this instance from the mesh for intersection selection stuff - return mesh; -}; - -DMACell.prototype._doMeshTransformations = function(mesh){};//by default, no mesh transformations - /////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////SCALE/POSITION//////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// DMACell.prototype.updateForScale = function(scale, cellMode, partType){ if (!scale) scale = dmaGlobals.lattice.get("scale"); - if (!cellMode) cellMode = dmaGlobals.appState.get("cellMode"); - if (!partType) partType = dmaGlobals.lattice.get("partType"); - var position = this._calcPosition(); this._setMeshPosition(this.cellMesh, position); - this.cellMesh.scale.set(scale, scale, scale);//must do this so highlighting works properly in part mode + //only update visible object to scale + if (!cellMode) cellMode = dmaGlobals.appState.get("cellMode"); + if (!partType) partType = dmaGlobals.lattice.get("partType"); if (cellMode == "part"){ if (partType == "beam"){ _.each(this.beams, function(beam){ @@ -102,7 +87,6 @@ DMACell.prototype.updateForScale = function(scale, cellMode, partType){ } }; - DMACell.prototype._setMeshPosition = function(mesh, position){ mesh.position.x = position.x; mesh.position.y = position.y; @@ -155,10 +139,37 @@ DMACell.prototype.zScale = function(scale){ /////////////////////////////////META////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// +DMACell.prototype._buildCellMesh = function(material){//called from every subclass + var unitCellGeo = this._getGeometry(); + if (!material) material = cellMaterials; + var mesh = THREE.SceneUtils.createMultiMaterialObject(unitCellGeo, material); + mesh.myParent = this;//we need a reference to this instance from the mesh for intersection selection stuff + return mesh; +}; + +DMACell.prototype._doMeshTransformations = function(mesh){};//by default, no mesh transformations + DMACell.prototype._initParts = function(){ return [];//override in subclasses }; +DMACell.prototype.removePart = function(index){ + this.parts[index].destroy(); + this.parts[index] = null; + var hasAnyParts = false;//check if all parts have been deleted + _.each(this.parts, function(part){ + if (part) hasAnyParts = true; + }); + if (!hasAnyParts) dmaGlobals.lattice.removeCell(this);//if all parts are gone, remove cell +}; + +DMACell.prototype.destroyParts = function(){ + _.each(this.parts, function(part){ + if (part) part.destroy(); + }); + this.parts = null; +}; + DMACell.prototype._initNodes = function(vertices){ var position = this.getPosition(); var orientation = this.getOrientation(); @@ -168,7 +179,7 @@ DMACell.prototype._initNodes = function(vertices){ var vertex = vertices[i].clone(); vertex.applyQuaternion(orientation); vertex.add(position); - vertex.multiplyScalar(scale); + //vertex.multiplyScalar(scale); nodes.push(new DmaNode(vertex, i)); } return nodes; @@ -208,16 +219,6 @@ DMACell.prototype._initBeams = function(nodes, faces){ return beams; }; -DMACell.prototype.removePart = function(index){ - this.parts[index].destroy(); - this.parts[index] = null; - var hasAnyParts = false;//check if all parts have been deleted - _.each(this.parts, function(part){ - if (part) hasAnyParts = true; - }); - if (!hasAnyParts) dmaGlobals.lattice.removeCell(this);//if all parts are gone, remove cell -}; - DMACell.prototype.destroy = function(){ if (this.cellMesh) { dmaGlobals.three.sceneRemove(this.cellMesh, "cell"); diff --git a/js/models/AppState.js b/js/models/AppState.js index 78c8bf01fa3b1373f2e4ed848f7e0e52155a9ebb..09831a0c4d6a4d410eabf0416a59ac4d00d156e1 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -122,7 +122,7 @@ AppState = Backbone.Model.extend({ shift: false, deleteMode: false, extrudeMode: false, - cellMode: "cell",//show cells vs parts + cellMode: "cell",//show cells vs part stockSimulationPlaying: false },