Skip to content
Snippets Groups Projects
Commit b6744e67 authored by amandaghassaei's avatar amandaghassaei
Browse files

removed should preserve cells on lattice change

parent de77d505
No related branches found
No related tags found
No related merge requests found
......@@ -18,8 +18,6 @@ Lattice = Backbone.Model.extend({
basePlane: null,//plane to build from
scale: 20,
highlighter: null,//highlights build-able surfaces
//todo this is not exposed in ui, is that useful?
shouldPreserveCells: true,//preserve cells when changing lattice type
//spacing for connectors/joints
cellSeparation: {xy:0, z:0},
......@@ -382,7 +380,6 @@ Lattice = Backbone.Model.extend({
if (typeof loadingFromFile == "undefined") loadingFromFile = false;
var cellType = this.get("cellType");
var connectionType = this.get("connectionType");
if (!loadingFromFile && !this.get("shouldPreserveCells")) this.clearCells();
if (this._undo) this._undo();
if (this.get("basePlane")) this.get("basePlane").destroy();
if (this.get("highlighter")) this.get("highlighter").destroy();
......@@ -412,39 +409,37 @@ Lattice = Backbone.Model.extend({
this._initLatticeType();
//todo refactor this eventually
if (loadingFromFile || this.get("shouldPreserveCells")){
var self = this;
var scale = this.get("scale");
var cells = this.get("cells");
this._loopCells(cells, function(cell, x, y, z){
if (!cell) return;
var index = _.clone(cell.indices);
//var parts = null;
//if (loadingFromFile) parts = _.clone(cell.parts);
if (cell.parentOrientation) var parentOrientation = new THREE.Quaternion(cell.parentOrientation._x, cell.parentOrientation._y, cell.parentOrientation._z, cell.parentOrientation._w);
if (cell.parentPosition) var parentPos = cell.parentPosition;
if (cell.direction) var direction = new THREE.Vector3(cell.direction.x, cell.direction.y, cell.direction.z);
if (cell.parentType) var parentType = cell.parentType;
if (cell.type) var type = cell.type;
if (cell.destroy) cell.destroy();
var newCell = self.makeCellForLatticeType(index, scale, parentPos, parentOrientation, direction, parentType, type);
//if (parts) {
// //todo make this better
// newCell.parts = newCell._initParts();
// for (var i=0;i<newCell.parts.length;i++){
// if (!parts[i]) {
// newCell.parts[i].destroy();
// newCell.parts[i] = null;
// }
// }
//}
cells[x][y][z] = newCell;
});
dmaGlobals.three.render();
}
var self = this;
var scale = this.get("scale");
var cells = this.get("cells");
this._loopCells(cells, function(cell, x, y, z){
if (!cell) return;
var index = _.clone(cell.indices);
//var parts = null;
//if (loadingFromFile) parts = _.clone(cell.parts);
if (cell.parentOrientation) var parentOrientation = new THREE.Quaternion(cell.parentOrientation._x, cell.parentOrientation._y, cell.parentOrientation._z, cell.parentOrientation._w);
if (cell.parentPosition) var parentPos = cell.parentPosition;
if (cell.direction) var direction = new THREE.Vector3(cell.direction.x, cell.direction.y, cell.direction.z);
if (cell.parentType) var parentType = cell.parentType;
if (cell.type) var type = cell.type;
if (cell.destroy) cell.destroy();
var newCell = self.makeCellForLatticeType(index, scale, parentPos, parentOrientation, direction, parentType, type);
//if (parts) {
// //todo make this better
// newCell.parts = newCell._initParts();
// for (var i=0;i<newCell.parts.length;i++){
// if (!parts[i]) {
// newCell.parts[i].destroy();
// newCell.parts[i] = null;
// }
// }
//}
cells[x][y][z] = newCell;
});
dmaGlobals.three.render();
},
////////////////////////////////////////////////////////////////////////////////////
......
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