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

generalizing super cell highlighter

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