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

organization

parent b9f32ad0
No related branches found
No related tags found
No related merge requests found
......@@ -44,16 +44,16 @@
<script src="js/fea/DmaNode.js"></script>
<script src="js/fea/DmaBeam.js"></script>
<script src="js/cell/DmaCell.js"></script>
<script src="js/cell/OctaFaceCell.js"></script>
<script src="js/cell/OctaEdgeCell.js"></script>
<script src="js/cell/OctaRotEdgeCell.js"></script>
<script src="js/cell/OctaVertexCell.js"></script>
<script src="js/cell/DMASuperCell.js"></script>
<script src="js/cell/DMACellFreeform.js"></script>
<script src="js/cell/DmaCellTetra.js"></script>
<script src="js/cell/DmaCellOther.js"></script>
<script src="js/cells/DmaCell.js"></script>
<script src="js/cells/OctaFaceCell.js"></script>
<script src="js/cells/OctaEdgeCell.js"></script>
<script src="js/cells/OctaRotEdgeCell.js"></script>
<script src="js/cells/OctaVertexCell.js"></script>
<script src="js/cells/DMASuperCell.js"></script>
<script src="js/cells/DMACellFreeform.js"></script>
<script src="js/cells/DmaCellTetra.js"></script>
<script src="js/cells/DmaCellOther.js"></script>
<script src="js/fea/DmaPart.js"></script>
......
......@@ -7,28 +7,26 @@ var cellMaterial = new THREE.MeshNormalMaterial();
var wireframeMaterial = new THREE.MeshBasicMaterial({color:0x000000, wireframe:true});
function DMACell(indices){
this.indices = indices;
this.object3D = this._translateCell(this._rotateCell(new THREE.Object3D()));
this.object3D.myParent = this;//reference to get mouse raycasting back
this._buildMesh(this.object3D);
//object 3d is parent to all 3d elements related to cell, parts, beams, nodes, etc
this.object3D = this._buildObject3D();
this._addMeshes(this._buildMesh(), this.object3D);//build cell meshes
globals.three.sceneAdd(this.object3D, this._getSceneType());
this.setMode();
}
DMACell.prototype._getSceneType = function(){
if (this.indices) return "cell";
return null;
};
DMACell.prototype._buildMesh = function(object3D){//called from every subclass
var geometry = this._getGeometry();
if (!object3D || object3D === undefined) object3D = this.object3D;
var mesh = new THREE.Mesh(geometry, cellMaterial);
mesh.name = "cell";
object3D.add(mesh);
var wireframe = new THREE.Mesh(geometry, wireframeMaterial);
wireframe.name = "cell";
object3D.add(wireframe);
DMACell.prototype._buildObject3D = function(){
var object3D = this._translateCell(this._rotateCell(new THREE.Object3D()));
object3D.myParent = this;//reference to get mouse raycasting back
return object3D;
};
DMACell.prototype._rotateCell = function(object3D){
......@@ -41,10 +39,26 @@ DMACell.prototype._translateCell = function(object3D){
return object3D;
};
DMACell.prototype._addMeshes = function(meshes, object3D){//accepts an array or a single mesh
if (object3D === undefined) object3D = this.object3D;
if (meshes.constructor === Array){
_.each(meshes, function(mesh){
object3D.add(mesh);
});
} else object3D.add(meshes);
};
DMACell.prototype._buildMesh = function(){//called from every subclass
var geometry = this._getGeometry();
var meshes = [];
var mesh = new THREE.Mesh(geometry, cellMaterial);
mesh.name = "cell";
var wireframe = new THREE.Mesh(geometry, wireframeMaterial);
wireframe.name = "cell";
meshes.push(mesh);
meshes.push(wireframe);
return meshes;
};
DMACell.prototype._initParts = function(){
return [];//override in subclasses
......@@ -53,11 +67,6 @@ DMACell.prototype._initParts = function(){
DMACell.prototype.changePartType = function(){//override in subclasses
};
DMACell.prototype.setMode = function(mode){
if (mode === undefined) mode = globals.appState.get("cellMode");
......@@ -74,8 +83,6 @@ DMACell.prototype.setMode = function(mode){
case "node":
if (!this.nodes) this.nodes = this._initNodes();
break;
case "hide":
break;
}
_.each(this.object3D.children, function(child){
......@@ -94,18 +101,6 @@ DMACell.prototype.show = function(){
DMACell.prototype.setOpacity = function(opacity){
};
DMACell.prototype._getSceneType = function(){
if (this.indices) return "cell";
return null;
};
DMACell.prototype.getPosition = function(){
return this.object3D.position.clone();
};
......@@ -130,11 +125,6 @@ DMACell.prototype.zScale = function(){
return globals.lattice.zScale(0);
};
DMACell.prototype.destroy = function(){
if (this.destroyStarted) return;
this.destroyStarted = true;
......
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
/**
* Created by aghassaei on 5/26/15.
*/
var partMaterial = new THREE.MeshLambertMaterial({ color:0xffffff, shading: THREE.FlatShading });
partMaterial.color.setRGB( 0.9619657144369509, 0.6625466032079207, 0.20799727886007258 );
function DMAPart(index) {
this.index = index;
this.mesh = this._buildMesh();
}
DMAPart.prototype._buildMesh = function(){
var geometry = this._getGeometry();
var mesh = new THREE.Mesh(geometry, partMaterial);
mesh.name = "part";
return mesh;
};
DMAPart.prototype._draw = function(){
if (this.mesh) console.warn("part mesh already in scene");
this.mesh = this._makeMeshForType(this.type);
var rotation = this.parentCell.getEulerRotation();
this.mesh.rotation.set(rotation.x, rotation.y, rotation.z);
this._setMeshPosition(this.parentCell.getPosition());
globals.three.sceneAdd(this.mesh, "part");
};
DMAPart.prototype.highlight = function(){
// this.mesh.material.color.setRGB(1,0,0);
};
DMAPart.prototype.unhighlight = function(){
// if (this.mesh) this.mesh.material.color.setRGB(0.9619657144369509, 0.6625466032079207, 0.20799727886007258);
};
DMAPart.prototype.removeFromCell = function(){//send message back to parent cell to destroy this
if (this.parentCell) {
this.parentCell.removePart(this.type);
globals.three.render();
} else console.warn("part has no parent cell");
};
DMAPart.prototype.destroy = function(){
if (this.mesh) {
globals.three.sceneRemove(this.mesh, "part");
this.mesh.myPart = null;
// this.mesh.dispose();
// geometry.dispose();
// material.dispose();
this.mesh = null;
}
this.parentCell = null;
this.type = null;
};
DMAPart.prototype.toJSON = function(){
return {
}
};
/**
* Created by aghassaei on 5/26/15.
*/
/**
* Created by aghassaei on 5/26/15.
*/
/**
* Created by aghassaei on 5/26/15.
*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment