Commit 72c9b3ff authored by amandaghassaei's avatar amandaghassaei

special meshes

parent 07efe70d
......@@ -6,7 +6,39 @@
define(['three', 'cell'],
function(THREE, DMACell){
var unitCellGeo = new THREE.BoxGeometry(1,1,1);
//var unitCellGeo = new THREE.BoxGeometry(1,1,1);
var unitCellGeo = new THREE.Geometry();
//box vertices
unitCellGeo.vertices = [
new THREE.Vector3(0.5, 0.5, 0.5),
new THREE.Vector3(0.5, 0.5, -0.5),
new THREE.Vector3(0.5, -0.5, 0.5),
new THREE.Vector3(0.5, -0.5, -0.5),
new THREE.Vector3(-0.5, 0.5, 0.5),
new THREE.Vector3(-0.5, 0.5, -0.5),
new THREE.Vector3(-0.5, -0.5, 0.5),
new THREE.Vector3(-0.5, -0.5, -0.5)
];
//box
unitCellGeo.faces = [
new THREE.Face3(1, 0, 2),
new THREE.Face3(1, 2, 3),
new THREE.Face3(4, 5, 6),
new THREE.Face3(6, 5, 7),
new THREE.Face3(3, 2, 6),
new THREE.Face3(3, 6, 7),
new THREE.Face3(0, 1, 4),
new THREE.Face3(4, 1, 5),
new THREE.Face3(2, 0, 4),
new THREE.Face3(2, 4, 6),
new THREE.Face3(1, 3, 5),
new THREE.Face3(5, 3, 7)
];
unitCellGeo.computeFaceNormals();
function CubeCell(json, superCell){
DMACell.call(this, json, superCell);
......@@ -17,8 +49,14 @@ define(['three', 'cell'],
return unitCellGeo;
};
CubeCell.prototype._getPartGeo = function(){
var mesh = this.getMaterial().getMesh();
if (mesh) return mesh;
return null;
};
CubeCell.prototype._buildWireframe = function(mesh){//abstract mesh representation of cell
var wireframe = new THREE.BoxHelper(mesh);
var wireframe = new THREE.EdgesHelper(mesh);
wireframe.material.color.set(0x000000);
wireframe.matrixWorld = mesh.matrixWorld;
wireframe.matrixAutoUpdate = true;
......
......@@ -59,9 +59,19 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', '
var meshes = [];
var mesh = new THREE.Mesh(geometry, this.getMaterial(true));
mesh.name = this._getMeshName();
meshes.push(mesh);
var wireframe = this._buildWireframe(mesh, geometry);
var wireframeMesh = mesh;
var partGeo = this._getPartGeo();
if (partGeo){
var partMesh = new THREE.Mesh(partGeo, this.getMaterial(true));
meshes.push(partMesh);
wireframeMesh = partMesh;
mesh.visible = false;
}
var wireframe = this._buildWireframe(wireframeMesh, geometry);
if (!wireframe) return meshes;
wireframe.name = this._getMeshName();
meshes.push(wireframe);
......
......@@ -7,6 +7,103 @@ define(['underscore', 'appState', 'three'], function(_, appState, THREE){
var materialNum = 1;//outward facing name
var torsion1dof = new THREE.Geometry();
//torsion
torsion1dof.vertices = [
new THREE.Vector3(0.5, 0.5, 0.5),
new THREE.Vector3(0.5, 0.5, -0.5),
new THREE.Vector3(0.5, -0.5, 0.5),
new THREE.Vector3(0.5, -0.5, -0.5),
new THREE.Vector3(-0.5, 0.5, 0.5),
new THREE.Vector3(-0.5, 0.5, -0.5),
new THREE.Vector3(-0.5, -0.5, 0.5),
new THREE.Vector3(-0.5, -0.5, -0.5)
];
torsion1dof.faces = [
new THREE.Face3(5, 0, 2),
new THREE.Face3(5, 2, 1),
new THREE.Face3(4, 3, 6),
new THREE.Face3(3, 4, 7),
new THREE.Face3(1, 2, 6),
new THREE.Face3(1, 6, 3),
new THREE.Face3(0, 7, 4),
new THREE.Face3(0, 5, 7),
new THREE.Face3(2, 0, 4),
new THREE.Face3(2, 4, 6),
new THREE.Face3(1, 3, 5),
new THREE.Face3(5, 3, 7)
];
var bending1dof = new THREE.Geometry();
//1dof hinge vertices and faces
bending1dof.vertices = [
new THREE.Vector3(0.5, 0.5, 0.5),
new THREE.Vector3(0.5, 0.5, -0.5),
new THREE.Vector3(0.5, -0.5, 0.5),
new THREE.Vector3(0.5, -0.5, -0.5),
new THREE.Vector3(-0.5, 0.5, 0.5),
new THREE.Vector3(-0.5, 0.5, -0.5),
new THREE.Vector3(-0.5, -0.5, 0.5),
new THREE.Vector3(-0.5, -0.5, -0.5),
new THREE.Vector3(0, 0, 0.5),
new THREE.Vector3(0, 0, -0.5)
];
bending1dof.faces = [
new THREE.Face3(1, 0, 2),
new THREE.Face3(1, 2, 3),
new THREE.Face3(4, 5, 6),
new THREE.Face3(6, 5, 7),
new THREE.Face3(3, 2, 8),
new THREE.Face3(3, 8, 9),
new THREE.Face3(9, 6, 7),
new THREE.Face3(9, 8, 6),
new THREE.Face3(0, 1, 8),
new THREE.Face3(1, 9, 8),
new THREE.Face3(4, 9, 5),
new THREE.Face3(8, 9, 4),
new THREE.Face3(2, 0, 8),
new THREE.Face3(8, 4, 6),
new THREE.Face3(1, 3, 9),
new THREE.Face3(5, 9, 7)
];
var bending2dof = new THREE.Geometry();
//2dof hinge vertices and faces
bending2dof.vertices = [
new THREE.Vector3(0.5, 0.5, 0.5),
new THREE.Vector3(0.5, 0.5, -0.5),
new THREE.Vector3(0.5, -0.5, 0.5),
new THREE.Vector3(0.5, -0.5, -0.5),
new THREE.Vector3(-0.5, 0.5, 0.5),
new THREE.Vector3(-0.5, 0.5, -0.5),
new THREE.Vector3(-0.5, -0.5, 0.5),
new THREE.Vector3(-0.5, -0.5, -0.5),
new THREE.Vector3(0, 0, 0)
];
bending2dof.faces = [
new THREE.Face3(1, 0, 2),
new THREE.Face3(1, 2, 3),
new THREE.Face3(4, 5, 6),
new THREE.Face3(6, 5, 7),
new THREE.Face3(3, 2, 8),
new THREE.Face3(8, 6, 7),
new THREE.Face3(8, 8, 6),
new THREE.Face3(0, 1, 8),
new THREE.Face3(4, 8, 5),
new THREE.Face3(8, 8, 4),
new THREE.Face3(2, 0, 8),
new THREE.Face3(8, 4, 6),
new THREE.Face3(1, 3, 8),
new THREE.Face3(5, 8, 7)
];
torsion1dof.computeFaceNormals();
bending1dof.computeFaceNormals();
bending2dof.computeFaceNormals();
function DMAMaterial(json, id){
this.id = id;
......@@ -22,6 +119,12 @@ define(['underscore', 'appState', 'three'], function(_, appState, THREE){
json = _.extend(defaults, json);
this.set(json, true);
if (json.texture) this.texture = json.texture;
if (json.mesh) {
if (json.mesh == "torsion1dof") this.mesh = torsion1dof;
else if (json.mesh == "bending1dof") this.mesh = bending1dof;
else if (json.mesh == "bending2dof") this.mesh = bending2dof;
else console.warn("no mesh for type " + json.mesh);
}
}
DMAMaterial.prototype.getID = function(){
......@@ -193,6 +296,10 @@ define(['underscore', 'appState', 'three'], function(_, appState, THREE){
return this.properties.k;
};
DMAMaterial.prototype.getMesh = function(){
return this.mesh;
};
DMAMaterial.prototype.canDelete = function(){
return !this.noDelete;
};
......@@ -205,7 +312,8 @@ define(['underscore', 'appState', 'three'], function(_, appState, THREE){
altColor: this.altColor,
noDelete: this.noDelete,
properties: this.getProperties(),
texture: this.texture
texture: this.texture,
mesh: this.mesh
}
};
......
......@@ -35,11 +35,12 @@ define([], function(){
k: 500
}
},
hinge1DOF: {
bending1DOF: {
name: "1 DOF Hinge",
color: "#cda4f3",
altColor: "#cda4f3",
texture: "stripes",
mesh: "bending1dof",
properties:{
conductive: false,
density: 3500,//kg/m^3
......@@ -47,11 +48,12 @@ define([], function(){
k: 30
}
},
hinge2DOF: {
bending2DOF: {
name: "2 DOF Hinge",
color: "#cda4f3",
altColor: "#cda4f3",
texture: "stripes",
mesh: "bending2dof",
properties:{
conductive: false,
density: 3500,//kg/m^3
......@@ -59,11 +61,12 @@ define([], function(){
k: 30
}
},
flexureTorsion: {
torsion1DOF: {
name: "Torsion Flexure",
color: "#cda4f3",
altColor: "#cda4f3",
texture: "stripes",
mesh: "torsion1dof",
properties:{
conductive: false,
density: 3500,//kg/m^3
......@@ -106,7 +109,7 @@ define([], function(){
k: 30
}
},
actuatorLinear: {
actuatorLinear1DOF: {
name: "Linear Actuator",
color: "#FFCC00",
altColor: "#FFCC00",
......@@ -117,10 +120,11 @@ define([], function(){
k: 200
}
},
actuatorBend: {
actuatorBending1DOF: {
name: "Bending Actuator",
color: "#FFCC00",
altColor: "#FFCC00",
mesh: "bending1dof",
properties:{
conductive: false,
density: 6500,//kg/m^3
......@@ -128,10 +132,11 @@ define([], function(){
k: 200
}
},
actuatorTorsion: {
actuatorTorsion1DOF: {
name: "Torsional Actuator",
color: "#FFCC00",
altColor: "#FFCC00",
mesh: "torsion1dof",
properties:{
conductive: false,
density: 6500,//kg/m^3
......@@ -229,7 +234,6 @@ define([], function(){
// elasMod: 17.2
// }
//},
piezo: {
name: "Piezo",
color: "#FFCC00",
......
Markdown is supported
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