diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index 7380a156c43e8f22330ce8312a5a342920066e81..c4cff5e7022ca13f43b2b8e2c8f09b81a305c8d0 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -123,6 +123,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return; } + //composite material appState.set("superCellRange", globals.materials.compositeMaterials[materialType].dimensions.clone()); appState.set("superCellIndex", new THREE.Vector3(0,0,0)); require(['superCellHighlighter'], function(SuperCellHighlighter){ diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js index ae3f3395380d42fea7bc881d8b83905a6e993f59..35013e58c33e4c22eb664905183ca04183a11f61 100644 --- a/js/lattice/LatticeBase.js +++ b/js/lattice/LatticeBase.js @@ -200,7 +200,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre if (material.dimensions){ var subCellMax = (new THREE.Vector3(x, y, z)).add(material.dimensions); dimVector.max(subCellMax); - console.log(dimVector); } } }); diff --git a/js/menus/MaterialMenuView.js b/js/menus/MaterialMenuView.js index 936da934c7b308555cc2d15ded1cba270853692b..092fb0ac10fe501470383fde690418ea021b2cef 100644 --- a/js/menus/MaterialMenuView.js +++ b/js/menus/MaterialMenuView.js @@ -79,6 +79,11 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'globals'], fu <span><%= materials.compositeMaterials[key].name %><a data-id="<%= key %>" class="editComposite">Settings...<a/></span></div>\ </label>\ <% }); %><br/>\ + <% if (_.keys(materials.compositeMaterials).length > 0) { %>\ + Offset (xyz): <input data-property="superCellIndex" data-key="x" value="<%= superCellIndex.x %>" placeholder="X" class="form-control intInput appState" type="text">\ + <input data-property="superCellIndex" data-key="y" value="<%= superCellIndex.y %>" placeholder="Y" class="form-control intInput appState" type="text">\ + <input data-property="superCellIndex" data-key="z" value="<%= superCellIndex.z %>" placeholder="Z" class="form-control intInput appState" type="text"><br/><br/>\ + <% } %>\ <a id="navToCompositeMenu" href="#" class="btn btn-block btn-lg btn-default">+ Create New Composite Material</a><br/>\ <a id="compositeFromLattice" href="#" class="btn btn-block btn-lg btn-default">New Composite From Current Assembly</a><br/>\ <% } %>\ diff --git a/js/menus/MenuWrapperView.js b/js/menus/MenuWrapperView.js index 08f3a2d764f0156152dff233c6e0fb6a0e53115e..6d3b270dd66081ff27eab35c8a0ceb509b78e1ca 100644 --- a/js/menus/MenuWrapperView.js +++ b/js/menus/MenuWrapperView.js @@ -121,9 +121,10 @@ define(['jquery', 'underscore', 'plist', 'backbone', 'lattice'], function($, _, newVal = parseFloat(newVal); if (key){ - var value = _.clone(this._getPropertyOwner($target).get(property)); + var value = this._getPropertyOwner($target).get(property).clone(); value[key] = newVal; this._getPropertyOwner($target).set(property, value); + return; } this._getPropertyOwner($target).set(property, newVal); }, diff --git a/js/models/AppState.js b/js/models/AppState.js index a6059661750d6abc39c5c1e554e61c73f6e9369e..126278b72b8ee8879cdfd25ef82ec54fd1b9435f 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -34,7 +34,7 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist'], function(_, B cellsVisible: true, superCellIndex: new THREE.Vector3(0,0,0),//offset of superCell adds - superCellRange: new THREE.Vector3(4,1,1), + superCellRange: new THREE.Vector3(1,1,1), realisticColorScheme: false, @@ -135,7 +135,7 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist'], function(_, B } else this.downKeys[e.keyCode] = false; // console.log(e); - // console.log(e.keyCode); +// console.log(e.keyCode); switch(e.keyCode){ case 8://delete key - causes back nav in chrome, super annoying e.preventDefault(); @@ -165,6 +165,8 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist'], function(_, B } else { globals.fileSaver.save(); } + } else { + if (state) this.set("superCellIndex", this._incrementSuperCellIndex("y", this.get("superCellIndex").clone())); } break; case 79://o open @@ -192,29 +194,39 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist'], function(_, B this.set("superCellRange", range); } break; - case 81://q - increase supercell index - if (this.lattice.get("connectionType") != "gik") break; - if (state) { - var index = this.get("superCellIndex").clone(); - index.x += 1; - if (index.x > this.get("superCellRange").x-1) index.x = 0; - this.set("superCellIndex", index); - } + case 87://w - increase supercell index + console.log(this.get("superCellIndex")); + if (state) this.set("superCellIndex", this._incrementSuperCellIndex("x", this.get("superCellIndex").clone())); + break; + case 81://q - decrease supercell index + if (state) this.set("superCellIndex", this._decrementSuperCellIndex("x", this.get("superCellIndex").clone())); break; case 65://a - decrease supercell index - if (this.lattice.get("connectionType") != "gik") break; - if (state) { - var index = this.get("superCellIndex").clone(); - index.x -= 1; - if (index.x < 0) index.x = this.get("superCellRange").x-1; - this.set("superCellIndex", index); - } + if (state) this.set("superCellIndex", this._decrementSuperCellIndex("y", this.get("superCellIndex").clone())); + break; + case 88://x - increase supercell index + if (state) this.set("superCellIndex", this._incrementSuperCellIndex("z", this.get("superCellIndex").clone())); + break; + case 90://z - decrease supercell index + if (state) this.set("superCellIndex", this._decrementSuperCellIndex("z", this.get("superCellIndex").clone())); break; default: break; } }, + _incrementSuperCellIndex: function(key, object){ + object[key] += 1; + if (object[key] > this.get("superCellRange")[key]-1) object[key] = 0; + return object; + }, + + _decrementSuperCellIndex: function(key, object){ + object[key] -= 1; + if (object[key] < 0) object[key] = this.get("superCellRange")[key]-1; + return object; + }, + _handleScroll: function(e){//disable two finger swipe back if (Math.abs(e.originalEvent.deltaX) > Math.abs(e.originalEvent.deltaY)) e.preventDefault(); }