diff --git a/data/edgeVoxPart.stl b/data/edgeVoxPart.stl new file mode 100644 index 0000000000000000000000000000000000000000..827e7c9993c32d8f6df65e61d5e131f30fd03fbb Binary files /dev/null and b/data/edgeVoxPart.stl differ diff --git a/js/cam/Machine.js b/js/cam/Machine.js index cf0dddf72ad0d60fde8cbc68c0d86621e258112f..7251123813516b210a0107faf2b335f40a0a766b 100644 --- a/js/cam/Machine.js +++ b/js/cam/Machine.js @@ -5,7 +5,7 @@ function Machine() { var mesh = new THREE.Mesh(new THREE.BoxGeometry(2,2,2)); - dmaGlobals.three.sceneAdd(mesh); + //dmaGlobals.three.sceneAdd(mesh); this.mesh = mesh; } diff --git a/js/fea/DmaCellOcta.js b/js/fea/DmaCellOcta.js index ca5c14bc49dcfa96549907e0b7ffdc4253387202..4eb1c7e3e32ed050bda0a0186f81b8a6ce298538 100644 --- a/js/fea/DmaCellOcta.js +++ b/js/fea/DmaCellOcta.js @@ -150,6 +150,10 @@ function DMARotatedEdgeCell(indices, scale){ } DMARotatedEdgeCell.prototype = Object.create(DMACell.prototype); +DMARotatedEdgeCell.prototype._initParts = function(){ + return [new DMAEdgeVoxPart(0, this)]; +}; + DMARotatedEdgeCell.prototype._doMeshTransformations = function(mesh){ mesh.rotation.set(0, 0, Math.PI/4); }; diff --git a/js/fea/DmaPart.js b/js/fea/DmaPart.js index 8f6c94b0e46f9a6a1c99ae63aa543c7bc847c3c1..792de4d07dd5165635f1b5e9df47e3aa1f89c831 100644 --- a/js/fea/DmaPart.js +++ b/js/fea/DmaPart.js @@ -3,6 +3,9 @@ */ +var partMaterial = new THREE.MeshLambertMaterial({ color:0xffffff, shading: THREE.FlatShading }); + partMaterial.color.setRGB( 0.9619657144369509, 0.6625466032079207, 0.20799727886007258 ); + //a part, element with a single material, handled by assembler function DMAPart(type, parent) { @@ -82,7 +85,7 @@ ////////////////////////////////////////////////////////////// -/////////////////TRIANGLE PART/////////////////////////////////// +/////////////////TRIANGLE PART//////////////////////////////// ////////////////////////////////////////////////////////////// @@ -108,9 +111,6 @@ unitPartGeo3.applyMatrix(new THREE.Matrix4().makeRotationZ(-2*Math.PI/3)); }); - var partMaterial = new THREE.MeshLambertMaterial({ color:0xffffff, shading: THREE.FlatShading }); - partMaterial.color.setRGB( 0.9619657144369509, 0.6625466032079207, 0.20799727886007258 ); - function DMATrianglePart(type, parent){ DMAPart.call(this, type, parent); } @@ -135,4 +135,41 @@ self.DMATrianglePart = DMATrianglePart; +})(); + + +////////////////////////////////////////////////////////////// +/////////////////EDGE VOX PART//////////////////////////////// +////////////////////////////////////////////////////////////// + + + +(function () { + + var unitPartGeo; + + //import part geometry + var loader = new THREE.STLLoader(); + loader.load("data/edgeVoxPart.stl", function(geometry){ + + unitPartGeo = geometry; + unitPartGeo.computeBoundingBox(); + var unitScale = 0.7/unitPartGeo.boundingBox.max.y; + unitPartGeo.applyMatrix(new THREE.Matrix4().makeScale(unitScale, unitScale, unitScale)); + unitPartGeo.applyMatrix(new THREE.Matrix4().makeRotationY(Math.PI)); + }); + + function DMAEdgeVoxPart(type, parent){ + DMAPart.call(this, type, parent); + } + DMAEdgeVoxPart.prototype = Object.create(DMAPart.prototype); + + DMAEdgeVoxPart.prototype._makeMeshForType = function(){ + var mesh = new THREE.Mesh(unitPartGeo, partMaterial.clone()); + mesh.myPart = this;//need a ref back to this part + return mesh; + }; + + self.DMAEdgeVoxPart = DMAEdgeVoxPart; + })(); \ No newline at end of file diff --git a/js/models/AppState.js b/js/models/AppState.js index bb47ffb09c1968bb832694419c92e434c80cc000..8abd76db0a7729014c7a40f6251400fcfecb712b 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -72,6 +72,7 @@ AppState = Backbone.Model.extend({ triangle:"Triangle" }, edgeRot: { + vox: "Snap Voxel", beam:"Beam" }, vertex: { diff --git a/js/threeViews/ThreeView.js b/js/threeViews/ThreeView.js index 5a0c2cbcf98f4668bbca720f4bc7fa68d2054244..0087c29b8003c3cdcef9baf94c8258e458110477 100644 --- a/js/threeViews/ThreeView.js +++ b/js/threeViews/ThreeView.js @@ -26,7 +26,7 @@ ThreeView = Backbone.View.extend({ this.appState = options.appState; - _.bindAll(this, "_mouseMoved");//"_animate" + _.bindAll(this, "_mouseMoved", "_animate"); //bind events this.listenTo(this.appState, "change:deleteMode change:extrudeMode change:shift", this._setControlsEnabled); @@ -40,17 +40,17 @@ ThreeView = Backbone.View.extend({ this.$el.append(this.model.domElement);//render only once this.model.render(); - //this._animate(); + this._animate(); }, //////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////CONTROLS///////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// - //_animate: function(){ - // requestAnimationFrame(this._animate); - // this.controls.update(); - //}, + _animate: function(){ + requestAnimationFrame(this._animate); + this.controls.update(); + }, _setControlsEnabled: function(){ var state = this.appState.get("deleteMode") || this.appState.get("shift") || this.appState.get("extrudeMode");