diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index 1cc9e3ed652719fbb9426b8dda7761539ab2526b..f0af65e22aa6d9b9cad135d1a8a1814aa22656cf 100644 --- a/js/fea/DmaCell.js +++ b/js/fea/DmaCell.js @@ -100,7 +100,6 @@ DMACell.prototype.destroy = function(){ var unitOctHeight = 2/Math.sqrt(6); 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().makeRotationX(Math.asin(2/Math.sqrt(2)/Math.sqrt(3)))); @@ -152,4 +151,98 @@ DMACell.prototype.destroy = function(){ self.DMASideOctaCell = DMASideOctaCell; -})(); \ No newline at end of file +})(); + +/////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////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; + +})();