From 6089a28ad4dee63aa6a8323897b61f9b867285e9 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Tue, 3 Feb 2015 23:18:06 -0500 Subject: [PATCH] part mode --- js/fea/DmaCell.js | 10 +++++++++- js/fea/DmaPart.js | 7 ++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index 7bf73504..c0c1d0e0 100644 --- a/js/fea/DmaCell.js +++ b/js/fea/DmaCell.js @@ -109,10 +109,18 @@ var position = this._calcPosition(scale, this.indices); this._setMeshPosition(this.cellMesh, position); _.each(this.parts, function(part){ - if (part) part.updateForScale(scale, position); + if (part) part.updateForScale(scale, position); }); }; + DMACell.prototype.getScale = function(){ + return this.lattice.get("scale"); + }; + + DMACell.prototype.getPosition = function(){ + return this._calcPosition(this.getScale(), this.indices); + } + DMACell.prototype.destroy = function(){ if (this.cellMesh) { window.three.sceneRemove(this.cellMesh, "cell"); diff --git a/js/fea/DmaPart.js b/js/fea/DmaPart.js index 96b20c9b..6c96634d 100644 --- a/js/fea/DmaPart.js +++ b/js/fea/DmaPart.js @@ -51,6 +51,7 @@ DMAPart.prototype._draw = function(){ if (this.mesh) console.warn("part mesh already in scene"); this.mesh = this._makeMeshForType(this.type); + this.updateForScale(this.parentCell.getScale(), this.parentCell.getPosition()); window.three.sceneAdd(this.mesh, "part"); }; @@ -74,20 +75,20 @@ return mesh; }; - DMAPart.prototype._setMeshPosition = function(mesh, scale, position){ + DMAPart.prototype._setMeshPosition = function(scale, position){ + var mesh = this.mesh; mesh.position.x = position.x; mesh.position.y = -scale/3*Math.sqrt(3)+position.y; mesh.position.z = position.z; if (this.oddZFlag){//adjust some offsets for odd z layers mesh.position.y += 7*scale/6; } - return mesh; }; DMAPart.prototype.updateForScale = function(scale, position){ if (this.mesh) { this.mesh.scale.set(scale, scale, scale); - this._setMeshPosition(this.mesh, scale, position); + this._setMeshPosition(scale, position); } }; -- GitLab