From 5c8c2617a9383eb6fa8a346dff5d2fd4ae29d3a3 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Tue, 16 Jun 2015 10:09:01 -0700 Subject: [PATCH] min number of dimensions calls --- js/cells/supercells/DMASuperCell.js | 3 ++- js/highlighter/SuperCellHighlighter.js | 2 +- js/lattice/CompositeEditorLattice.js | 10 +++------- js/menus/CompositeMenu.js | 11 +++++++++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/js/cells/supercells/DMASuperCell.js b/js/cells/supercells/DMASuperCell.js index f5a5c673..7572fa30 100644 --- a/js/cells/supercells/DMASuperCell.js +++ b/js/cells/supercells/DMASuperCell.js @@ -14,7 +14,8 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], DMACell.call(this, json, superCell); var material = this.getMaterial(); - var range = (new THREE.Vector3(1,1,1)).add(material.cellsMax).sub(material.cellsMin); + var range = appState.get("superCellRange"); + if (material.cellsMax) (new THREE.Vector3(1,1,1)).add(material.cellsMax).sub(material.cellsMin); this.cells = this._makeChildCells(range, material); DMACell.prototype.setMode.call(this, null, function(){ diff --git a/js/highlighter/SuperCellHighlighter.js b/js/highlighter/SuperCellHighlighter.js index 81edab6a..7c649551 100644 --- a/js/highlighter/SuperCellHighlighter.js +++ b/js/highlighter/SuperCellHighlighter.js @@ -38,7 +38,7 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', ' _setRotation: function(direction){ - if (lattice.connectionType == "gik"){ + if (lattice.get("connectionType") == "gik"){ if (!this.highlightedObject) return; var index = this.highlightedObject.getAbsoluteIndex(); diff --git a/js/lattice/CompositeEditorLattice.js b/js/lattice/CompositeEditorLattice.js index 15b794af..ba377065 100644 --- a/js/lattice/CompositeEditorLattice.js +++ b/js/lattice/CompositeEditorLattice.js @@ -19,19 +19,15 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre color: null }), + __bindEvents: function(){ + }, + __initialize: function(options, callback){ if (!options.id || options.id == "") this.set("id", "super" + this.cid); if (!options.color || options.color == "") this.set("color", makeRandomColor(), {silent:true}); if (callback) callback(this); }, - initLatticeSubclass: function(subclass){ - var self = this; - require([subclass], function(subclassObject){ - _.extend(self, subclassObject); - }); - }, - diff --git a/js/menus/CompositeMenu.js b/js/menus/CompositeMenu.js index 6a70086c..3f6dd624 100644 --- a/js/menus/CompositeMenu.js +++ b/js/menus/CompositeMenu.js @@ -4,6 +4,8 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'globals'], function($, _, MenuParentView, plist, lattice, globals){ + var dimensions; + return MenuParentView.extend({ events: { @@ -20,8 +22,13 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'globals'], fu console.warn("no composite editor inited"); return; } - this.listenTo(lattice.compositeEditor, "change", this.render); + this.listenTo(lattice.compositeEditor, "change", function(){ + if (lattice.compositeEditor.changedAttributes().numCells !== undefined) dimensions = lattice.compositeEditor.calculateBoundingBox(); + this.render(); + }); this.listenTo(lattice, "change", this.render); + + dimensions = lattice.compositeEditor.calculateBoundingBox(); }, _changeRandomColor: function(e){ @@ -75,7 +82,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'globals'], fu { materialClass:lattice.get("materialClass"), materialType:lattice.get("materialType"), - dimensions: lattice.compositeEditor.calculateBoundingBox() + dimensions: dimensions }); }, -- GitLab