Skip to content
Snippets Groups Projects
Commit 7a0aa6e3 authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

hex lattice rendering fix

parent 38a06ca2
No related branches found
No related tags found
No related merge requests found
......@@ -6,8 +6,53 @@
define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'],
function(_, THREE, three, lattice, appState, DMACell){
var unitCellGeo = new THREE.CylinderGeometry(1, 1, 1, 6);
unitCellGeo.applyMatrix(new THREE.Matrix4().makeRotationX(Math.PI/2));
var unitGeo = new THREE.Geometry();
unitGeo.vertices = [
new THREE.Vector3(0, -1, 0.5),
new THREE.Vector3(0.8660254037844386, -0.5, 0.5),
new THREE.Vector3(0.8660254037844387, 0.5, 0.5),
new THREE.Vector3(0, 1, 0.5),
new THREE.Vector3(-0.8660254037844384, 0.5, 0.5),
new THREE.Vector3(-0.8660254037844386, -0.5, 0.5),
new THREE.Vector3(0, -1, 0.5),
new THREE.Vector3(0, -1, -0.5),
new THREE.Vector3(0.8660254037844386, -0.5, -0.5),
new THREE.Vector3(0.8660254037844387, 0.5, -0.5),
new THREE.Vector3(0, 1, -0.5),
new THREE.Vector3(-0.8660254037844384, 0.5, -0.5),
new THREE.Vector3(-0.8660254037844386, -0.5, -0.5),
new THREE.Vector3(0, -1, -0.5),
new THREE.Vector3(0, 0, 0.5),
new THREE.Vector3(0, 0, -0.5)
];
unitGeo.faces = [
new THREE.Face3(0, 7, 1),
new THREE.Face3(7, 8, 1),
new THREE.Face3(1, 8, 2),
new THREE.Face3(8, 9, 2),
new THREE.Face3(2, 9, 3),
new THREE.Face3(9, 10, 3),
new THREE.Face3(3, 10, 4),
new THREE.Face3(10, 11, 4),
new THREE.Face3(4, 11, 5),
new THREE.Face3(11, 12, 5),
new THREE.Face3(5, 12, 6),
new THREE.Face3(12, 13, 6),
new THREE.Face3(0, 1, 14),
new THREE.Face3(1, 2, 14),
new THREE.Face3(2, 3, 14),
new THREE.Face3(3, 4, 14),
new THREE.Face3(4, 5, 14),
new THREE.Face3(5, 6, 14),
new THREE.Face3(8, 7, 15),
new THREE.Face3(9, 8, 15),
new THREE.Face3(10, 9, 15),
new THREE.Face3(11, 10, 15),
new THREE.Face3(12, 11, 15),
new THREE.Face3(13, 12, 15)
];
unitGeo.computeFaceNormals();
function HexagonalCell(json, superCell){
DMACell.call(this, json, superCell);
......@@ -15,7 +60,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'],
HexagonalCell.prototype = Object.create(DMACell.prototype);
HexagonalCell.prototype._getGeometry = function(){
return unitCellGeo;
return unitGeo;
};
HexagonalCell.prototype._buildWireframe = function(mesh){//abstract mesh representation of cell
......
......@@ -7,8 +7,52 @@
define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'hexCell'],
function(_, THREE, three, lattice, appState, HexCell){
var unitCellGeo = new THREE.CylinderGeometry(1, 1, 1, 6);
unitCellGeo.applyMatrix(new THREE.Matrix4().makeRotationY(Math.PI/2));
var unitGeo = new THREE.Geometry();
unitGeo.vertices = [
new THREE.Vector3(1, 0.5, 0),
new THREE.Vector3(0.5, 0.5, -0.8660254037844386),
new THREE.Vector3(-0.5, 0.5, -0.8660254037844387),
new THREE.Vector3(-1, 0.5, 0),
new THREE.Vector3(-0.5, 0.5, 0.8660254037844384),
new THREE.Vector3(0.5, 0.5, 0.8660254037844386),
new THREE.Vector3(1, 0.5, 0),
new THREE.Vector3(1, -0.5, 0),
new THREE.Vector3(0.5, -0.5, -0.8660254037844386),
new THREE.Vector3(-0.5, -0.5, -0.8660254037844387),
new THREE.Vector3(-1, -0.5, 0),
new THREE.Vector3(-0.5, -0.5, 0.8660254037844384),
new THREE.Vector3(0.5, -0.5, 0.8660254037844386),
new THREE.Vector3(1, -0.5, 0),
new THREE.Vector3(0, 0.5, 0),
new THREE.Vector3(0, -0.5, 0)
];
unitGeo.faces = [
new THREE.Face3(0, 7, 1),
new THREE.Face3(7, 8, 1),
new THREE.Face3(1, 8, 2),
new THREE.Face3(8, 9, 2),
new THREE.Face3(2, 9, 3),
new THREE.Face3(9, 10, 3),
new THREE.Face3(3, 10, 4),
new THREE.Face3(10, 11, 4),
new THREE.Face3(4, 11, 5),
new THREE.Face3(11, 12, 5),
new THREE.Face3(5, 12, 6),
new THREE.Face3(12, 13, 6),
new THREE.Face3(0, 1, 14),
new THREE.Face3(1, 2, 14),
new THREE.Face3(2, 3, 14),
new THREE.Face3(3, 4, 14),
new THREE.Face3(4, 5, 14),
new THREE.Face3(5, 6, 14),
new THREE.Face3(8, 7, 15),
new THREE.Face3(9, 8, 15),
new THREE.Face3(10, 9, 15),
new THREE.Face3(11, 10, 15),
new THREE.Face3(12, 11, 15),
new THREE.Face3(13, 12, 15)
];
unitGeo.computeFaceNormals();
function HexagonalCell(json, superCell){
HexCell.call(this, json, superCell);
......@@ -16,7 +60,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'hexCell'],
HexagonalCell.prototype = Object.create(HexCell.prototype);
HexagonalCell.prototype._getGeometry = function(){
return unitCellGeo;
return unitGeo;
};
HexagonalCell.prototype.aspectRatio = function(){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment