diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index 7b498a4033dcecdabed699b361144155d435181a..78eac68fa9ecc9a3d0f011948a7db632fd848a99 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -143,6 +143,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre } var bounds = this.calculateBoundingBox(); + console.log(bounds); this.set("denseCellsMin", bounds.min.clone().add(this.get("cellsMin"))); var size = bounds.max.sub(bounds.min); @@ -159,12 +160,12 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre } var min = this.get("cellsMin").sub(bounds.min); - var self = this; + var overlap = false; this._loopCells(this.sparseCells, function(cell){ if (!cell) return; - var overlap = cell.addToDenseArray(cells, min); - if (overlap) self.set("overlapDetected", true); + overlap |= cell.addToDenseArray(cells, min); }); + this.set("overlapDetected", overlap); this.cells = cells; }, diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js index 6f8d43dda8a8f310563c2fd1dded44c4ffa047af..2fd8bea6debd339ad82943f845e890d98c9305ce 100644 --- a/js/lattice/LatticeBase.js +++ b/js/lattice/LatticeBase.js @@ -205,11 +205,17 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre if (cell){ var material = cell.getMaterial(); if (material.dimensions){ - var subCellRange = (new THREE.Vector3(x, y, z)).add(cell.applyRotation(material.dimensions.clone())); + var subCellRange = (new THREE.Vector3(x, y, z)).add(cell.applyRotation(material.dimensions.clone()).round()); dimMax.max(subCellRange); dimMin.min(subCellRange); - } else if (cell.length){ - var subCellRange = (new THREE.Vector3(x, y, z)).add(cell.applyRotation(new THREE.Vector3(cell.length, 1, 1))); + } else if (cell.length){//gik + var subCellRange = (new THREE.Vector3(x, y, z)).add(cell.applyRotation(new THREE.Vector3(cell.length, 0, 0)).round()); + var padding = cell.applyRotation(new THREE.Vector3(0,1,1)).round(); + _.each(padding, function(element, key){ + if (element == -1) padding[key] = 1; + }); + subCellRange.add(padding); + console.log(subCellRange); dimMax.max(subCellRange); dimMin.min(subCellRange); }