diff --git a/js/cells/supercells/DMASuperCell.js b/js/cells/supercells/DMASuperCell.js index 1392a2e8b68fcf72b9c7a1d514a058205168f289..f5a5c673555b796553b81139004557c676877214 100644 --- a/js/cells/supercells/DMASuperCell.js +++ b/js/cells/supercells/DMASuperCell.js @@ -14,7 +14,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], DMACell.call(this, json, superCell); var material = this.getMaterial(); - var range = material.dimensions || appState.get("superCellRange"); + var range = (new THREE.Vector3(1,1,1)).add(material.cellsMax).sub(material.cellsMin); this.cells = this._makeChildCells(range, material); DMACell.prototype.setMode.call(this, null, function(){ diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js index 425fd3bed64442a0ae64db94b7498b6a651d2f8e..98f9902ec001a21df55e0e8d52a399b9f11b8987 100644 --- a/js/lattice/LatticeBase.js +++ b/js/lattice/LatticeBase.js @@ -193,7 +193,18 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre calculateBoundingBox: function(){ if (!this.get("cellsMax") || !this.get("cellsMin")) return new THREE.Vector3(0,0,0); - return (new THREE.Vector3()).subVectors(this.get("cellsMax"), this.get("cellsMin")).add(new THREE.Vector3(1,1,1)); + var dimVector = this.get("cellsMax").clone().sub(this.get("cellsMin")).add(new THREE.Vector3(1,1,1)); + this._loopCells(this.sparseCells, function(cell, x, y, z){ + if (cell){ + var material = cell.getMaterial(); + if (material.dimensions){ + var subCellMax = (new THREE.Vector3(x, y, z)).add(material.dimensions); + dimVector.max(subCellMax); + console.log(dimVector); + } + } + }); + return dimVector },