From a807fba747708f7ed76bb6e9e96de081c78b3b13 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Fri, 12 Jun 2015 16:08:03 -0700 Subject: [PATCH] ask latice subclasses for require filename --- js/lattice/CubeLattice.js | 7 ++----- js/lattice/GIKLattice.js | 7 ++----- js/lattice/KelvinLattice.js | 7 ++----- js/lattice/LatticeBase.js | 7 +++++++ js/lattice/OctaEdgeLattice.js | 7 ++----- js/lattice/OctaFaceLattice.js | 7 ++----- js/lattice/OctaRotEdgeLattice.js | 7 ++----- js/lattice/OctaVertexLattice.js | 7 ++----- js/lattice/TetraStackedLattice.js | 7 ++----- js/lattice/TetraVertexLattice.js | 7 ++----- js/lattice/TruncatedCubeLattice.js | 7 ++----- 11 files changed, 27 insertions(+), 50 deletions(-) diff --git a/js/lattice/CubeLattice.js b/js/lattice/CubeLattice.js index de8c82b3..b3499ff3 100644 --- a/js/lattice/CubeLattice.js +++ b/js/lattice/CubeLattice.js @@ -42,11 +42,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return 1+2*cellSeparation; }, - makeCellForLatticeType: function(json, callback){ - require(['cubeCell'], function(CubeCell){ - var cell = new CubeCell(json); - if (callback) callback(cell); - }); + getCellSubclassFile: function(){ + return "cubeCell"; }, _undo: function(){//remove all the mixins, this will help with debugging later diff --git a/js/lattice/GIKLattice.js b/js/lattice/GIKLattice.js index 89a86daf..1218f0da 100644 --- a/js/lattice/GIKLattice.js +++ b/js/lattice/GIKLattice.js @@ -44,11 +44,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return 1.28*(1+2*cellSeparation); }, - makeCellForLatticeType: function(json, callback){ - require(['gikSuperCell'], function(GIKSuperCell){ - var cell = new GIKSuperCell(json); - if (callback) callback(cell); - }); + getCellSubclassFile: function(){ + return "gikSuperCell"; }, _undo: function(){//remove all the mixins, this will help with debugging later diff --git a/js/lattice/KelvinLattice.js b/js/lattice/KelvinLattice.js index 763a8585..1b850891 100644 --- a/js/lattice/KelvinLattice.js +++ b/js/lattice/KelvinLattice.js @@ -43,11 +43,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return 2*Math.sqrt(2)+2*cellSeparation; }, - makeCellForLatticeType: function(json, callback){ - require(['kelvinCell'], function(KelvinCell){ - var cell = new KelvinCell(json); - if (callback) callback(cell); - }); + getCellSubclassFile: function(){ + return "kelvinCell"; }, _undo: function(){//remove all the mixins, this will help with debugging later diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js index cbeb311b..b1a4a640 100644 --- a/js/lattice/LatticeBase.js +++ b/js/lattice/LatticeBase.js @@ -92,6 +92,13 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre //add/remove cells + makeCellForLatticeType: function(json, callback){ + require([this.getCellSubclassFile()], function(CellSubclass){ + var cell = new CellSubclass(json); + if (callback) callback(cell); + }); + }, + addCellsInRange: function(range){//add a block of cells (extrude) this.checkForMatrixExpansion(this.sparseCells, range.max, range.min); diff --git a/js/lattice/OctaEdgeLattice.js b/js/lattice/OctaEdgeLattice.js index 46c8e5b6..f5ca9901 100644 --- a/js/lattice/OctaEdgeLattice.js +++ b/js/lattice/OctaEdgeLattice.js @@ -80,11 +80,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return 2/Math.sqrt(6)+2*cellSeparation; }, - makeCellForLatticeType: function(json, callback){ - require(['octaEdgeCell'], function(OctaEdgeCell){ - var cell = new OctaEdgeCell(json); - if (callback) callback(cell); - }); + getCellSubclassFile: function(){ + return "octaEdgeCell"; }, _undo: function(){//remove all the mixins, this will help with debugging later diff --git a/js/lattice/OctaFaceLattice.js b/js/lattice/OctaFaceLattice.js index 7313dc02..5e0d1d06 100644 --- a/js/lattice/OctaFaceLattice.js +++ b/js/lattice/OctaFaceLattice.js @@ -49,11 +49,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return 2/Math.sqrt(6)+2*cellSeparation; }, - makeCellForLatticeType: function(json, callback){ - require(['octaFaceCell'], function(OctaFaceCell){ - var cell = new OctaFaceCell(json); - if (callback) callback(cell); - }); + getCellSubclassFile: function(){ + return "octaFaceCell"; }, _undo: function(){//remove all the mixins diff --git a/js/lattice/OctaRotEdgeLattice.js b/js/lattice/OctaRotEdgeLattice.js index 3e37f740..a12be95e 100644 --- a/js/lattice/OctaRotEdgeLattice.js +++ b/js/lattice/OctaRotEdgeLattice.js @@ -47,11 +47,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return Math.sqrt(2)/2 + 2*cellSeparation; }, - makeCellForLatticeType: function(json, callback){ - require(['octaRotEdgeCell'], function(OctaRotEdgeCell){ - var cell = new OctaRotEdgeCell(json); - if (callback) callback(cell); - }); + getCellSubclassFile: function(){ + return "octaRotEdgeCell"; }, _undo: function(){//remove all the mixins diff --git a/js/lattice/OctaVertexLattice.js b/js/lattice/OctaVertexLattice.js index 242c8b6f..7a005de0 100644 --- a/js/lattice/OctaVertexLattice.js +++ b/js/lattice/OctaVertexLattice.js @@ -42,11 +42,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return Math.sqrt(2)+2*cellSeparation; }, - makeCellForLatticeType: function(json, callback){ - require(['octaVertexCell'], function(OctaVertexCell){ - var cell = new OctaVertexCell(json); - if (callback) callback(cell); - }); + getCellSubclassFile: function(){ + return "octaVertexCell"; }, _undo: function(){//remove all the mixins, this will help with debugging later diff --git a/js/lattice/TetraStackedLattice.js b/js/lattice/TetraStackedLattice.js index 5e602500..7694dacb 100644 --- a/js/lattice/TetraStackedLattice.js +++ b/js/lattice/TetraStackedLattice.js @@ -49,11 +49,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return 2/Math.sqrt(6)+2*cellSeparation; }, - makeCellForLatticeType: function(json, callback){ - require(['tetraStackedCell'], function(TetraStackedCell){ - var cell = new TetraStackedCell(json); - if (callback) callback(cell); - }); + getCellSubclassFile: function(){ + return "tetraStackedCell"; }, _undo: function(){//remove all the mixins, this will help with debugging later diff --git a/js/lattice/TetraVertexLattice.js b/js/lattice/TetraVertexLattice.js index c5a466dc..a1c2c8ac 100644 --- a/js/lattice/TetraVertexLattice.js +++ b/js/lattice/TetraVertexLattice.js @@ -51,11 +51,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return 2/Math.sqrt(6)+2*cellSeparation; }, - makeCellForLatticeType: function(json, callback){ - require(['tetraVertexCell'], function(TetraVertexCell){ - var cell = new TetraVertexCell(json); - if (callback) callback(cell); - }); + getCellSubclassFile: function(){ + return "tetraVertexCell"; }, _undo: function(){//remove all the mixins, this will help with debugging later diff --git a/js/lattice/TruncatedCubeLattice.js b/js/lattice/TruncatedCubeLattice.js index c24d05b8..4ee6ffc0 100644 --- a/js/lattice/TruncatedCubeLattice.js +++ b/js/lattice/TruncatedCubeLattice.js @@ -43,11 +43,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return Math.sqrt(2)+2*cellSeparation; }, - makeCellForLatticeType: function(json, callback){ - require(['truncatedCubeCell'], function(TruncatedCubeCell){ - var cell = new TruncatedCubeCell(json); - if (callback) callback(cell); - }); + getCellSubclassFile: function(){ + return "truncatedCubeCell"; }, _undo: function(){//remove all the mixins, this will help with debugging later -- GitLab