From c83b4d100ca656f82b34b3b9c5696942466759e7 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Mon, 9 Mar 2015 02:19:48 -0400 Subject: [PATCH] beam --- js/fea/DmaBeam.js | 10 +++++++++- js/fea/DmaCell.js | 2 +- js/fea/DmaNode.js | 4 ++++ js/models/AppState.js | 8 ++++---- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/js/fea/DmaBeam.js b/js/fea/DmaBeam.js index 65f3a79f..4eaecfba 100644 --- a/js/fea/DmaBeam.js +++ b/js/fea/DmaBeam.js @@ -5,6 +5,8 @@ Created by aghassaei on 1/13/15. //a single beam, made from two nodes +var unitGeo = new THREE.CylinderGeometry(0.1, 0.1, 1, 6); + function DmaBeam(node1, node2) { this.nodes = [node1, node2]; @@ -23,11 +25,17 @@ DmaBeam.prototype.getIndex = function(){ }; DmaBeam.prototype._buildBeamMesh = function(){ + var mesh = new THREE.Mesh(unitGeo); + var position = this.nodes[0].getPosition(); + position.sub(this.nodes[1].getPosition()); + position.multiplyScalar(0.5); + mesh.position.set(position); + return mesh; }; DmaBeam.prototype.render = function(scene){ - + if (!this.mesh) this.mesh = this._buildBeamMesh(); }; DmaBeam.prototype.calcStiffnessMatrix = function(){ diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index 3cb9a371..35d1bd4b 100644 --- a/js/fea/DmaCell.js +++ b/js/fea/DmaCell.js @@ -116,7 +116,7 @@ DMACell.prototype._initNodes = function(vertices){ return nodes; }; -DMACell.prototype._initBeams = function(){ +DMACell.prototype._initBeams = function(nodes, faces){ return []; }; diff --git a/js/fea/DmaNode.js b/js/fea/DmaNode.js index ab7e71d3..69f0d3b8 100644 --- a/js/fea/DmaNode.js +++ b/js/fea/DmaNode.js @@ -10,6 +10,10 @@ DmaNode.prototype.getIndex = function(){ return this.index; }; +DmaNode.prototype.getPosition = function(){ + return this.position.clone(); +}; + DmaNode.prototype.addBeam = function(beam){ this._beams.push(beam); }; diff --git a/js/models/AppState.js b/js/models/AppState.js index 9e173cc0..4af6c777 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -25,11 +25,11 @@ AppState = Backbone.Model.extend({ }, allPartTypes:{ octa:{ - face: {triangle:"Triangle", beam:"DmaBeam"}, - freeformFace: {triangle:"Triangle", beam:"DmaBeam"}, - edge: {triangle:"Triangle", beam:"DmaBeam"}, + face: {triangle:"Triangle", beam:"Beam"}, + freeformFace: {triangle:"Triangle", beam:"Beam"}, + edge: {triangle:"Triangle", beam:"Beam"}, edgeRot: {beam:"DmaBeam"}, - vertex: {square:"Square", xShape:"X", beam:"DmaBeam"} + vertex: {square:"Square", xShape:"X", beam:"Beam"} }, cube:{ face: null -- GitLab