From 9145402adcc66c16da8987ca4e634150db568af6 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Mon, 17 Aug 2015 11:25:19 -0400 Subject: [PATCH] hex cells --- js/cells/HexagonalCell.js | 30 +++++++++++++++++++ .../latticeSubclasses/HexagonalLattice.js | 20 ++++++------- js/main.js | 1 + js/menus/templates/NavViewMenu.html | 3 +- js/plists/PList.js | 2 +- 5 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 js/cells/HexagonalCell.js diff --git a/js/cells/HexagonalCell.js b/js/cells/HexagonalCell.js new file mode 100644 index 00000000..e3cd7d14 --- /dev/null +++ b/js/cells/HexagonalCell.js @@ -0,0 +1,30 @@ +/** + * Created by aghassaei on 8/17/15. + */ + + +define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], + function(_, THREE, three, lattice, appState, DMACell){ + + var unitCellGeo = new THREE.CylinderGeometry(Math.sqrt(3)/2, Math.sqrt(3)/2, 1, 6); + unitCellGeo.applyMatrix(new THREE.Matrix4().makeRotationX(Math.PI/2)); + + function HexagonalCell(json, superCell){ + DMACell.call(this, json, superCell); + } + HexagonalCell.prototype = Object.create(DMACell.prototype); + + HexagonalCell.prototype._getGeometry = function(){ + return unitCellGeo; + }; + +// HexagonalCell.prototype._buildWireframe = function(mesh){//abstract mesh representation of cell +// var wireframe = new THREE.BoxHelper(mesh); +// wireframe.material.color.set(0x000000); +// wireframe.matrixWorld = mesh.matrixWorld; +// wireframe.matrixAutoUpdate = true; +// return wireframe; +// }; + + return HexagonalCell; +}); \ No newline at end of file diff --git a/js/lattice/latticeSubclasses/HexagonalLattice.js b/js/lattice/latticeSubclasses/HexagonalLattice.js index bceb37d7..24a6d36d 100644 --- a/js/lattice/latticeSubclasses/HexagonalLattice.js +++ b/js/lattice/latticeSubclasses/HexagonalLattice.js @@ -6,14 +6,14 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'threeModel'], function(_, Backbone, appState, globals, plist, THREE, three){ - var KelvinLattice = { + var HexLattice = { _initLatticeType: function(){ - require(['hexBaseplane'], function(SquareBasePlane){ - globals.basePlane = new SquareBasePlane(); + require(['hexBaseplane'], function(BasePlaneClass){ + globals.basePlane = new BasePlaneClass(); }); - require([this.getHighlighterFile()], function(TruncatedCubeHighlighter){ - globals.highlighter = new TruncatedCubeHighlighter(); + require([this.getHighlighterFile()], function(HighlighterClass){ + globals.highlighter = new HighlighterClass(); }); }, @@ -31,7 +31,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre xScale: function(cellSeparation){ if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy; - return 2*Math.sqrt(2)+2*cellSeparation; + return 2*Math.sqrt(3)+2*cellSeparation; }, yScale: function(cellSeparation){ @@ -40,21 +40,21 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre zScale: function(cellSeparation){ if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z; - return 2*Math.sqrt(2)+2*cellSeparation; + return 1+2*cellSeparation; }, getCellSubclassFile: function(){ - return "kelvinCell"; + return "hexCell"; }, _undo: function(){//remove all the mixins, this will help with debugging later var self = this; - _.each(_.keys(KelvinLattice), function(key){ + _.each(_.keys(HexLattice), function(key){ self[key] = null; }); } }; - return KelvinLattice; + return HexLattice; }); diff --git a/js/main.js b/js/main.js index 2ea47c5e..86e6dcc8 100644 --- a/js/main.js +++ b/js/main.js @@ -85,6 +85,7 @@ require.config({ superCell: 'cells/supercells/DMASuperCell', gikSuperCell: 'cells/supercells/GIKSuperCell', compositeCell: "cells/supercells/CompositeCell", + hexCell: 'cells/HexagonalCell', //parts part: 'parts/DMAPart', diff --git a/js/menus/templates/NavViewMenu.html b/js/menus/templates/NavViewMenu.html index a7446c51..d90881c8 100644 --- a/js/menus/templates/NavViewMenu.html +++ b/js/menus/templates/NavViewMenu.html @@ -31,4 +31,5 @@ <li><a class="appState" data-property="cellMode" data-value="<%= key %>" href="#"><% if (cellMode == key) { %><span class="fui-check"></span><% } %><%= mode %></a></li> <% }); %> </ul> -</li> \ No newline at end of file +</li> +<li><a class="" href="#">Keyboard Shortcuts</a></li> \ No newline at end of file diff --git a/js/plists/PList.js b/js/plists/PList.js index 30f9a470..b73fc996 100644 --- a/js/plists/PList.js +++ b/js/plists/PList.js @@ -58,7 +58,7 @@ define(['three'], function(THREE){ cube:"Cube", truncatedCube:"Cuboctahedron", kelvin:"Kelvin", -// hex: "Hexagonal" + hex: "Hexagonal" }, allConnectionTypes: { octa: {face:"Face", edgeRot:"Edge", vertex:"Vertex"},// freeformFace:"Freeform Face" edge:"Edge", (Rotated) -- GitLab