diff --git a/js/fea/DmaCellOcta.js b/js/fea/DmaCellOcta.js index 2cf41250b67648469c48576e1fb096b8d007f1a6..b11f60ac18979de9e340699c569c580daaef557d 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}; };