diff --git a/js/fea/dmaCell.js b/js/fea/dmaCell.js index 75a1250841a933e6269b37820c2319422770d0f2..0a59cc6e55fdbcf8c42d18720fac5dd75ba31758 100644 --- a/js/fea/dmaCell.js +++ b/js/fea/dmaCell.js @@ -42,7 +42,7 @@ this.cellMesh = this._buildCellMesh(this.position); window.three.sceneAdd(this.cellMesh); - this.parts = this._initParts(this.position); + this.parts = this._initParts(this.position, indices.z); this.drawForMode(mode); } @@ -59,10 +59,10 @@ return position; }; - DMACell.prototype._initParts = function(position){ + DMACell.prototype._initParts = function(position, zIndex){ var parts = []; for (var i=0;i<3;i++){ - parts.push(new DMAPart(i, position)); + parts.push(new DMAPart(i, position, zIndex%2==1)); } return parts; }; diff --git a/js/fea/dmaPart.js b/js/fea/dmaPart.js index 187ee0b99d8a0d86dfcfd3b7fb325ab6417c1055..7f25da7c1a9cebf80e01f9ddee280d58d9e091f9 100644 --- a/js/fea/dmaPart.js +++ b/js/fea/dmaPart.js @@ -24,13 +24,10 @@ partGeometry.applyMatrix(new THREE.Matrix4().makeScale(30,30,30)); } - function DMAPart(type, position) { - + function DMAPart(type, position, oddZFlag) { this.position = position; + this.oddZFlag = oddZFlag;//this tells me if cell is at an odd z height in lattice, everything needs to rotate 180 this.type = type; - // this.nodes = nodes; - // this.beams = this._createBeams(nodes, config); - // this.geometry = geometry; } DMAPart.prototype._draw = function(){ @@ -45,8 +42,7 @@ mesh.position.y = -30/3*Math.sqrt(3)+this.position.y; mesh.position.z = this.position.z; - //todo this sucks, go back and fix the real problem - if (Math.round(mesh.position.z/(2*30/Math.sqrt(6)))%2 == 1){ + if (this.oddZFlag){//adjust some offsets for odd z layers mesh.position.y += 30 + 30/6; mesh.rotateZ(Math.PI); } @@ -62,14 +58,6 @@ return mesh; }; - DMAPart.prototype._createBeams = function(nodes, config){ -// var beams = []; -// _.each(config, function(pair){ -// beams.push(new Beam(nodes[pair[0]], nodes[pair[2]])); -// }); -// return beams; - }; - DMAPart.prototype.show = function(){ if (!this.mesh) this._draw(); this.mesh.visible = true;