Commit fa8b0999 authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

hex base planes

parent 6869242c
......@@ -14,32 +14,45 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three',
_makeBasePlaneMesh: function(){
var scale = lattice.xScale();
var dimX = this.get("dimX")*scale;
var dimY = this.get("dimY")*scale;
// 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));
// geometry.vertices.push( new THREE.Vector3(dimX-scale/2, i-scale/2, 0.01));
// geometry.vertices.push( new THREE.Vector3(i-scale/2, -dimX-scale/2, 0.01));
// geometry.vertices.push( new THREE.Vector3(i-scale/2, dimX-scale/2, 0.01));
//
// }
//
var xScale = lattice.xScale();
var yScale = lattice.yScale();
var dimX = this.get("dimX");
var dimY = this.get("dimY");
var geometry = new THREE.Geometry();
for (var i=-dimY;i<=dimY+1;i++) {
for (var j=-dimX;j<=dimX;j+=1){
if (i%2 == 0){
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();
planeGeometry.vertices.push( new THREE.Vector3(-dimX-scale/2, -dimX-scale/2, 0));
planeGeometry.vertices.push( new THREE.Vector3(dimX+scale/2, -dimX-scale/2, 0));
planeGeometry.vertices.push( new THREE.Vector3(-dimX-scale/2, dimX+scale/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*xScale+xScale/2, -dimX*yScale-yScale/2, 0));
planeGeometry.vertices.push( new THREE.Vector3(-dimX*xScale-xScale/2, dimX*yScale+yScale/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, 3, 2));
planeGeometry.computeFaceNormals();
var mesh = new THREE.Mesh(planeGeometry, new THREE.MeshBasicMaterial({color:0x000000, transparent:true, opacity:0.0}));
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];
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',
var params = SquareBasePlane.prototype.calcHighlighterParams.call(this, face, point);
params.position.x += lattice.xScale()/2;
return params;
},
nextCellPosition: function(highlighterPosition){
return highlighterPosition;
}
});
......
......@@ -16,10 +16,7 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three',
},
nextCellPosition: function(highlighterPosition){
highlighterPosition.x -= lattice.xScale()/2;
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);
return highlighterPosition;
}
});
......
......@@ -9,7 +9,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
var HexLattice = {
_initLatticeType: function(){
require(['squareBaseplane'], function(BasePlaneClass){
require(['hexBaseplane'], function(BasePlaneClass){
globals.basePlane = new BasePlaneClass();
});
require([this.getHighlighterFile()], function(HighlighterClass){
......
......@@ -44,7 +44,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
xScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy;
return 2+Math.sqrt(3)/2+2*cellSeparation;
return 3+2*cellSeparation;
},
yScale: function(cellSeparation){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment