From 7c1cc26f73247a8ed85a90e7906162036d1b7007 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Mon, 15 Jun 2015 19:37:40 -0700 Subject: [PATCH] dense dimensions for hierarchical cells --- js/cells/supercells/DMASuperCell.js | 2 +- js/lattice/LatticeBase.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/js/cells/supercells/DMASuperCell.js b/js/cells/supercells/DMASuperCell.js index 1392a2e8..f5a5c673 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 425fd3be..98f9902e 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 }, -- GitLab