diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index 044ac75bde544d347764b609e157d73bede47e80..23c9530dacd032f1948fea4c62bf27779700dfaf 100644 --- a/js/fea/DmaCell.js +++ b/js/fea/DmaCell.js @@ -30,7 +30,7 @@ DMACell.prototype.drawForMode = function(scale, cellMode, inverseMode){ }); }; -DMACell.prototype._superBuildCellMesh = function(unitCellGeo, material){//abstract mesh representation of cell +DMACell.prototype._superBuildCellMesh = function(unitCellGeo, material){//called from every subclass if (!material) material = cellMaterials; var mesh = THREE.SceneUtils.createMultiMaterialObject(unitCellGeo, material); this._doMeshTransformations(mesh);//some cell types require transformations, this may go away if i decide to do this in the geo instead @@ -48,7 +48,7 @@ DMACell.prototype._doMeshTransformations = function(mesh){};//by defualt, no mes DMACell.prototype.updateForScale = function(scale, cellMode){ //only update visible object to scale - var position = this.getPosition(); + var position = this._calcPosition(); this.cellMesh.scale.set(scale, scale, scale); this._setMeshPosition(this.cellMesh, position); if (cellMode == "part"){ @@ -68,8 +68,11 @@ DMACell.prototype.getScale = function(){//need for part relay return dmaGlobals.lattice.get("scale"); }; -//todo maybe this should be stored instead of recalc? DMACell.prototype.getPosition = function(){//need for part relay + return this.cellMesh.position.clone(); +}; + +DMACell.prototype._calcPosition = function(){//need for part relay if (this.isInverse) return dmaGlobals.lattice.getInvCellPositionForIndex(this.indices); return dmaGlobals.lattice.getPositionForIndex(this.indices); }; @@ -150,7 +153,7 @@ DMACell.prototype.destroy = function(){ var direction = face.normal; if (face.normal.z<0.99) direction = null;//only highlight horizontal faces - var position = dmaGlobals.lattice.getPositionForIndex(this.indices); + var position = this.getPosition(); position.z += dmaGlobals.lattice.zScale()/2; return {index: _.clone(this.indices), direction:direction, position:position}; } @@ -253,7 +256,7 @@ DMACell.prototype.destroy = function(){ DMAVertexOctaCell.prototype.calcHighlighterPosition = function(face, point){ - var position = dmaGlobals.lattice.getPositionForIndex(this.indices); + var position = this.getPosition(); var direction = null; var xScale = dmaGlobals.lattice.xScale(); @@ -390,7 +393,7 @@ DMACell.prototype.destroy = function(){ DMACubeCell.prototype.calcHighlighterPosition = function(face){ var direction = face.normal; - var position = dmaGlobals.lattice.getPositionForIndex(this.indices); + var position = this.getPosition(); var scale = dmaGlobals.lattice.xScale(); _.each(_.keys(position), function(key){ position[key] += direction[key]*scale/2; diff --git a/js/threeViews/Highlighter.js b/js/threeViews/Highlighter.js index ed7552fd258cff4a08322ab2e57fe66ceff62e53..03f4c4cc57fe000a88025ca8070e631757af008d 100644 --- a/js/threeViews/Highlighter.js +++ b/js/threeViews/Highlighter.js @@ -90,7 +90,6 @@ Highlighter = Backbone.View.extend({ _setPosition: function(position, direction){ this.mesh.position.set(position.x, position.y, position.z); this.mesh.rotation.set(direction.y*Math.PI/2, direction.x*Math.PI/2, 0); -// this.mesh.updateMatrix(); }, /////////////////////////////////////////////////////////////////////////////////// @@ -148,15 +147,7 @@ OctaFaceHighlighter = Highlighter.extend({ }); -OctaEdgeHighlighter = Highlighter.extend({ - - _makeGeometry: function(){ - - var rad = 1/Math.sqrt(3); - var geometry = new THREE.CylinderGeometry(rad, rad, 0.01, 3);//short triangular prism - geometry.applyMatrix(new THREE.Matrix4().makeRotationX(-Math.PI/2)); - return geometry; - }, +OctaEdgeHighlighter = OctaFaceHighlighter.extend({ _setPosition: function(position){ this.mesh.position.set(position.x, position.y, position.z); @@ -179,8 +170,7 @@ OctaVertexHighlighter = Highlighter.extend({ CubeHighlighter = Highlighter.extend({ _makeGeometry: function(){ - var geometry = new THREE.BoxGeometry(1,1,0.01); - return geometry; + return new THREE.BoxGeometry(1,1,0.01);; } }); \ No newline at end of file