From bdc9bb4f57c680a20922038873447d922fd389e6 Mon Sep 17 00:00:00 2001 From: amandaghassaei Date: Mon, 27 Jun 2016 13:47:52 -0400 Subject: [PATCH] save last orientation --- js/highlighter/Highlighter.js | 2 +- js/lattice/LatticeBase.js | 4 +++- js/menus/contextMenu/CellContextMenu.js | 1 + js/models/AppState.js | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/js/highlighter/Highlighter.js b/js/highlighter/Highlighter.js index c6e143f..1b7d732 100644 --- a/js/highlighter/Highlighter.js +++ b/js/highlighter/Highlighter.js @@ -218,7 +218,7 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', ' } if (shouldAdd){ if (!this.isVisible() || !this.highlightedObject) return; - lattice.addCellAtIndex(this._getNextCellIndex()); + lattice.addCellAtIndex(this._getNextCellIndex(), {quaternion: appState.get("currentDesignOrientation")}); } else { if (!this.highlightedObject) return; if (!(this.highlightedObject instanceof DMACell)) return; diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js index 4cd149f..acac68f 100644 --- a/js/lattice/LatticeBase.js +++ b/js/lattice/LatticeBase.js @@ -96,6 +96,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre for (var y=range.min.y;y<=range.max.y;y++){ for (var z=range.min.z;z<=range.max.z;z++){ var index = new THREE.Vector3(x, y, z); + var quaternion = null; if (clone){ var relIndex = index.clone().sub(range.min); var cloneSize = clone.get("size"); @@ -105,8 +106,9 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre var cell = clone.cellAtIndex(relIndex); if (!cell) continue; materialID = cell.getMaterialID(); + quaternion = cell.getOrientation(); } - this._addCellAtIndex(index, {materialID: materialID}, true); + this._addCellAtIndex(index, {materialID: materialID, quaternion: quaternion}, true); } } } diff --git a/js/menus/contextMenu/CellContextMenu.js b/js/menus/contextMenu/CellContextMenu.js index 387a555..8427906 100644 --- a/js/menus/contextMenu/CellContextMenu.js +++ b/js/menus/contextMenu/CellContextMenu.js @@ -65,6 +65,7 @@ define(['jquery', 'underscore', 'backbone', 'text!menus/contextMenu/CellContextM else if (axis == "z") this.cell.rotateZ(); else console.warn("unknown axis " + axis); cellAxesVis.setRotation(this.cell.getRotation()); + appState.set("currentDesignOrientation", this.cell.getOrientation()); three.render(); }, diff --git a/js/models/AppState.js b/js/models/AppState.js index cbb76e9..27ca583 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -34,6 +34,7 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'materialsPlis deleteMode: false, extrudeMode: false, cellMode: "cell",//cell, hide + currentDesignOrientation: null,//current rotation set for placing parts realisticColorScheme: false, materialType: null, -- GitLab