Commit 8e2516b3 authored by amandaghassaei's avatar amandaghassaei
Browse files

two sided material

parent 341019d4
...@@ -17,7 +17,7 @@ function initControls(globals){ ...@@ -17,7 +17,7 @@ function initControls(globals){
setLink("#about", function(){ setLink("#about", function(){
$('#aboutModal').modal('show'); $('#aboutModal').modal('show');
}); });
setCheckbox("#dynamic", globals.simType == "dynamic", function(val){ setCheckbox("#dynamic", globals.simType == "dynamic", function(val){
globals.simType = val; globals.simType = val;
}); });
......
...@@ -9,7 +9,7 @@ function initModel(globals){ ...@@ -9,7 +9,7 @@ function initModel(globals){
function setMeshMaterial(){ function setMeshMaterial(){
material = THREE.MeshFaceMaterial([ material = THREE.MeshFaceMaterial([
new THREE.MeshLambertMaterial({shading:THREE.FlatShading, color:0xff0000, side:THREE.FrontSide}), new THREE.MeshLambertMaterial({shading:THREE.FlatShading, color:0xff0000, side:THREE.FrontSide}),
new THREE.MeshLambertMaterial({shading:THREE.FlatShading, color:0x0000ff, side:THREE.BackSide}) new THREE.MeshLambertMaterial({shading:THREE.FlatShading, color:0x0000ff, side:THREE.FrontSide})
]); ]);
object3D.material = material; object3D.material = material;
} }
...@@ -161,22 +161,21 @@ function initModel(globals){ ...@@ -161,22 +161,21 @@ function initModel(globals){
vertices.push(nodes[i].getPosition()); vertices.push(nodes[i].getPosition());
} }
var geofaces = faces.slice();
for (var i=0;i<faces.length;i++){
geofaces[i].materialIndex = 1;
geofaces.push(new THREE.Face3(faces[i].a, faces[i].c, faces[i].b));
}
console.log(geofaces);
geometry.vertices = vertices; geometry.vertices = vertices;
geometry.faces = faces; geometry.faces = geofaces;
geometry.verticesNeedUpdate = true; geometry.verticesNeedUpdate = true;
geometry.elementsNeedUpdate = true; geometry.elementsNeedUpdate = true;
geometry.computeFaceNormals(); geometry.computeFaceNormals();
geometry.computeBoundingBox(); geometry.computeBoundingBox();
geometry.computeBoundingSphere(); geometry.computeBoundingSphere();
// for ( var face in geometry.faces ) {
// if (face<geometry.faces.length/2) {
// geometry.faces[ face ].materialIndex = 1;
// console.log(face);
// }
// else geometry.faces[ face ].materialIndex = 0;
// }
globals.shouldSyncWithModel = true; globals.shouldSyncWithModel = true;
inited = true; inited = true;
// globals.staticSolver.syncNodesAndEdges(); // globals.staticSolver.syncNodesAndEdges();
......
Supports Markdown
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