diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index 241e16120f4423a2ec23b3735b5949a499f834ed..9cff4de9eb5e4976b92d4e738ea580fa25939575 100644 --- a/js/fea/DmaCell.js +++ b/js/fea/DmaCell.js @@ -247,7 +247,7 @@ DMACell.prototype.destroy = function(){ DMACubeCell.prototype._calcPosition = function(scale, indices){ var position = _.clone(indices); _.each(_.keys(position), function(key){ - position.key *= scale; + position[key] *= scale; }); return position; }; @@ -266,6 +266,22 @@ DMACell.prototype.destroy = function(){ return mesh; }; - self.DMAVertexOctaCell = DMACubeCell; + DMACubeCell.prototype.getHighlighterVertices = function(face){ + if (face.normal.z<0.99) return null;//only highlight horizontal faces + + //the vertices don't include the position transformation applied to cell. Add these to create highlighter vertices + var mesh = this.cellMesh.children[0]; + var vertices = mesh.geometry.vertices; + var newVertices = [vertices[face.a].clone(), vertices[face.b].clone(), vertices[face.c].clone(), new THREE.Vector3(0,0,0)]; + var scale = this.cellMesh.scale.x; + var position = (new THREE.Vector3()).setFromMatrixPosition(mesh.matrixWorld); + _.each(newVertices, function(vertex){//apply scale + vertex.multiplyScalar(scale); + vertex.add(position); + }); + return newVertices; + } + + self.DMACubeCell = DMACubeCell; })(); diff --git a/js/models/BasePlane.js b/js/models/BasePlane.js index c49bafe4e3586c1e9b8fe9ea770762a1fa419ca4..fb15c4932a1f2f673958cf378cc4cff43f4043e4 100644 --- a/js/models/BasePlane.js +++ b/js/models/BasePlane.js @@ -237,6 +237,7 @@ SquareBasePlane = BasePlane.extend({ getHighlighterVertices: function(face, position){ //the vertices don't include the position transformation applied to cell. Add these to create highlighter vertices var index = window.lattice.getIndexForPosition(position); + index.z += 1; var scale = this.get("mesh")[0].scale.x; var vertices = []; vertices.push(new THREE.Vector3(index.x*scale, index.y*scale, index.z*scale)); diff --git a/js/models/Lattice.js b/js/models/Lattice.js index d687ab92821399ef733efcaed84bf6eed34726cb..88d27094f4dda9cfb729d2b913aac47e335bc6ff 100644 --- a/js/models/Lattice.js +++ b/js/models/Lattice.js @@ -521,7 +521,7 @@ Lattice = Backbone.Model.extend({ var index = {}; index.x = Math.round((absPosition.x-scale/2)/scale); index.y = Math.round((absPosition.y-scale/2)/scale); - index.z = Math.round(absPosition.z/scale); + index.z = Math.round(absPosition.z/scale)-1; return index; },