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

hex base planes

parent 6869242c
Branches
No related tags found
No related merge requests found
...@@ -14,32 +14,45 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three', ...@@ -14,32 +14,45 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three',
_makeBasePlaneMesh: function(){ _makeBasePlaneMesh: function(){
var scale = lattice.xScale(); var xScale = lattice.xScale();
var dimX = this.get("dimX")*scale; var yScale = lattice.yScale();
var dimY = this.get("dimY")*scale; var dimX = this.get("dimX");
var dimY = this.get("dimY");
// var geometry = new THREE.Geometry();
// var geometry = new THREE.Geometry();
// for ( var i = - dimX; i <= dimX+1; i += scale ) {
// geometry.vertices.push( new THREE.Vector3(-dimX-scale/2, i-scale/2, 0.01)); for (var i=-dimY;i<=dimY+1;i++) {
// geometry.vertices.push( new THREE.Vector3(dimX-scale/2, i-scale/2, 0.01)); for (var j=-dimX;j<=dimX;j+=1){
// geometry.vertices.push( new THREE.Vector3(i-scale/2, -dimX-scale/2, 0.01)); if (i%2 == 0){
// geometry.vertices.push( new THREE.Vector3(i-scale/2, dimX-scale/2, 0.01)); geometry.vertices.push( new THREE.Vector3(j*xScale-xScale/2, i*yScale-1/2, 0.01));
// geometry.vertices.push( new THREE.Vector3((j+0.5)*xScale-xScale/2, i*yScale-1, 0.01));
// } geometry.vertices.push( new THREE.Vector3((j+0.5)*xScale-xScale/2, i*yScale-1, 0.01));
// geometry.vertices.push( new THREE.Vector3((j+1)*xScale-xScale/2, i*yScale-1/2, 0.01));
geometry.vertices.push( new THREE.Vector3(j*xScale-xScale/2, i*yScale-1/2, 0.01));
geometry.vertices.push( new THREE.Vector3(j*xScale-xScale/2, (i+1)*yScale-1, 0.01));
} else {
geometry.vertices.push( new THREE.Vector3(j*xScale-xScale/2, i*yScale-1, 0.01));
geometry.vertices.push( new THREE.Vector3((j+0.5)*xScale-xScale/2, i*yScale-1/2, 0.01));
geometry.vertices.push( new THREE.Vector3((j+0.5)*xScale-xScale/2, i*yScale-1/2, 0.01));
geometry.vertices.push( new THREE.Vector3((j+1)*xScale-xScale/2, i*yScale-1, 0.01))
geometry.vertices.push( new THREE.Vector3((j+0.5)*xScale-xScale/2, i*yScale-1/2, 0.01));
geometry.vertices.push( new THREE.Vector3((j+0.5)*xScale-xScale/2, (i+1)*yScale-1, 0.01));
}
}
}
var planeGeometry = new THREE.Geometry(); var planeGeometry = new THREE.Geometry();
planeGeometry.vertices.push( new THREE.Vector3(-dimX-scale/2, -dimX-scale/2, 0)); planeGeometry.vertices.push( new THREE.Vector3(-dimX*xScale-xScale/2, -dimX*yScale-yScale/2, 0));
planeGeometry.vertices.push( new THREE.Vector3(dimX+scale/2, -dimX-scale/2, 0)); planeGeometry.vertices.push( new THREE.Vector3(dimX*xScale+xScale/2, -dimX*yScale-yScale/2, 0));
planeGeometry.vertices.push( new THREE.Vector3(-dimX-scale/2, dimX+scale/2, 0)); planeGeometry.vertices.push( new THREE.Vector3(-dimX*xScale-xScale/2, dimX*yScale+yScale/2, 0));
planeGeometry.vertices.push( new THREE.Vector3(dimX+scale/2, dimX+scale/2, 0)); planeGeometry.vertices.push( new THREE.Vector3(dimX*xScale+xScale/2, dimX*yScale+yScale/2, 0));
planeGeometry.faces.push(new THREE.Face3(0, 1, 3)); planeGeometry.faces.push(new THREE.Face3(0, 1, 3));
planeGeometry.faces.push(new THREE.Face3(0, 3, 2)); planeGeometry.faces.push(new THREE.Face3(0, 3, 2));
planeGeometry.computeFaceNormals(); planeGeometry.computeFaceNormals();
var mesh = new THREE.Mesh(planeGeometry, new THREE.MeshBasicMaterial({color:0x000000, transparent:true, opacity:0.0})); var mesh = new THREE.Mesh(planeGeometry, new THREE.MeshBasicMaterial({color:0x000000, transparent:true, opacity:0.0}));
return [mesh]; // return [mesh];
// return [mesh, new THREE.Line(geometry, new THREE.LineBasicMaterial({color:0x000000, transparent:true, linewidth:2, opacity:this.get("material").opacity}), THREE.LinePieces)]; return [mesh, new THREE.Line(geometry, new THREE.LineBasicMaterial({color:0x000000, transparent:true, linewidth:2, opacity:this.get("material").opacity}), THREE.LinePieces)];
} }
}); });
}); });
\ No newline at end of file
...@@ -12,6 +12,10 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three', ...@@ -12,6 +12,10 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three',
var params = SquareBasePlane.prototype.calcHighlighterParams.call(this, face, point); var params = SquareBasePlane.prototype.calcHighlighterParams.call(this, face, point);
params.position.x += lattice.xScale()/2; params.position.x += lattice.xScale()/2;
return params; return params;
},
nextCellPosition: function(highlighterPosition){
return highlighterPosition;
} }
}); });
......
...@@ -16,10 +16,7 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three', ...@@ -16,10 +16,7 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three',
}, },
nextCellPosition: function(highlighterPosition){ nextCellPosition: function(highlighterPosition){
highlighterPosition.x -= lattice.xScale()/2; return highlighterPosition;
highlighterPosition.y -= lattice.yScale()/2;//undo what we did in calc highlighter params
var newPosition = highlighterPosition.clone().add(highlighterPosition.clone().sub(this.getAbsolutePosition()));
return lattice.getIndexForPosition(newPosition);
} }
}); });
......
...@@ -9,7 +9,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -9,7 +9,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
var HexLattice = { var HexLattice = {
_initLatticeType: function(){ _initLatticeType: function(){
require(['squareBaseplane'], function(BasePlaneClass){ require(['hexBaseplane'], function(BasePlaneClass){
globals.basePlane = new BasePlaneClass(); globals.basePlane = new BasePlaneClass();
}); });
require([this.getHighlighterFile()], function(HighlighterClass){ require([this.getHighlighterFile()], function(HighlighterClass){
......
...@@ -44,7 +44,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -44,7 +44,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
xScale: function(cellSeparation){ xScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy; if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy;
return 2+Math.sqrt(3)/2+2*cellSeparation; return 3+2*cellSeparation;
}, },
yScale: function(cellSeparation){ yScale: function(cellSeparation){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment