From ab2775f4cbc62f541fa82b94c50d8631e0351682 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Tue, 10 Mar 2015 16:53:28 -0400 Subject: [PATCH] rot octa --- js/fea/DmaCellOcta.js | 55 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/js/fea/DmaCellOcta.js b/js/fea/DmaCellOcta.js index 2cf41250..b11f60ac 100644 --- a/js/fea/DmaCellOcta.js +++ b/js/fea/DmaCellOcta.js @@ -157,8 +157,59 @@ DMARotatedEdgeCell.prototype._doMeshTransformations = function(mesh){ DMARotatedEdgeCell.prototype.calcHighlighterPosition = function(face, point){ var position = this.getPosition(); - var direction = new THREE.Vector3(0,0,1); - position.z += this.zScale()/2; + var direction = new THREE.Vector3(0,0,0); + var rad = this.xScale()*Math.sqrt(2)/6; + + var difference = new THREE.Vector3().subVectors(position, point); + difference.divideScalar(this.zScale()); + if (Math.abs(difference.z) < 0.2){ + direction.z = 0; + } else if (point.z < position.z) { + direction.z = -1; + position.z -= rad; + } else { + direction.z = 1; + position.z += rad; + } + + if (direction.z != 0){ + if (this.indices.z%2 == 0){ + if (point.x < position.x) { + direction.x -= 1; + position.x -= rad; + } + else position.x += rad; + if (point.y < position.y) { + direction.y -= 1; + position.y -= rad; + } + else position.y += rad; + } else { + if (point.x > position.x) { + direction.x += 1; + position.x += rad; + } + else position.x -= rad; + if (point.y > position.y) { + direction.y += 1; + position.y += rad; + } + else position.y -= rad; + } + } else { + if (Math.abs(difference.x) > Math.abs(difference.y)){ + if (point.x > position.x) direction.x = 1; + else direction.x = -1; + } else { + if (point.y > position.y) direction.y = 1; + else direction.y = -1; + } + + + position.x += direction.x*this.xScale()/2; + position.y += direction.y*this.yScale()/2; + } + return {index: _.clone(this.indices), direction:direction, position:position}; }; -- GitLab