diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js index 2f0d6f2a51ee5d07b99fc1ebff2f342d6889bff3..e33f40b5862c09cfda37dc3187319605293c4767 100644 --- a/js/cells/DMACell.js +++ b/js/cells/DMACell.js @@ -373,7 +373,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', ' DMACell.prototype.toJSON = function(){ var data = { - material: this.materialName + materialName: this.materialName }; if (materials[this.materialName].cells) return data;//material definition in material composites if (this.cells) data.cells = this.cells; diff --git a/js/cells/supercells/DMASuperCell.js b/js/cells/supercells/DMASuperCell.js index 1dfaade0ff1e8b734a29c91dc583af583eb7ecf1..ce374dfe4e6596ca0d7ffa7e81b1d5e7379f00e4 100644 --- a/js/cells/supercells/DMASuperCell.js +++ b/js/cells/supercells/DMASuperCell.js @@ -27,7 +27,6 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], DMASuperCell.prototype = Object.create(DMACell.prototype); DMASuperCell.prototype._makeChildCells = function(range, material){ - console.log(range); var cells = []; for (var x=0;x<range.x;x++){ cells.push([]); @@ -36,21 +35,21 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], for (var z=0;z<range.z;z++){ //child cells add themselves to object3D - var cellMaterial = this.materialName; + var cellMaterialName = this.materialName; cells[x][y].push(null); if (material.sparseCells){ if (material.sparseCells[x][y][z]){ - if (material.sparseCells[x][y][z].material) { - cellMaterial = material.sparseCells[x][y][z].material; - this._makeSubCellForIndex({index: new THREE.Vector3(x,y,z), material:cellMaterial}, function(cell){ + if (material.sparseCells[x][y][z].materialName) { + cellMaterialName = material.sparseCells[x][y][z].materialName; + this._makeSubCellForIndex({index: new THREE.Vector3(x,y,z), materialName:cellMaterialName}, function(cell){ var index = cell.getIndex(); cells[index.x][index.y][index.z] = cell; }); } else console.warn("no material for composite cell definition subcell"); }//else no cell in this spot } else {//if not from composite definition, add subcell at all possible indices in supercell range - this._makeSubCellForIndex({index: new THREE.Vector3(x,y,z), material:cellMaterial}, function(cell){ + this._makeSubCellForIndex({index: new THREE.Vector3(x,y,z), materialName:cellMaterialName}, function(cell){ cells[x][y][z] = cell; }); } @@ -142,5 +141,11 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], }); }; + DMASuperCell.prototype.toJSON = function(){ + var data = DMACell.prototype.toJSON.call(this); + if (this.cells) data.cells = this.cells; + return data; + }; + return DMASuperCell; }); \ No newline at end of file diff --git a/js/cells/supercells/GIKSuperCell.js b/js/cells/supercells/GIKSuperCell.js index dd6d54f4766a67dea2bdda5abca9cc1f764e7c06..c4520d2c21158c83cbd1116bd5fd6c116f4e2203 100644 --- a/js/cells/supercells/GIKSuperCell.js +++ b/js/cells/supercells/GIKSuperCell.js @@ -41,18 +41,22 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', GIKSuperCell.prototype.getMaterial = function(returnTHREEObject){ if (returnTHREEObject){ - return DMASuperCell.prototype.getMaterial.call(this, returnTHREEObject); + return materials[this.materialName].threeMaterial } - var length = this.getLength(); - var name = this.materialName + "length" + (length+1); - if (!gikMaterials[name]) { - gikMaterials[name] = { + var name = this._makeMaterialKey(); + if (!gikMaterials[this.materialName]) gikMaterials[this.materialName] = {}; + if (!gikMaterials[this.materialName][name]) { + gikMaterials[this.materialName][name] = { materialName: this.materialName, - dimensions: new THREE.Vector3(length+1, 1, 1), - threeMaterial: materials[this.materialName].threeMaterial + dimensions: new THREE.Vector3(length+1, 1, 1) }; } - return gikMaterials[name]; + return gikMaterials[this.materialName][name]; + }; + + GIKSuperCell.prototype._makeMaterialKey = function(){ + var length = this.getLength(); + return "length" + (length+1); }; GIKSuperCell.prototype._buildWireframe = function(mesh){ @@ -67,5 +71,9 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', return "cell"; }; + GIKSuperCell.prototype.toJSON = function(){ + return gikMaterials[this.materialName][this._makeMaterialKey()]; + }; + return GIKSuperCell; }); \ No newline at end of file diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js index f4d40a86ca71a66fa3659810c3f173224144dabc..9879f6bbc8a1a20df9789d6e26e1aef4fb9f7759 100644 --- a/js/lattice/LatticeBase.js +++ b/js/lattice/LatticeBase.js @@ -199,9 +199,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre if (material.dimensions){ var subCellMax = (new THREE.Vector3(x, y, z)).add(material.dimensions); dimVector.max(subCellMax); - } else if (cell.getLength){ - var subCellMax = (new THREE.Vector3(x, y, z)).add(new THREE.Vector3(cell.getLength()+1, 1, 1)); - dimVector.max(subCellMax); } } });