Skip to content
Snippets Groups Projects
Commit 2e3dbbdb authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

generalizing super cell highlighter

parent 01156a58
No related branches found
No related tags found
No related merge requests found
...@@ -35,15 +35,15 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three', ...@@ -35,15 +35,15 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three',
var mesh = new THREE.Mesh(planeGeometry, new THREE.MeshBasicMaterial({color:0x000000, transparent:true, opacity:0.0})); var mesh = new THREE.Mesh(planeGeometry, new THREE.MeshBasicMaterial({color:0x000000, transparent:true, opacity:0.0}));
return [mesh, new THREE.Line(geometry, new THREE.LineBasicMaterial({color:0x000000, transparent:true, linewidth:2, opacity:this.get("material").opacity}), THREE.LinePieces)]; return [mesh, new THREE.Line(geometry, new THREE.LineBasicMaterial({color:0x000000, transparent:true, linewidth:2, opacity:this.get("material").opacity}), THREE.LinePieces)];
}, }
_renderZIndexChange: function(){ // _renderZIndexChange: function(){
var zIndex = this.get("zIndex"); // var zIndex = this.get("zIndex");
var zScale = lattice.zScale(); // var zScale = lattice.zScale();
_.each(this.get("mesh"), function(mesh){ // _.each(this.get("mesh"), function(mesh){
mesh.position.set(0, 0, zIndex*zScale); // mesh.position.set(0, 0, zIndex*zScale);
}); // });
three.render(); // three.render();
}, // },
}); });
}); });
...@@ -24,8 +24,10 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', ' ...@@ -24,8 +24,10 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', '
}, },
_setPosition: function(position, direction){ _setPosition: function(position, direction){
console.log(position);
this.mesh.position.set(position.x+lattice.xScale()*direction.x/2, position.y+lattice.yScale()*direction.y/2, this.mesh.position.set(position.x+lattice.xScale()*direction.x/2, position.y+lattice.yScale()*direction.y/2,
position.z+lattice.zScale()*direction.z/2); position.z+lattice.zScale()*direction.z/2);
console.log(this.mesh.position);
}, },
_setRotation: function(direction){ _setRotation: function(direction){
...@@ -37,9 +39,9 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', ' ...@@ -37,9 +39,9 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', '
else this.mesh.rotation.set(0,0,0); else this.mesh.rotation.set(0,0,0);
var superCellIndex = appState.get("superCellIndex"); var superCellIndex = appState.get("superCellIndex");
this.mesh.translateX((superCellIndex.x + 0.5)*lattice.xScale() - this.mesh.scale.x/2); this.mesh.translateX(-((superCellIndex.x + 0.5)*lattice.xScale() - this.mesh.scale.x/2));
this.mesh.translateY((superCellIndex.y + 0.5)*lattice.yScale() - this.mesh.scale.y/2); this.mesh.translateY(-((superCellIndex.y + 0.5)*lattice.yScale() - this.mesh.scale.y/2));
this.mesh.translateZ((superCellIndex.z + 0.5)*lattice.zScale() - this.mesh.scale.z/2); this.mesh.translateZ(-((superCellIndex.z + 0.5)*lattice.zScale() - this.mesh.scale.z/2));
}, },
_superCellParamDidChange: function(){ _superCellParamDidChange: function(){
...@@ -52,18 +54,10 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', ' ...@@ -52,18 +54,10 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', '
_getNextCellPosition: function(){//add direction vector to current index _getNextCellPosition: function(){//add direction vector to current index
var newIndex = this.highlightedObject.getAbsoluteIndex(); var newIndex = this.highlightedObject.getAbsoluteIndex();
console.log(this.highlightedObject.index); newIndex.add(this.direction.clone()).round();
var direction = this.direction; var offset = appState.get("superCellIndex").clone();
_.each(_.keys(newIndex), function(key){ offset.applyQuaternion(this.mesh.quaternion).round();
newIndex[key] = Math.round(newIndex[key] + direction[key]); newIndex.sub(offset);
});
console.log(newIndex);
var offset = appState.get("superCellIndex");
// this.highlightedObject.
if (newIndex.z%2 == 0) newIndex.x -= offset.x;
else newIndex.y -= offset.x;
return newIndex; return newIndex;
} }
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment