diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js index c233b4c52d0d7e174d5fda55e7852bc4f606b2d2..a091d5573d5a934dfbffe9cacadb15edd2178b9a 100644 --- a/js/cells/DMACell.js +++ b/js/cells/DMACell.js @@ -48,7 +48,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState'], DMACell.prototype.getIndex = function(){ var index = this.index.clone(); - console.log(index); +// console.log(index); index = this.getAbsoluteOrientation(index); if (this.superCell) index.add(this.superCell.getIndex()); return index; diff --git a/js/lattice/CubeLattice.js b/js/lattice/CubeLattice.js index 222d5612b4318834f91c9266504447dc5d432fc5..1fae3a4a6ec437f316cc1eb6e50eddf7dd31f305 100644 --- a/js/lattice/CubeLattice.js +++ b/js/lattice/CubeLattice.js @@ -38,9 +38,11 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th return 1+2*cellSeparation; }, - makeCellForLatticeType: function(indices){ + makeCellForLatticeType: function(indices, callback){ require(['cubeCell'], function(CubeCell){ - return new CubeCell(indices); + var cell = new CubeCell(indices); + if (callback) callback(cell); + return cell; }); }, diff --git a/js/lattice/GIKLattice.js b/js/lattice/GIKLattice.js index 0acb937d256272d0e64f6e459fcc1ffa8a406d57..be5d8ff0a72e5a8553bc126c1c8f3866b743df4d 100644 --- a/js/lattice/GIKLattice.js +++ b/js/lattice/GIKLattice.js @@ -39,9 +39,11 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th return 1.28*(1+2*cellSeparation); }, - makeCellForLatticeType: function(indices){ + makeCellForLatticeType: function(indices, callback){ require(['gikSuperCell'], function(GIKSuperCell){ - return new GIKSuperCell(indices); + var cell = new GIKSuperCell(indices); + if (callback) callback(cell); + return cell; }); }, diff --git a/js/lattice/KelvinLattice.js b/js/lattice/KelvinLattice.js index 917af049f8c4f9333653524637191bd42366e0b8..c67998c258c9150b35717b809bffba3ddfa95837 100644 --- a/js/lattice/KelvinLattice.js +++ b/js/lattice/KelvinLattice.js @@ -39,9 +39,11 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th return 2*Math.sqrt(2)+2*cellSeparation; }, - makeCellForLatticeType: function(indices){ + makeCellForLatticeType: function(indices, callback){ require(['kelvinCell'], function(KelvinCell){ - return new KelvinCell(indices); + var cell = new KelvinCell(indices); + if (callback) callback(cell); + return cell; }); }, diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index 2b7bf1cb733889ad150abfc29234450710260563..b17a97d63c780f181a15526e260f3c2cdf1547c4 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -64,10 +64,12 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre for (var y=relativeMin.y;y<=relativeMax.y;y++){ for (var z=relativeMin.z;z<=relativeMax.z;z++){ if (!cells[x][y][z]) { - var cell = this.makeCellForLatticeType(this._add({x:x, y:y, z:z}, cellsMin)); - cells[x][y][z] = cell; - newCells.push(cell); - this.set("numCells", this.get("numCells")+1); + var self = this; + var callback = function(cell){ + newCells.push(cell); + self.set("numCells", self.get("numCells")+1); + }; + cells[x][y][z] = this.makeCellForLatticeType(this._add({x:x, y:y, z:z}, cellsMin), callback); } else console.warn("already a cell there"); } } @@ -79,13 +81,16 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre addCellAtIndex: function(indices, noRender, noCheck){//no render no check from fill var cells = this.get("cells"); - if (!noCheck) this.checkForMatrixExpansion(cells, indices, indices); + if (!noCheck || noCheck === undefined) this.checkForMatrixExpansion(cells, indices, indices); var index = this._subtract(indices, this.get("cellsMin")); if (!cells[index.x][index.y][index.z]) { - cells[index.x][index.y][index.z] = this.makeCellForLatticeType(indices); - this.set("numCells", this.get("numCells")+1); - if (!noRender || noRender === undefined) three.render(); + var self = this; + var callback = function(){ + self.set("numCells", self.get("numCells")+1); + if (!noRender || noRender === undefined) three.render(); + }; + cells[index.x][index.y][index.z] = this.makeCellForLatticeType(indices, callback); } else console.warn("already a cell there"); }, diff --git a/js/lattice/OctaEdgeLattice.js b/js/lattice/OctaEdgeLattice.js index 94f88b558bb1b2043662c3e753fe09795a89368c..8dabb82fa2d1c37e62463acf8f15e77279e191f1 100644 --- a/js/lattice/OctaEdgeLattice.js +++ b/js/lattice/OctaEdgeLattice.js @@ -64,9 +64,11 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th return 2/Math.sqrt(6)+2*cellSeparation; }, - makeCellForLatticeType: function(indices){ + makeCellForLatticeType: function(indices, callback){ require(['octaEdgeCell'], function(OctaEdgeCell){ - return new OctaEdgeCell(indices); + var cell = new OctaEdgeCell(indices); + if (callback) callback(cell); + return cell; }); }, diff --git a/js/lattice/OctaFaceLattice.js b/js/lattice/OctaFaceLattice.js index b2667cd42cb3e8a08175e4bca732192d34f85e54..582033791c129c3f62d25f870ee6d8fefe81b024 100644 --- a/js/lattice/OctaFaceLattice.js +++ b/js/lattice/OctaFaceLattice.js @@ -47,9 +47,11 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th return 2/Math.sqrt(6)+2*cellSeparation; }, - makeCellForLatticeType: function(indices){ + makeCellForLatticeType: function(indices, callback){ require(['octaFaceCell'], function(OctaFaceCell){ - return new OctaFaceCell(indices); + var cell = new OctaFaceCell(indices); + if (callback) callback(cell); + return cell; }); }, @@ -61,9 +63,5 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th } }; - _.each(_.keys(OctaFaceLattice), function(key){ - console.log(key); - }); - return OctaFaceLattice; }); diff --git a/js/lattice/OctaRotEdgeLattice.js b/js/lattice/OctaRotEdgeLattice.js index ed8a0cd5b285095ac2557dfaf2869f78934b6450..7b5d359baf812cffcb5544628819e8fb90b6d258 100644 --- a/js/lattice/OctaRotEdgeLattice.js +++ b/js/lattice/OctaRotEdgeLattice.js @@ -50,9 +50,11 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th return Math.sqrt(2)/2 + 2*cellSeparation; }, - makeCellForLatticeType: function(indices){ + makeCellForLatticeType: function(indices, callback){ require(['octaRotEdgeCell'], function(OctaRotEdgeCell){ - return new OctaRotEdgeCell(indices); + var cell = new OctaRotEdgeCell(indices); + if (callback) callback(cell); + return cell; }); }, diff --git a/js/lattice/OctaVertexLattice.js b/js/lattice/OctaVertexLattice.js index a8f254f33c9306aa5b052c54befdb4fe3f83ecd9..babdeecff7f4955c91f14a48f3732da073e63d38 100644 --- a/js/lattice/OctaVertexLattice.js +++ b/js/lattice/OctaVertexLattice.js @@ -46,9 +46,11 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th return Math.sqrt(2)+2*cellSeparation; }, - makeCellForLatticeType: function(indices){ + makeCellForLatticeType: function(indices, callback){ require(['octaVertexCell'], function(OctaVertexCell){ - return new OctaVertexCell(indices); + var cell = new OctaVertexCell(indices); + if (callback) callback(cell); + return cell; }); }, diff --git a/js/lattice/TruncatedCubeLattice.js b/js/lattice/TruncatedCubeLattice.js index 485507d57e823b70837cc1068c0ebfcfb8219479..7ba455af2a8cc0fd96e33b1ebc07745f065be7f3 100644 --- a/js/lattice/TruncatedCubeLattice.js +++ b/js/lattice/TruncatedCubeLattice.js @@ -39,9 +39,11 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th return Math.sqrt(2)+2*cellSeparation; }, - makeCellForLatticeType: function(indices){ + makeCellForLatticeType: function(indices, callback){ require(['truncatedCubeCell'], function(TruncatedCubeCell){ - return new TruncatedCubeCell(indices); + var cell = new TruncatedCubeCell(indices); + if (callback) callback(cell); + return cell; }); }, diff --git a/js/main.js b/js/main.js index eb0b60f7d943ef31f89c870435f62720f0eed6e9..1182e50b15d1e747fb1e9370d3ca060ba20a3787 100644 --- a/js/main.js +++ b/js/main.js @@ -102,11 +102,11 @@ require.config({ }); -require.onError = function (err) { - console.log(err.requireType); - console.log(err.requireModules); - throw err; -}; +//require.onError = function (err) { +// console.log(err.requireType); +// console.log(err.requireModules); +// throw err; +//}; //init stuff require(['appState', 'lattice', 'menuWrapper', 'navbar', 'ribbon', 'threeModel', 'threeView', 'flatUI'],