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

preparing for a big refactor or cell classes

parent ffafb8b5
Branches
No related tags found
No related merge requests found
......@@ -12,7 +12,13 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState'],
function DMACell(index, superCell){
this.index = new THREE.Vector3(index.x, index.y, index.z);
if (superCell) this.superCell = superCell;
if (superCell) {
this.superCell = superCell;
} else if (!this.cells){
//lowest level child
this.material = lattice.get("materialType");
}
//object 3d is parent to all 3d elements related to cell, parts, beams, nodes, etc
this.object3D = this._buildObject3D();
......@@ -120,7 +126,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState'],
};
DMACell.prototype.getMaterial = function(){
return cellMaterial;
return this.superCell.getMaterial();
};
DMACell.prototype.setOpacity = function(opacity){
......@@ -140,6 +146,9 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState'],
if (mode === undefined) mode = appState.get("cellMode");
switch(mode) {
case "supercell":
if (!this.superCell) mode = "cell";
break;
case "cell":
break;
case "part":
......@@ -216,6 +225,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState'],
};
DMACell.prototype.destroyParts = function(){
if (!this.parts) return;
_.each(this.parts, function(part){
if (part) part.destroy();
});
......
......@@ -9,7 +9,6 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'],
function DMASuperCell(index, superCell){//supercells might have supercells
this.material = lattice.get("materialType");//todo move to dmacell
var range = lattice.get("superCellRange");
this.cells = this._makeChildCells(index, range);//todo three dimensional array?
DMACell.call(this, index, superCell);
......@@ -51,8 +50,8 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'],
cell.setMode(mode);
});
if (mode == "cell") mode = "supercell";
if (mode == "part") mode = "object3D";
if (mode == "cell" || mode == "supercell") mode = "supercell";
else mode = "object3D";
_.each(this.object3D.children, function(child){
child.visible = child.name == mode;
......
......@@ -33,7 +33,7 @@ define(['underscore', 'backbone'], function(_, Backbone){
deleteMode: false,
highlightMode: true,
extrudeMode: false,
cellMode: "cell",//show cells vs part
cellMode: "cell",//supercell, cell, part, node, beam
cellsVisible: true,
superCellIndex: 0,//offset of superCell adds todo lattice?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment