Commit aad83d50 authored by amandaghassaei's avatar amandaghassaei
Browse files

simple fold examples

parent f1357b05
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="3456px" height="6912px" viewBox="0 0 3456 6912" enable-background="new 0 0 3456 6912" xml:space="preserve">
<path fill="none" stroke="#000000" stroke-miterlimit="10" d="M2851.823,3456H889V2014.824h1962.823V3456z"/>
<path fill="none" stroke="#0000FF" stroke-miterlimit="10" d="M1379.706,2014.824V3456 M1870.411,2014.824V3456 M2361.117,2014.824
V3456 M889,2735.412h490.706 M1870.411,2735.412h490.706"/>
<path fill="none" stroke="#FF0000" stroke-miterlimit="10" d="M1379.706,2735.412h490.706 M2361.117,2735.412h490.706"/>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="3456px" height="6912px" viewBox="0 0 3456 6912" enable-background="new 0 0 3456 6912" xml:space="preserve">
<path fill="none" stroke="#000000" stroke-miterlimit="10" d="M2851.823,3456H889V2014.824h1962.823V3456z"/>
<path fill="none" stroke="#0000FF" stroke-miterlimit="10" d="M1379.706,2014.824V3456 M2361.117,2014.824V3456 M889,2735.412
h490.706 M1870.411,2735.412h490.706"/>
<path fill="none" stroke="#FF0000" stroke-miterlimit="10" d="M1870.411,2014.824V3456 M1379.706,2735.412h490.706
M2361.117,2735.412h490.706"/>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="3456px" height="6912px" viewBox="0 0 3456 6912" enable-background="new 0 0 3456 6912" xml:space="preserve">
<path fill="none" stroke="#0000FF" stroke-miterlimit="10" d="M316.529,232.941l1300,1300 M1616.529,232.941l-650,650
M1616.529,232.941l650,650 M2266.529,882.941l-650,650 M1616.529,232.941v1300"/>
<path fill="none" stroke="#000000" stroke-miterlimit="10" d="M2266.529,1532.941h-1950v-1300h1950V1532.941z"/>
<path fill="none" stroke="#FF0000" stroke-miterlimit="10" d="M966.529,882.941l-650,650"/>
</svg>
......@@ -603,6 +603,9 @@
<a tabindex="-1">Simple Folds<span class="pull-right fui-arrow-right"></span></a>
<ul class="dropdown-menu">
<li><a href="#" class="demo" data-url="SimpleFolds/simpleVertex.svg">Simple Vertex</a></li>
<li><a href="#" class="demo" data-url="SimpleFolds/russianTuck.svg">Russian Tuck</a></li>
<li><a href="#" class="demo" data-url="SimpleFolds/mapFold.svg">Map Fold</a></li>
<li><a href="#" class="demo" data-url="SimpleFolds/brochureFold.svg">Brochure Fold</a></li>
</ul>
</li>
<li class="divider"></li>
......
......@@ -15,71 +15,69 @@ function makeSaveGEO(doublesided){
}
if (globals.thickenModel){
var numVertices = geo.vertices.length;
geo.computeVertexNormals();
geo.computeFaceNormals();
for (var i=0;i<numVertices;i++){
var face;
var vertexNormal = new THREE.Vector3();
var lastFaceIndex = 0;
for (var j=0;j<geo.faces.length;j++){
face = geo.faces[j];
if (face.a == i) {
var a = geo.vertices[face.a];
var b = geo.vertices[face.b];
var c = geo.vertices[face.c];
var weight = Math.abs(Math.acos( (b.clone().sub(a)).normalize().dot( (c.clone().sub(a)).normalize() ) ));
console.log(weight);
vertexNormal.add(face.normal.clone().multiplyScalar(weight));
lastFaceIndex = j;
} else if (face.b == i) {
var a = geo.vertices[face.a];
var b = geo.vertices[face.b];
var c = geo.vertices[face.c];
var weight = Math.abs(Math.acos( (c.clone().sub(b)).normalize().dot( (a.clone().sub(b)).normalize() ) ));
console.log(weight);
vertexNormal.add(face.normal.clone().multiplyScalar(weight));
lastFaceIndex = j;
} else if (face.c == i) {
var a = geo.vertices[face.a];
var b = geo.vertices[face.b];
var c = geo.vertices[face.c];
var weight = Math.abs(Math.acos( (b.clone().sub(c)).normalize().dot( (a.clone().sub(c)).normalize() ) ));
console.log(weight);
vertexNormal.add(face.normal.clone().multiplyScalar(weight));
lastFaceIndex = j;
}
// if (vertexNormal !== null) break;
}
// if (vertexNormal === undefined) {
// geo.vertices.push(new THREE.Vector3());
// continue;
// }
//filter out duplicate normals
vertexNormal.normalize();
var offset = vertexNormal.clone().multiplyScalar(globals.thickenOffset/(2*vertexNormal.clone().dot(geo.faces[lastFaceIndex].normal)));
// geo.vertices.push(geo.vertices[i].clone().sub(offset));
geo.vertices[i].add(offset);
}
// var numFaces = geo.faces.length;
// for (var i=0;i<numFaces;i++){
// var face = geo.faces[i].clone();
// face.a += numVertices;
// face.b += numVertices;
// face.c += numVertices;
// var b = face.b;
// face.b = face.c;
// face.c = b;
// geo.faces.push(face);
// }
geo.computeVertexNormals();
geo.computeFaceNormals();
// if (globals.thickenModel){
// var numVertices = geo.vertices.length;
// geo.computeVertexNormals();
// geo.computeFaceNormals();
// for (var i=0;i<numVertices;i++){
// var face;
// var vertexNormal = new THREE.Vector3();
// var lastFaceIndex = 0;
// for (var j=0;j<geo.faces.length;j++){
// face = geo.faces[j];
// if (face.a == i) {
// var a = geo.vertices[face.a];
// var b = geo.vertices[face.b];
// var c = geo.vertices[face.c];
// var weight = Math.abs(Math.acos( (b.clone().sub(a)).normalize().dot( (c.clone().sub(a)).normalize() ) ));
// vertexNormal.add(face.normal.clone().multiplyScalar(weight));
// lastFaceIndex = j;
// } else if (face.b == i) {
// var a = geo.vertices[face.a];
// var b = geo.vertices[face.b];
// var c = geo.vertices[face.c];
// var weight = Math.abs(Math.acos( (c.clone().sub(b)).normalize().dot( (a.clone().sub(b)).normalize() ) ));
// vertexNormal.add(face.normal.clone().multiplyScalar(weight));
// lastFaceIndex = j;
// } else if (face.c == i) {
// var a = geo.vertices[face.a];
// var b = geo.vertices[face.b];
// var c = geo.vertices[face.c];
// var weight = Math.abs(Math.acos( (b.clone().sub(c)).normalize().dot( (a.clone().sub(c)).normalize() ) ));
// vertexNormal.add(face.normal.clone().multiplyScalar(weight));
// lastFaceIndex = j;
// }
// // if (vertexNormal !== null) break;
// }
// // if (vertexNormal === undefined) {
// // geo.vertices.push(new THREE.Vector3());
// // continue;
// // }
// //filter out duplicate normals
// vertexNormal.normalize();
// console.log(vertexNormal);
// var offset = vertexNormal.clone().multiplyScalar(5);//globals.thickenOffset/(2*vertexNormal.clone().dot(geo.faces[lastFaceIndex].normal)));
//
// geo.vertices.push(geo.vertices[i].clone().sub(offset));
// geo.vertices[i].add(offset);
// }
// var numFaces = geo.faces.length;
// for (var i=0;i<numFaces;i++){
// var face = geo.faces[i].clone();
// face.a += numVertices;
// face.b += numVertices;
// face.c += numVertices;
// var b = face.b;
// face.b = face.c;
// face.c = b;
// geo.faces.push(face);
// }
// geo.computeVertexNormals();
// geo.computeFaceNormals();
} else if (doublesided){
if (doublesided){
var numFaces = geo.faces.length;
for (var i=0;i<numFaces;i++){
var face = geo.faces[i];
......
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