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

init with alternative color

parent 1ffcba66
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ DMASuperCell = function(index, superCell){//supercells might have supercells
this.material = globals.lattice.get("materialType");//todo move to dmacell
DMACell.call(this, index, superCell);
var range = globals.lattice.get("superCellRange");
this.cells = this._makeChildCells(index, range);//three dimensional array
this.cells = this._makeChildCells(index, range);//todo three dimensional array?
var self = this;
_.each(this.cells, function(cell){
......@@ -20,7 +20,7 @@ DMASuperCell = function(index, superCell){//supercells might have supercells
DMASuperCell.prototype = Object.create(DMACell.prototype);
DMASuperCell.prototype._makeChildCells = function(index, range){
var cells = [];//todo make cells a 3d array?
var cells = [];
for (var x=0;x<range.x;x++){
for (var y=0;y<range.y;y++){
for (var z=0;z<range.z;z++){
......
......@@ -4,20 +4,11 @@
var allGIKMaterials = {};
var gikMaterialList = AppPList().allMaterialTypes.cube.gik;
_.each(_.keys(gikMaterialList), function(material){
allGIKMaterials[material] = new THREE.MeshLambertMaterial({color:gikMaterialList[material].color});
if (gikMaterialList[material].opacity){
allGIKMaterials[material].transparent = true;
allGIKMaterials[material].opacity = gikMaterialList[material].opacity;
} else {
allGIKMaterials[material].transparent = false;
}
});
function changeGikMaterials(){
_.each(_.keys(allGIKMaterials), function(material){
_.each(_.keys(gikMaterialList), function(material){
if (globals.appState.get("realisticColorScheme")) {
allGIKMaterials[material].color = new THREE.Color(gikMaterialList[material].color);
if (allGIKMaterials[material]) allGIKMaterials[material].color = new THREE.Color(gikMaterialList[material].color);
else allGIKMaterials[material] = new THREE.MeshLambertMaterial({color:gikMaterialList[material].color});
if (gikMaterialList[material].opacity){
allGIKMaterials[material].transparent = true;
allGIKMaterials[material].opacity = gikMaterialList[material].opacity;
......@@ -26,7 +17,8 @@ function changeGikMaterials(){
}
}
else {
allGIKMaterials[material].color = new THREE.Color(gikMaterialList[material].altColor);
if (allGIKMaterials[material]) allGIKMaterials[material].color = new THREE.Color(gikMaterialList[material].altColor);
else allGIKMaterials[material] = new THREE.MeshLambertMaterial({color:gikMaterialList[material].altColor});
allGIKMaterials[material].transparent = false;
}
});
......@@ -46,6 +38,10 @@ GIKSuperCell.prototype._rotateCell = function(object3D){
return object3D;
};
GIKSuperCell.prototype.getMaterial = function(){
return allGIKMaterials[this.material];
};
GIKSuperCell.prototype._buildMesh = function(){
var length = globals.lattice.get("superCellRange").x;
var meshes = [];
......@@ -68,20 +64,4 @@ GIKSuperCell.prototype._buildWireframe = function(mesh){
wireframe.matrixWorld = mesh.matrixWorld;
wireframe.matrixAutoUpdate = true;
return wireframe;
};
GIKSuperCell.prototype.getMaterial = function(){
return allGIKMaterials[this.material];
};
GIKSuperCell.prototype.destroy = function(){
this.object3D.myParent = null;
globals.three.sceneRemove(this.object3D, this._getSceneName());
this.object3D = null;
_.each(this.cells, function(cell){
if (cell) cell.destroy();
});
this.cells = null;
this.index = null;
this.material = null;
};
\ No newline at end of file
......@@ -41,6 +41,8 @@ Lattice = Backbone.Model.extend({
this.listenTo(globals.appState, "change:cellMode", this._updateForMode);
this.listenTo(globals.appState, "change:cellsVisible", this._setCellVisibility);
changeGikMaterials();
},
delayedInit: function(){
......
......@@ -36,7 +36,7 @@ AppState = Backbone.Model.extend({
superCellIndex: 0,//offset of superCell adds todo lattice?
realisticColorScheme: true,
realisticColorScheme: false,
stockSimulationPlaying: false,
manualSelectOrigin: false//mode that allows user ot select origin from existing cell
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment