-
amandaghassaei authoredamandaghassaei authored
DmaCellOther.js 9.02 KiB
/**
* Created by aghassaei on 3/9/15.
*/
var cellMaterial = [new THREE.MeshNormalMaterial()];
///////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////CUBE CELL CLASS////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
(function () {
var unitCellGeo = new THREE.BoxGeometry(1,1,1);
function DMACubeCell(indices, scale){
DMACell.call(this, indices, scale);
}
DMACubeCell.prototype = Object.create(DMACell.prototype);
DMACubeCell.prototype._buildCellMesh = function(){//abstract mesh representation of cell
var mesh = DMACell.prototype._buildCellMesh.call(this, cellMaterial);
var wireframe = new THREE.BoxHelper(mesh.children[0]);
wireframe.material.color.set(0x000000);
mesh.children.push(wireframe);
return mesh;
};
DMACubeCell.prototype.calcHighlighterPosition = function(face){
var direction = face.normal;
var position = this.getPosition();
var scale = this.xScale();
_.each(_.keys(position), function(key){
position[key] += direction[key]*scale/2;
});
return {index: _.clone(this.indices), direction:direction, position:position};
};
DMACubeCell.prototype._getGeometry = function(){
return unitCellGeo;
};
DMACubeCell.prototype.xScale = function(scale){
if (!scale) scale = this.getScale();
return scale;
};
DMACubeCell.prototype.yScale = function(scale){
return this.xScale(scale);
};
DMACubeCell.prototype.zScale = function(scale){
return this.xScale(scale);
};
self.DMACubeCell = DMACubeCell;
})();
///////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////TRUNCATED CUBE CLASS///////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
(function(){
var truncCubeRad = Math.sqrt(2)/2;