From 793df5f9d2071f754daab02afe108b4786f58e42 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Mon, 26 Oct 2015 23:52:23 -0400 Subject: [PATCH] transformations between lattice types is working --- js/lattice/Lattice.js | 7 ++++--- js/lattice/LatticeBase.js | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index 92ee6109..85204c39 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -196,8 +196,9 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis return; } myConsole.clear(); - myConsole.write("lattice.setCells(" + JSON.stringify(cells) + ")"); - this._setSparseCells(cells, this._getSubclassForLatticeType()); + var cellsString = JSON.stringify(cells); + myConsole.write("lattice.setCells(" + cellsString + ")"); + this._setSparseCells(JSON.parse(cellsString), this._getSubclassForLatticeType()); }, _getSubclassForLatticeType: function(){ @@ -227,7 +228,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis if (globals.basePlane) globals.basePlane.destroy(); if (globals.highlighter) globals.highlighter.destroy(); - if (cellsMax && cellsMin) this._checkForMatrixExpansion(cellsMax, cellsMin); + if (cellsMax && cellsMin) this._expandCellsMatrix(cellsMax, cellsMin); var self = this; require([subclass], function(subclassObject){ diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js index 1f226c4b..89764b28 100644 --- a/js/lattice/LatticeBase.js +++ b/js/lattice/LatticeBase.js @@ -300,8 +300,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return; } - indicesMax.max(lastMax); - indicesMin.min(lastMin); + indicesMax = indicesMax.clone().max(lastMax); + indicesMin = indicesMin.clone().min(lastMin); if (!indicesMax.equals(lastMax)) { var size = indicesMax.clone().sub(lastMax); this._expandArray(this.cells, size, false); @@ -609,9 +609,11 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre parseCellsJSON: function(sparseCells){ var cellsMin = this.get("cellsMin"); this._loopCells(sparseCells, function(cell, x, y, z, self){ - var json = _.extend({index: (new THREE.Vector3(x, y, z)).add(cellsMin)}, cell); - self._addCellAtIndex(new THREE.Vector3(x, y, z), json); + var index = (new THREE.Vector3(x, y, z)).add(cellsMin); + var json = _.extend({index: index}, cell); + self._addCellAtIndex(index, json); }); + three.render(); }, getSaveJSON: function(){ -- GitLab