diff --git a/js/cells/supercells/DMASuperCell.js b/js/cells/supercells/DMASuperCell.js index 977b0ffec13a546c4be9f08a619f45165ee1caea..1b9d13f5b85b27f7aa22bedd050ebcad4f3707ce 100644 --- a/js/cells/supercells/DMASuperCell.js +++ b/js/cells/supercells/DMASuperCell.js @@ -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++){ diff --git a/js/cells/supercells/GIKSuperCell.js b/js/cells/supercells/GIKSuperCell.js index 12e975ca61739980f7bd8092063e633939aedaff..2510d3e4fa1db75d713aa1600a3bce0ec4b84d06 100644 --- a/js/cells/supercells/GIKSuperCell.js +++ b/js/cells/supercells/GIKSuperCell.js @@ -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 diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index 8882bfdec68cb17eb2095d763d34831ff7182d17..0b4f58287896ff3a1ef93bf12d0830adce1dc958 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -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(){ diff --git a/js/models/AppState.js b/js/models/AppState.js index 10dbaf117c832facf63050f9ff2bbe81ecf2af4e..ba5855e3ddcbec7256a38440675ad2b3438574da 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -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