Commit ec4f1687 authored by amandaghassaei's avatar amandaghassaei
Browse files

small changes

parent 9013cba1
...@@ -620,6 +620,20 @@ ...@@ -620,6 +620,20 @@
<span class="dropdown-arrow"></span> <span class="dropdown-arrow"></span>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a id="menuVis" href="#">Toggle Menu Visibility</a></li> <li><a id="menuVis" href="#">Toggle Menu Visibility</a></li>
<li class="divider"></li>
<li><a id="rotateX" href="#">Rotate Model X</a></li>
<li><a id="rotateY" href="#">Rotate Model Y</a></li>
<li><a id="rotateZ" href="#">Rotate Model Z</a></li>
<li><a id="stopRotation" href="#">Stop Rotation</a></li>
<li><a id="changeRotationSpeed" href="#">Change Rotation Speed...</a></li>
<li class="divider"></li>
<li><a href="#" id="cameraZ">View Front</a></li>
<li><a href="#" id="cameraMinusZ">View Back</a></li>
<li><a href="#" id="cameraX">View Right</a></li>
<li><a href="#" id="cameraMinusX">View Left</a></li>
<li><a href="#" id="cameraY">View Top</a></li>
<li><a href="#" id="cameraMinusY">View Bottom</a></li>
<li><a href="#" id="cameraOrtho">View Ortho</a></li>
</ul> </ul>
</li> </li>
<li><a id="navPattern" href="#">Pattern</a></li> <li><a id="navPattern" href="#">Pattern</a></li>
...@@ -647,7 +661,7 @@ ...@@ -647,7 +661,7 @@
<div id="controls"> <div id="controls">
<div class="sliderInput floatRight" id="creasePercent"> <div class="sliderInput floatRight" id="creasePercent">
<span class="label-slider">Fold Angle (-1 to 1) : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div> <span class="label-slider">Fold Angle (-1 to 1) : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div>
<input value="" placeholder="" class="form-control" type="text"> <input value="" placeholder="" class="float form-control" type="text">
</div><br/><br/> </div><br/><br/>
<div id="simButtons" class="alignRight"> <div id="simButtons" class="alignRight">
<a href="#" id="start" class="paddingBottom btn btn-lg btn-success">Start Simulation</a> <a href="#" id="start" class="paddingBottom btn btn-lg btn-success">Start Simulation</a>
...@@ -655,7 +669,7 @@ ...@@ -655,7 +669,7 @@
<a href="#" id="reset" class="paddingBottom btn btn-lg btn-default">Reset</a> <a href="#" id="reset" class="paddingBottom btn btn-lg btn-default">Reset</a>
<div id="stepForwardOptions" class="floatRight"> <div id="stepForwardOptions" class="floatRight">
<a href="#" id="stepForward" class="btn btn-lg btn-default">Step Forward</a> <a href="#" id="stepForward" class="btn btn-lg btn-default">Step Forward</a>
<label>Num Steps:</label> &nbsp;&nbsp;<input id="numSteps" value="100" placeholder="" class="form-control" type="text"> <label>Num Steps:</label> &nbsp;&nbsp;<input id="numSteps" value="100" placeholder="" class="int form-control" type="text">
<br/><br/> <br/><br/>
</div> </div>
</div> </div>
...@@ -688,23 +702,23 @@ ...@@ -688,23 +702,23 @@
<div id="simulationSettings" class="hide"> <div id="simulationSettings" class="hide">
<div class="sliderInput paddingBottom" id="axialStiffness"> <div class="sliderInput paddingBottom" id="axialStiffness">
<span class="label-slider">Axial Stiffness : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div> <span class="label-slider">Axial Stiffness : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div>
<input value="" placeholder="" class="form-control" type="text"> <input value="" placeholder="" class="float form-control" type="text">
</div> </div>
<!--<div class="sliderInput paddingBottom" id="triStiffness">--> <!--<div class="sliderInput paddingBottom" id="triStiffness">-->
<!--<span class="label-slider">Triangle Stiffness : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div>--> <!--<span class="label-slider">Triangle Stiffness : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div>-->
<!--<input value="" placeholder="" class="form-control" type="text">--> <!--<input value="" placeholder="" class="float form-control" type="text">-->
<!--</div>--> <!--</div>-->
<div class="sliderInput" id="creaseStiffness"> <div class="sliderInput" id="creaseStiffness">
<span class="label-slider">Fold Stiffness : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div> <span class="label-slider">Fold Stiffness : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div>
<input value="" placeholder="" class="form-control" type="text"> <input value="" placeholder="" class="float form-control" type="text">
</div> </div>
<div class="sliderInput" id="panelStiffness"> <div class="sliderInput" id="panelStiffness">
<span class="label-slider">Facet Stiffness : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div> <span class="label-slider">Facet Stiffness : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div>
<input value="" placeholder="" class="form-control" type="text"> <input value="" placeholder="" class="float form-control" type="text">
</div> </div>
<div class="sliderInput" id="percentDamping"> <div class="sliderInput" id="percentDamping">
<span class="label-slider">Damping (0-1): </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div> <span class="label-slider">Damping (0-1): </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div>
<input value="" placeholder="" class="form-control" type="text"> <input value="" placeholder="" class="float form-control" type="text">
</div> </div>
</div><br/> </div><br/>
</div> </div>
...@@ -810,18 +824,6 @@ ...@@ -810,18 +824,6 @@
<a href="#" id="enterVR" class="displayBlock btn btn-lg btn-inverse"></a> <a href="#" id="enterVR" class="displayBlock btn btn-lg btn-inverse"></a>
</div><br/><br/> </div><br/><br/>
</div><br/> </div><br/>
<div>
<a href="#" class="seeMore closed" data-id="cameraAngle"><span class="fui-triangle-down"></span>View Angle:</a><br/>
</div>
<div id="cameraAngle" class="hide indent ">
<a href="#" id="cameraZ" class="paddingBottom btn btn-sm btn-default">Front</a>
<a href="#" id="cameraMinusZ" class="paddingBottom btn btn-sm btn-default">Back</a>
<a href="#" id="cameraX" class="paddingBottom btn btn-sm btn-default">Right</a>
<a href="#" id="cameraMinusX" class="paddingBottom btn btn-sm btn-default">Left</a><br/>
<a href="#" id="cameraY" class="btn btn-sm btn-default">Top</a>
<a href="#" id="cameraMinusY" class="btn btn-sm btn-default">Bottom</a>
<a href="#" id="cameraOrtho" class="btn btn-sm btn-default">Ortho</a>
</div>
<div class="extraSpace"></div> <div class="extraSpace"></div>
</div> </div>
</div> </div>
...@@ -960,7 +962,7 @@ ...@@ -960,7 +962,7 @@
</button> </button>
<b>Export STL</b><br/><br/> <b>Export STL</b><br/><br/>
Filename: &nbsp;&nbsp;<input id="stlFilename" value="" placeholder="" class="bigInput text form-control" type="text"> .stl<br/><br/> Filename: &nbsp;&nbsp;<input id="stlFilename" value="" placeholder="" class="bigInput text form-control" type="text"> .stl<br/><br/>
Scale: &nbsp;&nbsp;<input value="" placeholder="" class="exportScale form-control" type="text"><br/><br/> Scale: &nbsp;&nbsp;<input value="" placeholder="" class="float exportScale form-control" type="text"><br/><br/>
Dimensions: &nbsp;&nbsp;<b><span class="exportDimensions"></span></b><br/> Dimensions: &nbsp;&nbsp;<b><span class="exportDimensions"></span></b><br/>
<span class="smallTxt">(the STL file format is unitless, but typically assumed to be either in inches or mm)</span><br/> <span class="smallTxt">(the STL file format is unitless, but typically assumed to be either in inches or mm)</span><br/>
<label class="bigLabel checkbox" for="doublesidedSTL"> <label class="bigLabel checkbox" for="doublesidedSTL">
...@@ -983,7 +985,7 @@ ...@@ -983,7 +985,7 @@
</button> </button>
<b>Export OBJ</b><br/><br/> <b>Export OBJ</b><br/><br/>
Filename: &nbsp;&nbsp;<input id="objFilename" value="" placeholder="" class="bigInput text form-control" type="text"> .stl<br/><br/> Filename: &nbsp;&nbsp;<input id="objFilename" value="" placeholder="" class="bigInput text form-control" type="text"> .stl<br/><br/>
Scale: &nbsp;&nbsp;<input value="" placeholder="" class="exportScale form-control" type="text"><br/><br/> Scale: &nbsp;&nbsp;<input value="" placeholder="" class="float exportScale form-control" type="text"><br/><br/>
Dimensions: &nbsp;&nbsp;<b><span class="exportDimensions"></span></b><br/> Dimensions: &nbsp;&nbsp;<b><span class="exportDimensions"></span></b><br/>
<span class="smallTxt">(the OBJ file format is unitless, but typically assumed to be either in inches or mm)</span><br/> <span class="smallTxt">(the OBJ file format is unitless, but typically assumed to be either in inches or mm)</span><br/>
<label class="bigLabel checkbox" for="doublesidedOBJ"> <label class="bigLabel checkbox" for="doublesidedOBJ">
...@@ -1007,7 +1009,7 @@ ...@@ -1007,7 +1009,7 @@
<b>Export FOLD</b><br/><br/> <b>Export FOLD</b><br/><br/>
Filename: &nbsp;&nbsp;<input id="foldFilename" value="" placeholder="" class="bigInput text form-control" type="text"> .fold<br/><br/> Filename: &nbsp;&nbsp;<input id="foldFilename" value="" placeholder="" class="bigInput text form-control" type="text"> .fold<br/><br/>
Author: &nbsp;&nbsp;<input id="foldAuthor" value="Amanda Ghassaei" placeholder="" class="bigInput text form-control" type="text"><br/><br/> Author: &nbsp;&nbsp;<input id="foldAuthor" value="Amanda Ghassaei" placeholder="" class="bigInput text form-control" type="text"><br/><br/>
Scale: &nbsp;&nbsp;<input value="" placeholder="" class="exportScale form-control" type="text">&nbsp;&nbsp;&nbsp;&nbsp; Scale: &nbsp;&nbsp;<input value="" placeholder="" class="float exportScale form-control" type="text">&nbsp;&nbsp;&nbsp;&nbsp;
Units: &nbsp;&nbsp; Units: &nbsp;&nbsp;
<div class="btn-group"> <div class="btn-group">
<button data-toggle="dropdown" class="btn btn-default dropdown-toggle" type="button"><span class="unitsDisplay"></span> <span class="caret"></span></button> <button data-toggle="dropdown" class="btn btn-default dropdown-toggle" type="button"><span class="unitsDisplay"></span> <span class="caret"></span></button>
...@@ -1186,5 +1188,20 @@ ...@@ -1186,5 +1188,20 @@
</div><!-- /.modal-content --> </div><!-- /.modal-content -->
</div><!-- /.modal-dialog --> </div><!-- /.modal-dialog -->
</div><!-- /.modal --> </div><!-- /.modal -->
<div class="modal fade" id="changeRotationSpeedModal" tabindex="-1" role="dialog">
<div class="modal-dialog sm">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<p><b>ROTATION SPEED</b><br/><br/>
Speed : &nbsp;&nbsp;<input id="rotationSpeed" value="" placeholder="" class="float form-control" type="text"> &nbsp;&nbsp;<span class="smallTxt">( radians per frame )</span>
</p>
</div>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -112,6 +112,30 @@ function initControls(globals){ ...@@ -112,6 +112,30 @@ function initControls(globals){
saveFOLD(); saveFOLD();
}); });
setLink("#rotateX", function(){
globals.threeView.resetModel();
globals.rotateModel = "x";
});
setLink("#rotateY", function(){
globals.threeView.resetModel();
globals.rotateModel = "y";
});
setLink("#rotateZ", function(){
globals.threeView.resetModel();
globals.rotateModel = "z";
});
setLink("#stopRotation", function(){
globals.rotateModel = null;
globals.threeView.resetModel();
});
setLink("#changeRotationSpeed", function(){
$("#changeRotationSpeedModal").modal("show");
});
setInput("#rotationSpeed", globals.rotationSpeed, function(val){
globals.rotationSpeed = val;
}, 0);
setLink("#navPattern", function(){ setLink("#navPattern", function(){
if (globals.noCreasePatternAvailable()){ if (globals.noCreasePatternAvailable()){
globals.warn("No crease pattern available for FOLD format."); globals.warn("No crease pattern available for FOLD format.");
......
...@@ -77,8 +77,10 @@ function initGlobals(){ ...@@ -77,8 +77,10 @@ function initGlobals(){
userInteractionEnabled: false, userInteractionEnabled: false,
vrEnabled: false, vrEnabled: false,
numSteps: 100 numSteps: 100,
rotateModel: null,
rotationSpeed: 0.01
}; };
function setCreasePercent(percent){ function setCreasePercent(percent){
......
...@@ -25,8 +25,29 @@ function makeSaveGEO(doublesided){ ...@@ -25,8 +25,29 @@ function makeSaveGEO(doublesided){
var lastFaceIndex = 0; var lastFaceIndex = 0;
for (var j=0;j<geo.faces.length;j++){ for (var j=0;j<geo.faces.length;j++){
face = geo.faces[j]; face = geo.faces[j];
if (face.a == i || face.b == i || face.c == i) { if (face.a == i) {
vertexNormal.add(face.normal); 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; lastFaceIndex = j;
} }
// if (vertexNormal !== null) break; // if (vertexNormal !== null) break;
...@@ -35,24 +56,24 @@ function makeSaveGEO(doublesided){ ...@@ -35,24 +56,24 @@ function makeSaveGEO(doublesided){
// geo.vertices.push(new THREE.Vector3()); // geo.vertices.push(new THREE.Vector3());
// continue; // continue;
// } // }
//filter out duplicate normals
vertexNormal.normalize(); vertexNormal.normalize();
console.log(vertexNormal);
var offset = vertexNormal.clone().multiplyScalar(globals.thickenOffset/(2*vertexNormal.clone().dot(geo.faces[lastFaceIndex].normal))); 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.push(geo.vertices[i].clone().sub(offset));
geo.vertices[i].add(offset); geo.vertices[i].add(offset);
} }
var numFaces = geo.faces.length; // var numFaces = geo.faces.length;
for (var i=0;i<numFaces;i++){ // for (var i=0;i<numFaces;i++){
var face = geo.faces[i].clone(); // var face = geo.faces[i].clone();
face.a += numVertices; // face.a += numVertices;
face.b += numVertices; // face.b += numVertices;
face.c += numVertices; // face.c += numVertices;
var b = face.b; // var b = face.b;
face.b = face.c; // face.b = face.c;
face.c = b; // face.c = b;
geo.faces.push(face); // geo.faces.push(face);
} // }
geo.computeVertexNormals(); geo.computeVertexNormals();
geo.computeFaceNormals(); geo.computeFaceNormals();
......
...@@ -104,6 +104,11 @@ function initThreeView(globals) { ...@@ -104,6 +104,11 @@ function initThreeView(globals) {
} }
function _loop(callback){ function _loop(callback){
if (globals.rotateModel !== null){
if (globals.rotateModel == "x") modelWrapper.rotateX(globals.rotationSpeed);
if (globals.rotateModel == "y") modelWrapper.rotateY(globals.rotationSpeed);
if (globals.rotateModel == "z") modelWrapper.rotateZ(globals.rotationSpeed);
}
if (globals.needsSync){ if (globals.needsSync){
globals.model.sync(); globals.model.sync();
} }
...@@ -182,6 +187,10 @@ function initThreeView(globals) { ...@@ -182,6 +187,10 @@ function initThreeView(globals) {
document.body.removeChild(downloadLink); document.body.removeChild(downloadLink);
} }
function resetModel(){
modelWrapper.rotation.set(0,0,0);
}
return { return {
sceneAddModel: sceneAddModel, sceneAddModel: sceneAddModel,
...@@ -203,6 +212,8 @@ function initThreeView(globals) { ...@@ -203,6 +212,8 @@ function initThreeView(globals) {
setCameraX:setCameraX, setCameraX:setCameraX,
setCameraY: setCameraY, setCameraY: setCameraY,
setCameraZ: setCameraZ, setCameraZ: setCameraZ,
setCameraOrtho: setCameraOrtho setCameraOrtho: setCameraOrtho,
resetModel: resetModel//reset model orientation
} }
} }
\ No newline at end of file
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