Commit 2bd1b7b5 authored by amandaghassaei's avatar amandaghassaei
Browse files

save stl

parent 25345a48
......@@ -210,6 +210,8 @@ input.form-control {
}
.modal-body{
padding: 20px 35px;
}
#aboutModal .modal-body{
padding-top: 40px;
}
......
......@@ -346,6 +346,7 @@
<script type="text/javascript" src="js/staticSolver.js"></script>
<script type="text/javascript" src="js/dynamic/dynamicModel.js"></script>
<script type="text/javascript" src="js/pattern.js"></script>
<script type="text/javascript" src="js/saveSTL.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</head>
......@@ -365,20 +366,12 @@
<ul class="dropdown-menu">
<li><a class="loadFile" href="#">Import SVG...</a></li>
<li class="divider"></li>
<li><a id="saveSVG" href="#">Save Pattern as SVG...</a></li>
<!--<li><a id="saveSVG" href="#">Save Pattern as SVG...</a></li>-->
<li><a id="exportSTL" href="#">Save Simulation as STL...</a></li>
</ul>
</li>
<li><a data-menu-id="navDesign" class="menuHoverControls" href="#">Pattern</a></li>
<li><a data-menu-id="navSim" class="menuHoverControls" href="#">Simulation</a></li>
<!--<li class="dropdown navDropdown">-->
<!--<a href="#" class="dropdown-toggle" id="viewMenuDropdown" data-toggle="dropdown">View <b class="caret"></b></a>-->
<!--<span class="dropdown-arrow"></span>-->
<!--<ul id="navViewMenu" class="dropdown-menu">-->
<!--<li><a href="#">thing1</a></li>-->
<!--<li><a href="#">things2</a></li>-->
<!--</ul>-->
<!--</li>-->
<li><a id="about" class="menuHoverControls" target="_blank" href="#">About</a></li>
</ul>
......@@ -450,12 +443,30 @@
https://github.com/mapbox/earcut
<br/><br/>
Built by <a href="http://www.amandaghassaei.com/" target="_blank">Amanda Ghassaei</a> as a homework assignment for <a href="http://courses.csail.mit.edu/6.849/spring17/" target="_blank">Geometric Folding Algorithms</a>.
Built by <a href="http://www.amandaghassaei.com/" target="_blank">Amanda Ghassaei</a> as a final project for <a href="http://courses.csail.mit.edu/6.849/spring17/" target="_blank">Geometric Folding Algorithms</a>.
Code available on <a href="https://github.com/amandaghassaei/OrigamiSimulator" target="_blank">Github</a>.
</p>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="modal fade" id="exportSTLModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-med">
<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>Export STL</b><br/><br/>
stl settings here...
</p>
</div>
<div class="modal-footer">
<button id="doSTLsave" type="button" class="btn btn-success">Save</button>
<button type="button" class="btn btn default" data-dismiss="modal">Cancel</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</body>
</html>
\ No newline at end of file
......@@ -18,6 +18,14 @@ function initControls(globals){
$('#aboutModal').modal('show');
});
setLink("#exportSTL", function(){
$('#exportSTLModal').modal('show');
});
setLink("#doSTLsave", function(){
saveSTL();
});
setCheckbox("#dynamic", globals.simType == "dynamic", function(val){
globals.simType = val;
});
......
......@@ -28,9 +28,9 @@ function initGlobals(){
//sim settings
creasePercent: 0,
axialStiffness: 1000,
creaseStiffness: 30,
panelStiffness: 30,
axialStiffness: 2000,
creaseStiffness: 70,
panelStiffness: 70,
//dynamic sim settings
percentDamping: 1,
......
......@@ -32,6 +32,10 @@ function initModel(globals){
var object3D = new THREE.Mesh(geometry, material);
globals.threeView.sceneAdd(object3D);
function getGeometry(){
return geometry;
}
var allNodeObject3Ds = [];
var nodes = [];
......@@ -224,6 +228,7 @@ function initModel(globals){
buildModel: buildModel,
getObjectsToIntersect: getObjectsToIntersect,
setMeshMaterial: setMeshMaterial,
updateEdgeVisibility: updateEdgeVisibility
updateEdgeVisibility: updateEdgeVisibility,
getGeometry: getGeometry
}
}
\ No newline at end of file
......@@ -614,17 +614,17 @@ function initPattern(globals){
}
function drawPattern(faces){
console.log("draw pattern");
object3D.children = [];
var geo = new THREE.Geometry();
geo.vertices = vertices;
geo.faces = faces;
geo.computeVertexNormals();
var mesh = new THREE.Mesh(geo, new THREE.MeshBasicMaterial({side:THREE.DoubleSide, color:0xffffff}));
// console.log("draw pattern");
// object3D.children = [];
//
// var geo = new THREE.Geometry();
// geo.vertices = vertices;
// geo.faces = faces;
// geo.computeVertexNormals();
// var mesh = new THREE.Mesh(geo, new THREE.MeshBasicMaterial({side:THREE.DoubleSide, color:0xffffff}));
// // object3D.add(mesh);
// var mesh = new THREE.Mesh(geo, new THREE.MeshBasicMaterial({color:0x000000, wireframe:true}));
// object3D.add(mesh);
var mesh = new THREE.Mesh(geo, new THREE.MeshBasicMaterial({color:0x000000, wireframe:true}));
object3D.add(mesh);
// object3D.add(new THREE.LineSegments(makeGeoFromSVGSegments(outlines),
// new THREE.LineBasicMaterial({color: 0x000000, linewidth: 4})));
......@@ -632,9 +632,9 @@ function initPattern(globals){
// new THREE.LineBasicMaterial({color: 0xff0000, linewidth: 4})));
// object3D.add(new THREE.LineSegments(makeGeoFromSVGSegments(valleys),
// new THREE.LineBasicMaterial({color: 0x0000ff, linewidth: 4})));
var bounds = new THREE.Box3().setFromObject(object3D);
var avg = (bounds.min.add(bounds.max)).multiplyScalar(0.5);
object3D.position.set(-avg.x, 0, -avg.z);
// var bounds = new THREE.Box3().setFromObject(object3D);
// var avg = (bounds.min.add(bounds.max)).multiplyScalar(0.5);
// object3D.position.set(-avg.x, 0, -avg.z);
}
function makeGeoFromSVGSegments(segments){
......
/**
* Created by amandaghassaei on 5/2/17.
*/
function saveSTL(){
var geo = globals.model.getGeometry();
if (geo.vertices.length == 0) {
console.warn("no geo");
return;
}
var data = [];
data.push({geo: geo, offset:new THREE.Vector3(0,0,0), orientation:new THREE.Quaternion(0,0,0,1)});
var stlBin = geometryToSTLBin(data);
if (!stlBin) return;
var blob = new Blob([stlBin], {type: 'application/octet-binary'});
saveAs(blob, "shell.stl");
}
\ 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