diff --git a/js/baseplane/BasePlane.js b/js/baseplane/BasePlane.js index a5d587e9e91bf595f02ede7c2302ef528f11dbe3..97435485ad9427ed03bfddece2e44f60cb68fc83 100644 --- a/js/baseplane/BasePlane.js +++ b/js/baseplane/BasePlane.js @@ -36,7 +36,8 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three'], updateXYSeparation: function(xySep) {}, - getOrientation: function(){ + getAbsoluteOrientation: function(){ + console.log("baseplane orientation"); return new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0,0,1), Math.PI); }, @@ -45,8 +46,18 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three'], three.render(); }, - getIndex: function(){ - return this.index.clone(); + getAbsoluteIndex: function(){ + return this.highligherIndex.clone(); + }, + + calcHighlighterParams: function(face, point, index){ + point.z = 0;//todo this doesn't generalize when baseplane moves + if (!index || index === undefined) index = lattice.getIndexForPosition(point); + index.z = this.get("zIndex") - 1;//pretend we're on the top of the cell underneath the baseplane + var position = lattice.getPositionForIndex(index); + position.z += lattice.zScale()/2; + this.highligherIndex = index; + return {direction: new THREE.Vector3(0,0,1), position:position}; }, _removeMesh: function(){ diff --git a/js/baseplane/OctaBasePlane.js b/js/baseplane/OctaBasePlane.js index bc1ca132272b262150618e80d2cc1efb9a160c1f..2278bd67dd771e00c4322ee52ab66948b823c741 100644 --- a/js/baseplane/OctaBasePlane.js +++ b/js/baseplane/OctaBasePlane.js @@ -89,15 +89,11 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three', geometry.verticesNeedUpdate = true; }, - calcHighlighterPosition: function(face, position){ - position.z = 0; - var index = lattice.getIndexForPosition(position); + calcHighlighterParams: function(face, point){ + point.z = 0; + var index = lattice.getIndexForPosition(point); if (index.z%2 != 0) index.x -= 1; - index.z = this.get("zIndex") - 1;//pretend we're on the top of the cell underneath the baseplane - var position = lattice.getPositionForIndex(index); - position.z += lattice.zScale()/2; - this.index = new THREE.Vector3(index.x, index.y, index.z);//todo no!!! - return {index: index, direction: new THREE.Vector3(0,0,1), position:position}; + return BasePlane.prototype.calcHighlighterParams.call(this, face, point, index); } }); }); \ No newline at end of file diff --git a/js/baseplane/RotEdgeOctaBasePlane.js b/js/baseplane/RotEdgeOctaBasePlane.js index 2c59ce3d6e9f4222d0b46717fa4185d980bce365..7c4b4413763e8102b10aca54e9eae66b01d6faf5 100644 --- a/js/baseplane/RotEdgeOctaBasePlane.js +++ b/js/baseplane/RotEdgeOctaBasePlane.js @@ -8,14 +8,12 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three', return SquareBasePlane.extend({ - calcHighlighterPosition: function(face, position){ - var index = lattice.getIndexForPosition(position); - index.z = this.get("zIndex") - 1;//pretend we're on the top of the cell underneath the baseplane - var latticePosition = lattice.getPositionForIndex(index); - latticePosition.x -= lattice.xScale()/2; - latticePosition.y -= lattice.yScale()/2; - this.index = new THREE.Vector3(index.x, index.y, index.z);//todo no!!! - return {index: index, direction: new THREE.Vector3(0,0,1), position:latticePosition}; + calcHighlighterParams: function(face, point){ + var params = SquareBasePlane.prototype.calcHighlighterParams.call(this, face, point); + params.position.x -= lattice.xScale()/2; + params.position.y -= lattice.yScale()/2; + params.position.z -= lattice.zScale()/2; + return params; } }); }); \ No newline at end of file diff --git a/js/baseplane/SquareBasePlane.js b/js/baseplane/SquareBasePlane.js index 00021c2024d708dc6c0ba31e590801ef3b5789d1..29bdbc73bed90532755defb04d26ea91effdcda3 100644 --- a/js/baseplane/SquareBasePlane.js +++ b/js/baseplane/SquareBasePlane.js @@ -45,14 +45,5 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three', }); three.render(); }, - - calcHighlighterPosition: function(face, position){ - var index = lattice.getIndexForPosition(position); - index.z = this.get("zIndex") - 1;//pretend we're on the top of the cell underneath the baseplane - var latticePosition = lattice.getPositionForIndex(index); - latticePosition.z += lattice.zScale()/2; - this.index = new THREE.Vector3(index.x, index.y, index.z);//todo no!!! - return {index: index, direction: new THREE.Vector3(0,0,1), position:latticePosition}; - } }); }); diff --git a/js/cells/CubeCell.js b/js/cells/CubeCell.js index f66b17bbf49eb605f2334069987cedffeaaa692e..ff808f388f58590c312b7cc98f56d23908f035c7 100644 --- a/js/cells/CubeCell.js +++ b/js/cells/CubeCell.js @@ -25,17 +25,5 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], return wireframe; }; - CubeCell.prototype.calcHighlighterPosition = function(face){ - - var direction = face.normal.clone().applyEuler(this.object3D.rotation); - var position = this.getPosition(); - var scale = this.xScale(); - _.each(_.keys(position), function(key){ - position[key] += direction[key]*scale/2; - }); - return {index: _.clone(this.index), direction:direction, position:position}; - }; - return CubeCell; - }); \ No newline at end of file diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js index 86243b2939782da2d631164d6dcdbfdbca237e59..80c7fe83cad366e88e311c60e5499206ce043731 100644 --- a/js/cells/DMACell.js +++ b/js/cells/DMACell.js @@ -20,7 +20,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals'], if (this.superCell) this.superCell.addChildren(this.object3D);//add as child of supercell - if (superCell === undefined) { + if (!superCell || superCell === undefined) { if (this.index) { three.sceneAdd(this.object3D); if (!this.cells) three.addCell(this.object3D.children[0]);//add mesh as highlightable object @@ -63,7 +63,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals'], var geometry = this._getGeometry(); var meshes = []; - var mesh = new THREE.Mesh(geometry, this._getMaterial()); + var mesh = new THREE.Mesh(geometry, this.getMaterial()); mesh.name = this._getMeshName(); meshes.push(mesh); @@ -141,6 +141,24 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals'], + //highlighting + + DMACell.prototype.calcHighlighterParams = function(face, point){//this works for rectalinear, override in subclasses + var direction = face.normal.clone().applyQuaternion(this.getAbsoluteOrientation()); + var position = this.getAbsolutePosition(); + var self = this; + _.each(_.keys(position), function(key){ + position[key] += direction[key]*self.axisScale(key)/2; + }); + return {direction:direction, position:position}; + }; + + + + + + + //children DMACell.prototype.addChildren = function(children, object3D){//accepts an array or a single mesh @@ -177,7 +195,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals'], this.setMode(mode); }; - DMACell.prototype._getMaterial = function(){ + DMACell.prototype.getMaterial = function(){ if (!this.material) console.warn("no material for cell"); var materialClass = lattice.get("materialClass"); if (!globals.materials[materialClass]) { diff --git a/js/cells/OctaEdgeCell.js b/js/cells/OctaEdgeCell.js index 98278401711ebed6ec5d706b6def2997fbc26dcc..ae89f4e8fa08a65c50454769ff2295112ea93795 100644 --- a/js/cells/OctaEdgeCell.js +++ b/js/cells/OctaEdgeCell.js @@ -17,6 +17,8 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'octaFaceCel //todo fix this OctaEdgeCell.prototype.calcHighlighterPosition = function(face){ +// var direction = face.normal.clone().applyQuaternion(this.getAbsoluteOrientation()); +// var position = this.getAbsolutePosition(); var direction = face.normal.clone(); direction.applyQuaternion(this.mesh.quaternion); var position = this.getPosition(); diff --git a/js/cells/OctaFaceCell.js b/js/cells/OctaFaceCell.js index db85c6402f5c1012bd70f1832442e508d1866b81..0b6fe3245fa62764b231d3c41882a50495a51d18 100644 --- a/js/cells/OctaFaceCell.js +++ b/js/cells/OctaFaceCell.js @@ -33,12 +33,10 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], return parts; }; - OctaFaceCell.prototype.calcHighlighterPosition = function(face){ - if (face.normal.z<0.99) return {index: _.clone(this.index)};//only highlight horizontal faces - var direction = face.normal; - var position = this.getPosition(); - position.z += face.normal.z*this.zScale()/2; - return {index:_.clone(this.index), direction:direction, position:position}; + OctaFaceCell.prototype.calcHighlighterParams = function(face){ + var direction = face.normal.clone().applyQuaternion(this.getAbsoluteOrientation()); + if (direction.z<0.99) return null;//only highlight horizontal faces + return DMACell.prototype.calcHighlighterParams.call(this, face); }; return OctaFaceCell; diff --git a/js/cells/OctaRotEdgeCell.js b/js/cells/OctaRotEdgeCell.js index 28aee99afcccd5e4ad922dac5f97d8f2bf1598e9..8348f9748c5e8555b6639b2757a114a89c214e0b 100644 --- a/js/cells/OctaRotEdgeCell.js +++ b/js/cells/OctaRotEdgeCell.js @@ -7,6 +7,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], function(_, THREE, three, lattice, appState, DMACell){ var unitGeo = new THREE.OctahedronGeometry(1/Math.sqrt(2)); + unitGeo.applyMatrix(new THREE.Matrix4().makeRotationZ(Math.PI/4)); function OctaRotEdgeCell(index, superCell){ DMACell.call(this, index, superCell); @@ -31,14 +32,10 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], return unitGeo; }; - OctaRotEdgeCell.prototype._rotateCell = function(object3D){ - object3D.rotation.set(0, 0, Math.PI/4); - return object3D; - }; - - OctaRotEdgeCell.prototype.calcHighlighterPosition = function(face, point){ + OctaRotEdgeCell.prototype.calcHighlighterParams = function(face, point){ - var position = this.getPosition(); +// point.applyQuaternion(this.getAbsoluteOrientation()); + var position = this.getAbsolutePosition(); var direction = new THREE.Vector3(0,0,0); var rad = this.xScale()*Math.sqrt(2)/6; @@ -90,8 +87,8 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], position.y += direction.y*this.yScale()/2; } - return {index: _.clone(this.index), direction:direction, position:position}; + return {direction:direction, position:position}; }; - return OctaVertexCell; + return OctaRotEdgeCell; }); \ No newline at end of file diff --git a/js/cells/OctaVertexCell.js b/js/cells/OctaVertexCell.js index 6231d0c68adf0c73ccd8a3aaa72e4701dfb54a95..e60050e9d92c64120bfc37de86ef8ce629b1ffd3 100644 --- a/js/cells/OctaVertexCell.js +++ b/js/cells/OctaVertexCell.js @@ -6,18 +6,21 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], function(_, THREE, three, lattice, appState, DMACell){ + var unitGeo = new THREE.OctahedronGeometry(1/Math.sqrt(2)); + function OctaVertexCell(index, superCell){ DMACell.call(this, index, superCell); } OctaVertexCell.prototype = Object.create(DMACell.prototype); OctaVertexCell.prototype._getGeometry = function(){ - return unitVertexOcta; + return unitGeo; }; - OctaVertexCell.prototype.calcHighlighterPosition = function(face, point){ + OctaVertexCell.prototype.calcHighlighterParams = function(face, point){ - var position = this.getPosition(); +// point.applyQuaternion(this.getAbsoluteOrientation()); + var position = this.getAbsolutePosition(); var direction = null; var xScale = this.xScale(); @@ -50,7 +53,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], } } - return {index: _.clone(this.index), direction:direction, position:position}; + return {direction:direction, position:position}; }; return OctaVertexCell; diff --git a/js/cells/TruncatedCubeCell.js b/js/cells/TruncatedCubeCell.js index c623bde0ee9d598c7b7e70fbc516def3a69a95db..ee4addcf51d5cd3aa523e5530d5892c569be8784 100644 --- a/js/cells/TruncatedCubeCell.js +++ b/js/cells/TruncatedCubeCell.js @@ -66,17 +66,10 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], return wireframe; }; - TruncatedCubeCell.prototype.calcHighlighterPosition = function(face){ - + TruncatedCubeCell.prototype.calcHighlighterParams = function(face){ var direction = face.normal; - if (!(Math.abs(direction.x)>0.9 || Math.abs(direction.y)>0.9 || Math.abs(direction.z)>0.9)) return {index: _.clone(this.index)}; - - var position = this.getPosition(); - var scale = this.zScale(); - _.each(_.keys(position), function(key){ - position[key] += direction[key]*scale/2; - }); - return {index: _.clone(this.index), direction:direction, position:position}; + if (!(Math.abs(direction.x)>0.9 || Math.abs(direction.y)>0.9 || Math.abs(direction.z)>0.9)) return null; + return DMACell.prototype.calcHighlighterParams.call(this, face); }; return TruncatedCubeCell; diff --git a/js/highlighter/Highlighter.js b/js/highlighter/Highlighter.js index a2a86e7536919b79a65433757fdfae61a7df213b..bd7d570dc65c764449ca7666709dde7de1af0c78 100644 --- a/js/highlighter/Highlighter.js +++ b/js/highlighter/Highlighter.js @@ -17,11 +17,9 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', ' var geometry = this._makeGeometry(); this.mesh = new THREE.Mesh(geometry, new THREE.MeshBasicMaterial({ - // side:THREE.DoubleSide, transparent:true, opacity:0.4, color:0xffffff - // vertexColors:THREE.FaceColors })); three.sceneAdd(this.mesh); @@ -32,9 +30,10 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', ' this.listenTo(appState, "change:superCellIndex", this._superCellParamDidChange); }, - /////////////////////////////////////////////////////////////////////////////////// - /////////////////////////////VISIBILITY//////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////////// + + + + //visibility hide: function(){ this._setVisibility(false); @@ -64,47 +63,51 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', ' this.hide(); }, + + + + //highlight + highlight: function(intersection){ if (!intersection.object) return; - var highlighted = intersection.object; - if (!(highlighted.parent instanceof THREE.Scene)) highlighted = highlighted.parent;//cell mesh parent is object3d - if (!highlighted.myParent) { + var highlighted = intersection.object.parent;//cell mesh parent is object3d + if (!highlighted.myParent) {//myParent is cell instance console.warn("no parent for highlighted object"); return; } this.highlightedObject = highlighted.myParent; - var highlightedPos = this.highlightedObject.calcHighlighterPosition(intersection.face, intersection.point); - this.position = highlightedPos.position;//todo used just for gik - if (!highlightedPos.direction) {//may be hovering over a face that we shouldn't highlight + var params = this.highlightedObject.calcHighlighterParams(intersection.face, intersection.point); + if (!params) {//may be hovering over a face that we shouldn't highlight this.hide(); return; } - this.direction = highlightedPos.direction; - this._setPosition(highlightedPos.position, this.direction);//position of center point - this._setRotation(this.direction); + this.position = params.position; + this.direction = params.direction; + this._setPosition(params.position, params.direction);//position of center point + this._setRotation(params.direction); this.show(true); }, - /////////////////////////////////////////////////////////////////////////////////// - /////////////////////////////POSITION/SCALE//////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////////// + + + + //position/scale/rotation getHighlightedObjectPosition: function(){//origin selection if (this.highlightedObject instanceof DMACell) { var position = this.highlightedObject.getPosition(); - return { - x:parseFloat(position.x.toFixed(4)), - y:parseFloat(position.y.toFixed(4)), - z:parseFloat(position.z.toFixed(4)) - }; + return new THREE.Vector3(parseFloat(position.x.toFixed(4)), + parseFloat(position.y.toFixed(4)), + parseFloat(position.z.toFixed(4))); } + console.warn("highlighted object is not a DMACell") return null; }, - _setPosition: function(position){ + _setPosition: function(position, direction){ this.mesh.position.set(position.x, position.y, position.z); }, @@ -116,12 +119,13 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', ' if (this.updateGikLength) this.updateGikLength(); }, - /////////////////////////////////////////////////////////////////////////////////// - /////////////////////////////ADD REMOVE//////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////////// + + + + //add/remove cells _getNextCellPosition: function(){//add direction vector to current index - var newIndex = _.clone(this.highlightedObject.getIndex()); + var newIndex = this.highlightedObject.getAbsoluteIndex().clone(); var direction = this.direction; _.each(_.keys(newIndex), function(key){ newIndex[key] = Math.round(newIndex[key] + direction[key]); diff --git a/js/highlighter/OctaFaceHighlighter.js b/js/highlighter/OctaFaceHighlighter.js index 826c4a484d7ec247f3a4645cf444060c0c98136f..67e0289b47f7eee9d98ec30c5c1ea9ddc4f3ac41 100644 --- a/js/highlighter/OctaFaceHighlighter.js +++ b/js/highlighter/OctaFaceHighlighter.js @@ -17,7 +17,7 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', ' }, _setRotation: function(){ - this.mesh.rotation.set(0,0,(this.highlightedObject.getIndex().z+1)%2*Math.PI); + this.mesh.rotation.set(0,0,(this.highlightedObject.getAbsoluteIndex().z+1)%2*Math.PI); } }); diff --git a/js/highlighter/GIKHighlighter.js b/js/highlighter/SuperCellHighlighter.js similarity index 95% rename from js/highlighter/GIKHighlighter.js rename to js/highlighter/SuperCellHighlighter.js index e674fedf0df4a081c7851c8bc07dffdd9bdb736f..0281843030e37a489776bccf8cb80651d9ee3521 100644 --- a/js/highlighter/GIKHighlighter.js +++ b/js/highlighter/SuperCellHighlighter.js @@ -8,7 +8,7 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', ' return Highlighter.extend({ _makeGeometry: function(){ - return new THREE.BoxGeometry(1,1,lattice.zScale(0)); + return new THREE.BoxGeometry(lattice.xScale(0),lattice.yScale(0),lattice.zScale(0)); }, _setPosition: function(position, direction){ diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index e7e01f5612d6bdf1767ca12f3858956783bc2ab4..050a20fc40dd239e4b9140a139ac5204b6c52051 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -95,15 +95,14 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre }, _indexForPosition: function(absPosition){ - var position = {}; - position.x = Math.floor(absPosition.x/this.xScale()); - position.y = Math.floor(absPosition.y/this.yScale()); - position.z = Math.floor(absPosition.z/this.zScale()); - return position; + return new THREE.Vector3( + Math.floor(absPosition.x/this.xScale()), + Math.floor(absPosition.y/this.yScale()), + Math.floor(absPosition.z/this.zScale())); }, _positionForIndex: function(index){ - var position = _.clone(index); + var position = index.clone(); position.x = (position.x+0.5)*this.xScale(); position.y = (position.y+0.5)*this.yScale(); position.z = (position.z+0.5)*this.zScale(); @@ -133,7 +132,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre clearCells: function(){ this._iterCells(this.sparseCells, function(cell){//send destroy to top level - if (cell && cell.destroy) cell.destroy(); + if (cell) cell.destroy(); }); three.removeAllCells();//todo add flag in cell destroy to avoid redundancy here this.cells = [[[null]]]; diff --git a/js/lattice/OctaFaceLattice.js b/js/lattice/OctaFaceLattice.js index 582033791c129c3f62d25f870ee6d8fefe81b024..0927d3e6b6246a364edadcdd048fabf27c30cd5d 100644 --- a/js/lattice/OctaFaceLattice.js +++ b/js/lattice/OctaFaceLattice.js @@ -25,7 +25,7 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th }, getPositionForIndex: function(index){ - var position = _.clone(index); + var position = index.clone(); position.x = (position.x+1/2); position.y = position.y*this.yScale()+1/Math.sqrt(3)/2; position.z = (position.z+0.5)*this.zScale(); diff --git a/js/lattice/OctaRotEdgeLattice.js b/js/lattice/OctaRotEdgeLattice.js index 7b5d359baf812cffcb5544628819e8fb90b6d258..88ab171e520e72384830925087d448028496169c 100644 --- a/js/lattice/OctaRotEdgeLattice.js +++ b/js/lattice/OctaRotEdgeLattice.js @@ -8,7 +8,7 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th var OctaRotEdgeLattice = { _initLatticeType: function(){ - require(['rotEdgeOctaBasePlane'], function(RotEdgeOctaBasePlane){ + require(['rotEdgeOctaBaseplane'], function(RotEdgeOctaBasePlane){ globals.basePlane = new RotEdgeOctaBasePlane(); }); require(['defaultHighlighter'], function(DefaultHighlighter){ @@ -17,15 +17,14 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th }, getIndexForPosition: function(absPosition){ - var position = {}; - position.x = Math.floor(absPosition.x/this.xScale()+0.5); - position.y = Math.floor(absPosition.y/this.yScale()+0.5); - position.z = Math.floor(absPosition.z/this.zScale()+0.5); - return position; + return new THREE.Vector3( + Math.floor(absPosition.x/this.xScale()+0.5), + Math.floor(absPosition.y/this.yScale()+0.5), + Math.floor(absPosition.z/this.zScale())+0.5); }, getPositionForIndex: function(index){ - var position = _.clone(index); + var position = index.clone(); if (index.z %2 != 0){ position.x += 0.5; position.y += 0.5; diff --git a/js/lattice/OctaVertexLattice.js b/js/lattice/OctaVertexLattice.js index babdeecff7f4955c91f14a48f3732da073e63d38..76764cb9a78ebcf531c8746a9047042c65e344e1 100644 --- a/js/lattice/OctaVertexLattice.js +++ b/js/lattice/OctaVertexLattice.js @@ -17,15 +17,14 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th }, getIndexForPosition: function(absPosition){ - var position = {}; - position.x = Math.floor(absPosition.x/this.xScale()+0.5); - position.y = Math.floor(absPosition.y/this.yScale()+0.5); - position.z = Math.floor(absPosition.z/this.zScale()+0.5); - return position; + return new THREE.Vector3( + Math.floor(absPosition.x/this.xScale()+0.5), + Math.floor(absPosition.y/this.yScale()+0.5), + Math.floor(absPosition.z/this.zScale())+0.5); }, getPositionForIndex: function(index){ - var position = _.clone(index); + var position = index.clone(); position.x = (position.x)*this.xScale(); position.y = (position.y)*this.yScale(); position.z = (position.z+0.5)*this.zScale(); diff --git a/js/main.js b/js/main.js index a46871011155c26285e2b7ba7ae92c96eaf6bc15..2cde81ed5a2a774a09f66856760810276004fdcd 100644 --- a/js/main.js +++ b/js/main.js @@ -46,7 +46,7 @@ require.config({ highlighter: 'highlighter/Highlighter', defaultHighlighter: 'highlighter/DefaultHighlighter', cubeHighlighter: 'highlighter/CubeHighlighter', - gikHighlighter: 'highlighter/GIKHighlighter', + superCellHighlighter: 'highlighter/SuperCellHighlighter', octaFaceHighlighter: 'highlighter/OctaFaceHighlighter', truncatedCubeHighlighter: 'highlighter/TruncatedCubeHighlighter', diff --git a/js/three/ThreeView.js b/js/three/ThreeView.js index a75b5de4da84580bc86f922ad90d23d0719133dd..14b3ee068284b52576e250a32184b94c5f91c2a5 100644 --- a/js/three/ThreeView.js +++ b/js/three/ThreeView.js @@ -83,6 +83,8 @@ define(['underscore', 'backbone', 'three', 'appState', 'globals', 'orbitControls _mouseMoved: function(e){ + if (!globals.highlighter) return;//highlighter not loaded yet + if (!appState.get("highlightMode") && !(appState.get("manualSelectOrigin"))) return; if (this.mouseIsDown && !this.controls.noRotate) {//in the middle of a camera move