Skip to content
Snippets Groups Projects
Commit db3eee0c authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

cells matrix expansion working

parent b0b2ea62
No related branches found
No related tags found
No related merge requests found
...@@ -10,9 +10,9 @@ Lattice = Backbone.Model.extend({ ...@@ -10,9 +10,9 @@ Lattice = Backbone.Model.extend({
cellType: "octa", cellType: "octa",
connectionType: "face", connectionType: "face",
nodes: [], nodes: [],
cells: [[[null]]],//3D matrix containing all cells and null, dynamic cells: [[[null]]],//3D matrix containing all cells and null, dynamic size
cellsMin: {x:0, y:0, z:0},//min position of cells matrix cellsMin: {x:0, y:0, z:0},//min position of cells matrix
cellsMax: {x:0, y:0, z:0},//min position of cells matrix cellsMax: {x:0, y:0, z:0},//max position of cells matrix
numCells: 0, numCells: 0,
partType: "triangle", partType: "triangle",
cellMode: "cell" cellMode: "cell"
...@@ -45,7 +45,6 @@ Lattice = Backbone.Model.extend({ ...@@ -45,7 +45,6 @@ Lattice = Backbone.Model.extend({
var lastMin = this.get("cellsMin"); var lastMin = this.get("cellsMin");
var newMax = this._updateCellsMax(position, lastMax); var newMax = this._updateCellsMax(position, lastMax);
var newMin = this._updateCellsMin(position, lastMin); var newMin = this._updateCellsMin(position, lastMin);
console.log(position);
if (newMax) { if (newMax) {
this._expandCellsArray(cells, this._subtract(newMax, lastMax), false); this._expandCellsArray(cells, this._subtract(newMax, lastMax), false);
this.set("cellsMax", newMax); this.set("cellsMax", newMax);
...@@ -55,18 +54,13 @@ Lattice = Backbone.Model.extend({ ...@@ -55,18 +54,13 @@ Lattice = Backbone.Model.extend({
this.set("cellsMin", newMin); this.set("cellsMin", newMin);
} }
console.log(cells); var index = this._subtract(position, this.get("cellsMin"));
cells[index.x][index.y][index.z] = new DMACell(this.get("cellMode"), absPosition);
cells[position.x][position.y][position.z] = new DMACell(this.get("cellMode"), absPosition);
// console.log(cells);
// this.set("numCells", cells.length);
window.three.render(); window.three.render();
}, },
_expandCellsArray: function(cells, expansion, fromFront){ _expandCellsArray: function(cells, expansion, fromFront){
console.log(expansion);
_.each(_.keys(expansion), function(key){ _.each(_.keys(expansion), function(key){
if (expansion[key] == 0) return;//no expansion on this axis if (expansion[key] == 0) return;//no expansion on this axis
...@@ -94,8 +88,8 @@ Lattice = Backbone.Model.extend({ ...@@ -94,8 +88,8 @@ Lattice = Backbone.Model.extend({
for (var z=0;z<cellsZ;z++){ for (var z=0;z<cellsZ;z++){
newCol.push(null); newCol.push(null);
} }
if (fromFront) cells.unshift(newCol); if (fromFront) cells[x].unshift(newCol);
else cells.push(newCol); else cells[x].push(newCol);
} }
} }
} else if (key=="z"){ } else if (key=="z"){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment