diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js index 8400570a43ebc01bbc918a5de7811dc80ea8056b..b6b4185e98b42199dddfcdc1e80db5d66920a8ff 100644 --- a/js/cells/DMACell.js +++ b/js/cells/DMACell.js @@ -399,15 +399,15 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', ' }; DMACell.prototype.xScale = function(){ - return lattice.xScale(0); + return lattice.xScale(); }; DMACell.prototype.yScale = function(){ - return lattice.yScale(0); + return lattice.yScale(); }; DMACell.prototype.zScale = function(){ - return lattice.zScale(0); + return lattice.zScale(); }; diff --git a/js/cells/supercells/GIKSuperCell.js b/js/cells/supercells/GIKSuperCell.js index 3738fc66094deec03147c4404c25458ea05b02a7..ea7f1fe997264638e6fdd00670ddf974a48bca5f 100644 --- a/js/cells/supercells/GIKSuperCell.js +++ b/js/cells/supercells/GIKSuperCell.js @@ -10,7 +10,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', var unitGeos = {}; function makePartWithLength(length){ - var geo = new THREE.BoxGeometry(lattice.xScale(0),lattice.yScale(0),lattice.zScale(0)); + var geo = new THREE.BoxGeometry(lattice.xScale(),lattice.yScale(),lattice.zScale()); geo.applyMatrix(new THREE.Matrix4().makeScale(length, 1, 1)); geo.applyMatrix(new THREE.Matrix4().makeTranslation(length/2-0.5, 0, 0)); return geo; diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index 1352ff6d64d4cda50ed25faa8eacf3ae52643b6c..1d4890b6f7147a992bebc754472cd908f00ad7c9 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -23,21 +23,17 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre denseCellsMin: null, overlapDetected: false, - nodes: [], - - cellSeparation: {xy:0, z:0}//spacing for connectors/joints + nodes: [] }), __initialize: function(){ - //todo change latticeType this.listenTo(this, "change:partType change:latticeType", this._updatePartType); this.listenTo(this, "change:cellType change:connectionType", function(){ this._updateLatticeConfig();//pass no params }); this.listenTo(this, "change:latticeType", this._updateLatticeType); - this.listenTo(this, "change:cellSeparation", this._updateCellSeparation); this.listenTo(appState, "change:currentNav", this._navChanged); this.listenTo(this, "change:cellsMin change:cellsMax", function(){ @@ -85,6 +81,10 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre var newMaterialClass = (latticeData.materialClasses || _.keys(plist.allMaterialClasses))[0]; appState.set("materialClass", newMaterialClass); + + if (latticeData.options){ + if (latticeData.options.gikLength) appState.set("gikLength", latticeData.options.gikLength); + } }, _setDefaultCellMode: function(){//if no part associated with this lattice type @@ -107,25 +107,25 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return subclass; }, + xScale: function(){ + return this.get("aspectRatio").x; + }, + + yScale: function(){ + return this.get("aspectRatio").y; + }, + zScale: function(){ + return this.get("aspectRatio").z; + }, - //events - _updateCellSeparation: function(){ - var cellSep = this.get("cellSeparation"); - globals.basePlane.updateXYSeparation(cellSep.xy); - var cellMode = appState.get("cellMode"); - var partType = this.get("partType"); -// this._iterCells(this.cells, function(cell){ -// if (cell) cell.updateForScale(cellMode, partType); -// }); - three.render(); - }, + //events __clearCells: function(silent){ three.removeAllCells();//todo add flag in cell destroy to avoid redundancy here diff --git a/js/lattice/latticeSubclasses/CubeLattice.js b/js/lattice/latticeSubclasses/CubeLattice.js index b3499ff394153a39dbf867b8958dc811c9ae451d..df951705ce2e74c43bb33c4c1985da720397b24e 100644 --- a/js/lattice/latticeSubclasses/CubeLattice.js +++ b/js/lattice/latticeSubclasses/CubeLattice.js @@ -28,20 +28,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return this._positionForIndex(index); }, - xScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy; - return 1+2*cellSeparation; - }, - - yScale: function(cellSeparation){ - return this.xScale(cellSeparation); - }, - - zScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z; - return 1+2*cellSeparation; - }, - getCellSubclassFile: function(){ return "cubeCell"; }, diff --git a/js/lattice/latticeSubclasses/GIKLattice.js b/js/lattice/latticeSubclasses/GIKLattice.js index d95bd2259b061fdefe428d10561bfcd6fb6e583a..9458c80d87d6e02f1b975a5bc5b512a1af4950e8 100644 --- a/js/lattice/latticeSubclasses/GIKLattice.js +++ b/js/lattice/latticeSubclasses/GIKLattice.js @@ -29,20 +29,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return this._positionForIndex(index); }, - xScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy; - return 1+2*cellSeparation; - }, - - yScale: function(cellSeparation){ - return this.xScale(cellSeparation); - }, - - zScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z; - return 1.28*(1+2*cellSeparation); - }, - _zIndexRotation: function(index){ if (index.z%2 == 0) return Math.PI/2; return 0; diff --git a/js/lattice/latticeSubclasses/HexagonalLattice.js b/js/lattice/latticeSubclasses/HexagonalLattice.js index b62b5c27dd5df9a616e5070a8c78c4a69c1db3e4..950668e85595300981cc59b2d962873d02e9ed36 100644 --- a/js/lattice/latticeSubclasses/HexagonalLattice.js +++ b/js/lattice/latticeSubclasses/HexagonalLattice.js @@ -36,21 +36,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return position; }, - xScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy; - return Math.sqrt(3)+2*cellSeparation; - }, - - yScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy; - return 1.5+2*cellSeparation; - }, - - zScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z; - return 1+2*cellSeparation; - }, - getCellSubclassFile: function(){ return "hexCell"; }, diff --git a/js/lattice/latticeSubclasses/HexagonalRotLattice.js b/js/lattice/latticeSubclasses/HexagonalRotLattice.js index 661869041f7e488fc41024cbc7324df3969455f0..458a98a98746f69fd274854eb33f9ba9dbc3c44b 100644 --- a/js/lattice/latticeSubclasses/HexagonalRotLattice.js +++ b/js/lattice/latticeSubclasses/HexagonalRotLattice.js @@ -42,21 +42,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return position; }, - xScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy; - return 3+2*cellSeparation; - }, - - yScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy; - return 1+2*cellSeparation; - }, - - zScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z; - return Math.sqrt(3)/2+2*cellSeparation; - }, - getCellSubclassFile: function(){ return "hexRotCell"; }, diff --git a/js/lattice/latticeSubclasses/KelvinLattice.js b/js/lattice/latticeSubclasses/KelvinLattice.js index 1b850891da04f57cd249a94e5401214b0a1cc25c..1ba33649528568d24e119fd9637c89eed78c59c9 100644 --- a/js/lattice/latticeSubclasses/KelvinLattice.js +++ b/js/lattice/latticeSubclasses/KelvinLattice.js @@ -29,20 +29,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return this._positionForIndex(index); }, - xScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy; - return 2*Math.sqrt(2)+2*cellSeparation; - }, - - yScale: function(cellSeparation){ - return this.xScale(cellSeparation); - }, - - zScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z; - return 2*Math.sqrt(2)+2*cellSeparation; - }, - getCellSubclassFile: function(){ return "kelvinCell"; }, diff --git a/js/lattice/latticeSubclasses/OctaEdgeLattice.js b/js/lattice/latticeSubclasses/OctaEdgeLattice.js index f5ca9901482bdd2ad8fe66f2c093d67147d1434c..522706474bce26655640ce0d4bd6730f06f09867 100644 --- a/js/lattice/latticeSubclasses/OctaEdgeLattice.js +++ b/js/lattice/latticeSubclasses/OctaEdgeLattice.js @@ -66,20 +66,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre // return position; // }, - xScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy; - return 1+2*cellSeparation; - }, - - yScale: function(cellSeparation){ - return this.xScale(cellSeparation)/2*Math.sqrt(3); - }, - - zScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z; - return 2/Math.sqrt(6)+2*cellSeparation; - }, - getCellSubclassFile: function(){ return "octaEdgeCell"; }, diff --git a/js/lattice/latticeSubclasses/OctaFaceLattice.js b/js/lattice/latticeSubclasses/OctaFaceLattice.js index 5e0d1d0692299419efc64a74e24dcb12a149cd04..766007f68bbb1850c1cf98b1aa5c2d1ae46bbd37 100644 --- a/js/lattice/latticeSubclasses/OctaFaceLattice.js +++ b/js/lattice/latticeSubclasses/OctaFaceLattice.js @@ -35,20 +35,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return position; }, - xScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy; - return 1+2*cellSeparation; - }, - - yScale: function(cellSeparation){ - return this.xScale(cellSeparation)/2*Math.sqrt(3); - }, - - zScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z; - return 2/Math.sqrt(6)+2*cellSeparation; - }, - getCellSubclassFile: function(){ return "octaFaceCell"; }, diff --git a/js/lattice/latticeSubclasses/OctaRotEdgeLattice.js b/js/lattice/latticeSubclasses/OctaRotEdgeLattice.js index bf325be9d49ccc2ac90f6648b5a319bbfc6dc4a8..bd381b61d7bab24450c2ca2c2b03891bd74739df 100644 --- a/js/lattice/latticeSubclasses/OctaRotEdgeLattice.js +++ b/js/lattice/latticeSubclasses/OctaRotEdgeLattice.js @@ -39,20 +39,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return position; }, - xScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy; - return 1 + 2*cellSeparation; - }, - - yScale: function(cellSeparation){ - return this.xScale(cellSeparation); - }, - - zScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z; - return Math.sqrt(2)/2 + 2*cellSeparation; - }, - getCellSubclassFile: function(){ return "octaRotEdgeCell"; }, diff --git a/js/lattice/latticeSubclasses/OctaVertexLattice.js b/js/lattice/latticeSubclasses/OctaVertexLattice.js index 7a005de01543c3cefea2134de30242a43ed30e73..515ef779db67861598d80bba14f48c5af50d1223 100644 --- a/js/lattice/latticeSubclasses/OctaVertexLattice.js +++ b/js/lattice/latticeSubclasses/OctaVertexLattice.js @@ -28,20 +28,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return this._positionForIndex(index); }, - xScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy; - return Math.sqrt(2)+2*cellSeparation; - }, - - yScale: function(cellSeparation){ - return this.xScale(cellSeparation); - }, - - zScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z; - return Math.sqrt(2)+2*cellSeparation; - }, - getCellSubclassFile: function(){ return "octaVertexCell"; }, diff --git a/js/lattice/latticeSubclasses/TetraStackedLattice.js b/js/lattice/latticeSubclasses/TetraStackedLattice.js index 7694dacb7cd2632a889adb65c23440cd0e236de8..e726f022713a406b117cd2d71fad7235fd671bf8 100644 --- a/js/lattice/latticeSubclasses/TetraStackedLattice.js +++ b/js/lattice/latticeSubclasses/TetraStackedLattice.js @@ -35,20 +35,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return position; }, - xScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy; - return 1+2*cellSeparation; - }, - - yScale: function(cellSeparation){ - return this.xScale(cellSeparation)/2*Math.sqrt(3); - }, - - zScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z; - return 2/Math.sqrt(6)+2*cellSeparation; - }, - getCellSubclassFile: function(){ return "tetraStackedCell"; }, diff --git a/js/lattice/latticeSubclasses/TetraVertexLattice.js b/js/lattice/latticeSubclasses/TetraVertexLattice.js index a1c2c8ac1d34c57de45561a4f7ff1303ca23763a..41913d7cbeb09dd79c942f6f6e6e871f0758edaa 100644 --- a/js/lattice/latticeSubclasses/TetraVertexLattice.js +++ b/js/lattice/latticeSubclasses/TetraVertexLattice.js @@ -37,20 +37,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return position; }, - xScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy; - return 1+2*cellSeparation; - }, - - yScale: function(cellSeparation){ - return this.xScale(cellSeparation)/2*Math.sqrt(3); - }, - - zScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z; - return 2/Math.sqrt(6)+2*cellSeparation; - }, - getCellSubclassFile: function(){ return "tetraVertexCell"; }, diff --git a/js/lattice/latticeSubclasses/TruncatedCubeLattice.js b/js/lattice/latticeSubclasses/TruncatedCubeLattice.js index 4ee6ffc0020b16a7078703c619974888251d508f..1b0f12d055a3c1622c36ef5bf1e46a75ba95dca0 100644 --- a/js/lattice/latticeSubclasses/TruncatedCubeLattice.js +++ b/js/lattice/latticeSubclasses/TruncatedCubeLattice.js @@ -29,20 +29,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre return this._positionForIndex(index); }, - xScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy; - return Math.sqrt(2)+2*cellSeparation; - }, - - yScale: function(cellSeparation){ - return this.xScale(cellSeparation); - }, - - zScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z; - return Math.sqrt(2)+2*cellSeparation; - }, - getCellSubclassFile: function(){ return "truncatedCubeCell"; }, diff --git a/js/menus/LatticeMenuView.js b/js/menus/LatticeMenuView.js index 4aaa1845d6f4280b2475e3cf81515ae1b0430fe7..8be261c9b81139837141192e1049577776a384f5 100644 --- a/js/menus/LatticeMenuView.js +++ b/js/menus/LatticeMenuView.js @@ -21,9 +21,4 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'text!latticeM template: _.template(template) }); -}); - -//Cell Separation <% if (connectionType != "freeformFace"){ %>(xy, z):   \ -// \ -//<% } else { %>( radial ):   <% } %>\ -//

\ \ No newline at end of file +}); \ No newline at end of file diff --git a/js/menus/templates/LatticeMenuView.html b/js/menus/templates/LatticeMenuView.html index ce5210bed28cff20deae7006d1a48e80d16b9945..2e5923c2409d63fc1f93587491156148e7e07e6a 100644 --- a/js/menus/templates/LatticeMenuView.html +++ b/js/menus/templates/LatticeMenuView.html @@ -33,8 +33,4 @@ Aspect Ratio:   Part Length:  

<% } %> Clear All Cells
-Num Cells:  <%= numCells %>
- - - - \ No newline at end of file +Num Cells:  <%= numCells %>
\ No newline at end of file diff --git a/js/menus/templates/PartMenuView.html b/js/menus/templates/PartMenuView.html index 038f98ba0b7ac3f6506cd672d667cfd6d173b130..329494f3d8819f2a18261b2b8d2c5a4f38efbbf4 100644 --- a/js/menus/templates/PartMenuView.html +++ b/js/menus/templates/PartMenuView.html @@ -7,7 +7,4 @@ Part Type:   
  • <%= val.name %>
  • <% }); %> -

    -
    \ No newline at end of file +

    \ No newline at end of file diff --git a/js/plists/PList.js b/js/plists/PList.js index 9650231724a9e95261c7c5a2f7f99dc40445fe77..9b80dcb4a1a2a9d050572674aab30d95863ae783 100644 --- a/js/plists/PList.js +++ b/js/plists/PList.js @@ -103,13 +103,13 @@ define(['three'], function(THREE){ name: "Triangle" } }, - aspectRatio: new THREE.Vector3(1,1,1), + aspectRatio: new THREE.Vector3(1,1/2*Math.sqrt(3),2/Math.sqrt(6)), materialClasses: ['mechanical'] }, default: { name: "Default", parts: null, - aspectRatio: new THREE.Vector3(1,1,1) + aspectRatio: new THREE.Vector3(1,1/2*Math.sqrt(3),2/Math.sqrt(6)) } } }, @@ -131,13 +131,13 @@ define(['three'], function(THREE){ name: "Snap Voxel (low res)" } }, - aspectRatio: new THREE.Vector3(1,1,1), + aspectRatio: new THREE.Vector3(1,1,Math.sqrt(2)/2), materialClasses: ['mechanical'] }, default: { name: "Default", parts: null, - aspectRatio: new THREE.Vector3(1,1,1) + aspectRatio: new THREE.Vector3(1,1,Math.sqrt(2)/2) } } }, @@ -159,13 +159,13 @@ define(['three'], function(THREE){ } // xShape:"X" }, - aspectRatio: new THREE.Vector3(1,1,1), + aspectRatio: new THREE.Vector3(Math.sqrt(2),Math.sqrt(2),Math.sqrt(2)), materialClasses: ['mechanical'] }, default: { name: "Default", parts: null, - aspectRatio: new THREE.Vector3(1,1,1) + aspectRatio: new THREE.Vector3(Math.sqrt(2),Math.sqrt(2),Math.sqrt(2)) } } } @@ -181,11 +181,12 @@ define(['three'], function(THREE){ default: { name: "Default", parts: null, - aspectRatio: new THREE.Vector3(1,1,1) + aspectRatio: new THREE.Vector3(1,1/2*Math.sqrt(3),2/Math.sqrt(6)) } } } } + //vetex (1, 1//2*Math.sqrt(3), 2/Math.sqrt(6)) }, cube: { name: "Cube", @@ -215,8 +216,27 @@ define(['three'], function(THREE){ name: "Micro LEGO (low res)" } }, - aspectRatio: new THREE.Vector3(1,1,1.28), - materialClasses: ['electronic'] + aspectRatio: new THREE.Vector3(1,1,5),//1.28 + materialClasses: ['electronic'], + options: { + gikLength: 4 + } + }, + dnaBricks: { + name: "DNA Bricks", + parts: { + dnaLego: { + name: "Lego Blocks" + }, + dnaStraight: { + name: "DNA (straight chains)" + } + }, + aspectRatio: new THREE.Vector3(1,1,1), + materialClasses: ['mechanical'], + options: { + gikLength: 2 + } }, default: { name: "Default", @@ -237,7 +257,7 @@ define(['three'], function(THREE){ default: { name: "Default", parts: null, - aspectRatio: new THREE.Vector3(1,1,1) + aspectRatio: new THREE.Vector3(Math.sqrt(2),Math.sqrt(2),Math.sqrt(2)) } } } @@ -253,7 +273,7 @@ define(['three'], function(THREE){ default: { name: "Default", parts: null, - aspectRatio: new THREE.Vector3(1,1,1) + aspectRatio: new THREE.Vector3(2*Math.sqrt(2),2*Math.sqrt(2),2*Math.sqrt(2)) } } } @@ -269,7 +289,7 @@ define(['three'], function(THREE){ default: { name: "Default", parts: null, - aspectRatio: new THREE.Vector3(1,1,1) + aspectRatio: new THREE.Vector3(Math.sqrt(3),1.5,1) } } }, @@ -280,7 +300,7 @@ define(['three'], function(THREE){ default: { name: "Default", parts: null, - aspectRatio: new THREE.Vector3(1,1,1) + aspectRatio: new THREE.Vector3(3,1,Math.sqrt(3)/2) } } } diff --git a/js/simulation/electronics/LatticeEsim.js b/js/simulation/electronics/LatticeEsim.js index 6614c3c5775ebd2fc5e20c9258a241ba228f0279..73a88c12b6c9b91f0dbaad764c5cf44a06758a76 100644 --- a/js/simulation/electronics/LatticeEsim.js +++ b/js/simulation/electronics/LatticeEsim.js @@ -104,7 +104,7 @@ define(['lattice', 'appState', 'three', 'threeModel', 'numeric', 'eSim', 'eSimFi } }); - var offset = this.get("cellsMin").clone().sub(new THREE.Vector3(1/(2*resolution)+this.xScale(0)/2, 1/(2*resolution)+this.yScale(0)/2, 1/(2*resolution)+this.zScale(0)/2)); + var offset = this.get("cellsMin").clone().sub(new THREE.Vector3(1/(2*resolution)+this.xScale()/2, 1/(2*resolution)+this.yScale()/2, 1/(2*resolution)+this.zScale()/2)); var dataRange = []; _.each(conductorGroups, function(group){ dataRange.push(group.voltage);