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

cell subclasses

parent 2b1be52c
No related branches found
No related tags found
No related merge requests found
...@@ -100,7 +100,6 @@ DMACell.prototype.destroy = function(){ ...@@ -100,7 +100,6 @@ DMACell.prototype.destroy = function(){
var unitOctHeight = 2/Math.sqrt(6); var unitOctHeight = 2/Math.sqrt(6);
var unitCellGeo1 = new THREE.OctahedronGeometry(1/Math.sqrt(2)); var unitCellGeo1 = new THREE.OctahedronGeometry(1/Math.sqrt(2));
unitCellGeo1.dynamic = true;
unitCellGeo1.applyMatrix(new THREE.Matrix4().makeRotationZ(-3*Math.PI/12)); unitCellGeo1.applyMatrix(new THREE.Matrix4().makeRotationZ(-3*Math.PI/12));
unitCellGeo1.applyMatrix(new THREE.Matrix4().makeRotationX(Math.asin(2/Math.sqrt(2)/Math.sqrt(3)))); unitCellGeo1.applyMatrix(new THREE.Matrix4().makeRotationX(Math.asin(2/Math.sqrt(2)/Math.sqrt(3))));
...@@ -153,3 +152,97 @@ DMACell.prototype.destroy = function(){ ...@@ -153,3 +152,97 @@ DMACell.prototype.destroy = function(){
self.DMASideOctaCell = DMASideOctaCell; self.DMASideOctaCell = DMASideOctaCell;
})(); })();
///////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////OCTA VERTEX CLASS//////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
(function () {
var unitCellGeo = new THREE.OctahedronGeometry(1/Math.sqrt(2));
var cellMaterials = [new THREE.MeshNormalMaterial(),
new THREE.MeshBasicMaterial({color:0x000000, wireframe:true})];
function DMAVertexOctaCell(mode, indices, scale, lattice){
DMACell.call(this, mode, indices, scale, lattice);
}
DMAVertexOctaCell.prototype = Object.create(DMACell.prototype);
DMAVertexOctaCell.prototype._calcPosition = function(scale, indices){
var position = {};
// var octHeight = 2*scale/Math.sqrt(6);
// var triHeight = scale/2*Math.sqrt(3);
// position.x = indices.x*scale;
// position.y = indices.y*triHeight;
// position.z = indices.z*octHeight;
// if (Math.abs(indices.y%2) == 1) position.x -= scale/2;
// if (Math.abs(indices.z%2) == 1) position.y -= triHeight*4/3;
return position;
};
DMAVertexOctaCell.prototype._initParts = function(zIndex){
var parts = [];
for (var i=0;i<3;i++){
parts.push(new DMAPart(i, zIndex%2==1, this));
}
return parts;
};
DMAVertexOctaCell.prototype._buildCellMesh = function(zIndex){//abstract mesh representation of cell
var mesh = THREE.SceneUtils.createMultiMaterialObject(unitCellGeo, cellMaterials);
mesh.myCell = this;//we need a reference to this instance from the mesh for intersection selection stuff
return mesh;
};
self.DMAVertexOctaCell = DMAVertexOctaCell;
})();
///////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////CUBE CELL CLASS////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
(function () {
var unitCellGeo = new THREE.BoxGeometry(1,1,1);
unitCellGeo.applyMatrix(new THREE.Matrix4().makeTranslation(1/2,1/2,1/2));
var cellMaterials = [new THREE.MeshNormalMaterial(),
new THREE.MeshBasicMaterial({color:0x000000, wireframe:true})];
function DMACubeCell(mode, indices, scale, lattice){
DMACell.call(this, mode, indices, scale, lattice);
}
DMACubeCell.prototype = Object.create(DMACell.prototype);
DMACubeCell.prototype._calcPosition = function(scale, indices){
var position = _.clone(indices);
_.each(_.keys(position), function(key){
position.key *= scale;
});
return position;
};
DMACubeCell.prototype._initParts = function(zIndex){
var parts = [];
for (var i=0;i<4;i++){
parts.push(new DMAPart(0, zIndex%2==1, this));
}
return parts;
};
DMACubeCell.prototype._buildCellMesh = function(zIndex){//abstract mesh representation of cell
var mesh = THREE.SceneUtils.createMultiMaterialObject(unitCellGeo, cellMaterials);
mesh.myCell = this;//we need a reference to this instance from the mesh for intersection selection stuff
return mesh;
};
self.DMAVertexOctaCell = DMACubeCell;
})();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment