Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Amanda Ghassaei
OrigamiSimulator
Commits
bf0688d7
Commit
bf0688d7
authored
May 06, 2017
by
amandaghassaei
Browse files
save fold options
parent
2269d703
Changes
6
Hide whitespace changes
Inline
Side-by-side
css/main.css
View file @
bf0688d7
...
...
@@ -336,6 +336,6 @@ svg{
.smallTxt
{
font-size
:
14px
;
}
#stlFilename
{
input
.form-control.bigInput
{
width
:
300px
;
}
index.html
View file @
bf0688d7
...
...
@@ -374,6 +374,7 @@
<script
type=
"text/javascript"
src=
"js/dynamic/dynamicSolver.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/saveFOLD.js"
></script>
<script
type=
"text/javascript"
src=
"js/importer.js"
></script>
...
...
@@ -411,6 +412,7 @@
<li><a
class=
"loadFile"
href=
"#"
>
Import... (SVG / FOLD / txt)
</a></li>
<li
class=
"divider"
></li>
<li><a
id=
"exportFOLD"
href=
"#"
>
Save Simulation as FOLD...
</a></li>
<li><a
id=
"exportSTL"
href=
"#"
>
Save Simulation as STL...
</a></li>
<li><a
id=
"saveSVG"
href=
"#"
>
Save Pattern as SVG...
</a></li>
<!--<li><a id="saveSVGScreenshot" href="#">Save SVG screenshot</a></li>-->
...
...
@@ -597,9 +599,9 @@
<span
aria-hidden=
"true"
>
×
</span>
</button>
<p><b>
Export STL
</b><br/><br/>
Filename:
<input
id=
"stlFilename"
value=
""
placeholder=
""
class=
"text form-control"
type=
"text"
>
.stl
<br/><br/>
Scale:
<input
id=
"stlScale"
value=
""
placeholder=
""
class=
"form-control"
type=
"text"
><br/><br/>
Dimensions:
<b><span
id=
"stl
Dimensions"
></span></b><br/>
Filename:
<input
id=
"stlFilename"
value=
""
placeholder=
""
class=
"
bigInput
text form-control"
type=
"text"
>
.stl
<br/><br/>
Scale:
<input
value=
""
placeholder=
""
class=
"
exportScale
form-control"
type=
"text"
><br/><br/>
Dimensions:
<b><span
class=
"export
Dimensions"
></span></b><br/>
<span
class=
"smallTxt"
>
(the STL file format is unitless, but typically assumed to be either in inches or mm)
</span><br/><br/>
<label
class=
"bigLabel checkbox"
for=
"doublesidedSTL"
>
<input
id=
"doublesidedSTL"
data-toggle=
"checkbox"
class=
"custom-checkbox layersSelector"
type=
"checkbox"
><span
class=
"icons"
><span
class=
"icon-unchecked"
></span><span
class=
"icon-checked"
></span></span>
...
...
@@ -614,6 +616,29 @@
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<div
class=
"modal fade"
id=
"exportFOLDModal"
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"
>
×
</span>
</button>
<p><b>
Export FOLD
</b><br/><br/>
Filename:
<input
id=
"foldFilename"
value=
""
placeholder=
""
class=
"bigInput text form-control"
type=
"text"
>
.stl
<br/><br/>
Author:
<input
id=
"foldAuthor"
value=
"Amanda Ghassaei"
placeholder=
""
class=
"bigInput text form-control"
type=
"text"
><br/><br/>
Scale:
<input
value=
""
placeholder=
""
class=
"exportScale form-control"
type=
"text"
><br/><br/>
Dimensions:
<b><span
class=
"exportDimensions"
></span></b><br/>
<span
class=
"smallTxt"
>
(the FOLD file format is unitless)
</span><br/><br/>
</p>
</div>
<div
class=
"modal-footer"
>
<button
id=
"doFOLDsave"
type=
"button"
class=
"btn btn-success"
data-dismiss=
"modal"
>
Save
</button>
<button
type=
"button"
class=
"btn btn default"
data-dismiss=
"modal"
>
Cancel
</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<div
class=
"modal fade"
id=
"importFoldModal"
tabindex=
"-1"
role=
"dialog"
>
<div
class=
"modal-dialog modal-med"
>
<div
class=
"modal-content"
>
...
...
js/controls.js
View file @
bf0688d7
...
...
@@ -21,19 +21,24 @@ function initControls(globals){
$
(
'
#tipsModal
'
).
modal
(
'
show
'
);
});
setLink
(
"
#exportFOLD
"
,
function
(){
updateDimensions
();
$
(
"
#foldFilename
"
).
val
(
globals
.
filename
+
"
:
"
+
parseInt
(
globals
.
creasePercent
*
100
)
+
"
PercentFolded
"
);
$
(
'
#exportFOLDModal
'
).
modal
(
'
show
'
);
});
setLink
(
"
#exportSTL
"
,
function
(){
updateDimensions
();
$
(
"
#stlFilename
"
).
val
(
globals
.
filename
+
"
:
"
+
parseInt
(
globals
.
creasePercent
*
100
)
+
"
PercentFolded
"
);
$
(
'
#exportSTLModal
'
).
modal
(
'
show
'
);
});
setInput
(
"
#stl
Scale
"
,
globals
.
stl
Scale
,
function
(
val
){
globals
.
stl
Scale
=
val
;
setInput
(
"
.export
Scale
"
,
globals
.
export
Scale
,
function
(
val
){
globals
.
export
Scale
=
val
;
updateDimensions
();
},
0
);
function
updateDimensions
(){
var
dim
=
globals
.
model
.
getDimensions
();
dim
.
multiplyScalar
(
globals
.
stl
Scale
/
globals
.
scale
);
$
(
"
#stl
Dimensions
"
).
html
(
dim
.
x
.
toFixed
(
2
)
+
"
x
"
+
dim
.
y
.
toFixed
(
2
)
+
"
x
"
+
dim
.
z
.
toFixed
(
2
));
dim
.
multiplyScalar
(
globals
.
export
Scale
/
globals
.
scale
);
$
(
"
.export
Dimensions
"
).
html
(
dim
.
x
.
toFixed
(
2
)
+
"
x
"
+
dim
.
y
.
toFixed
(
2
)
+
"
x
"
+
dim
.
z
.
toFixed
(
2
));
}
setCheckbox
(
"
#doublesidedSTL
"
,
globals
.
doublesidedSTL
,
function
(
val
){
globals
.
doublesidedSTL
=
val
;
...
...
@@ -42,6 +47,9 @@ function initControls(globals){
setLink
(
"
#doSTLsave
"
,
function
(){
saveSTL
();
});
setLink
(
"
#doFOLDsave
"
,
function
(){
saveFOLD
();
});
setLink
(
"
#navPattern
"
,
function
(){
...
...
js/globals.js
View file @
bf0688d7
...
...
@@ -55,7 +55,7 @@ function initGlobals(){
filename
:
null
,
extension
:
null
,
doublesidedSTL
:
false
,
stl
Scale
:
1
,
export
Scale
:
1
,
userInteractionEnabled
:
false
...
...
js/saveFOLD.js
0 → 100644
View file @
bf0688d7
/**
* Created by amandaghassaei on 5/6/17.
*/
function
saveFOLD
(){
var
geo
=
new
THREE
.
Geometry
().
fromBufferGeometry
(
globals
.
model
.
getGeometry
()
);
if
(
geo
.
vertices
.
length
==
0
||
geo
.
faces
.
length
==
0
)
{
globals
.
warn
(
"
No geometry to save.
"
);
return
;
}
if
(
globals
.
exportScale
!=
1
){
for
(
var
i
=
0
;
i
<
geo
.
vertices
.
length
;
i
++
){
geo
.
vertices
[
i
].
multiplyScalar
(
globals
.
exportScale
);
}
}
// 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'});
var
filename
=
$
(
"
#foldFilename
"
).
val
();
if
(
filename
==
""
)
filename
=
globals
.
filename
;
saveAs
(
blob
,
filename
+
"
.fold
"
);
}
\ No newline at end of file
js/saveSTL.js
View file @
bf0688d7
...
...
@@ -11,9 +11,9 @@ function saveSTL(){
return
;
}
if
(
globals
.
stl
Scale
!=
1
){
if
(
globals
.
export
Scale
!=
1
){
for
(
var
i
=
0
;
i
<
geo
.
vertices
.
length
;
i
++
){
geo
.
vertices
[
i
].
multiplyScalar
(
globals
.
stl
Scale
);
geo
.
vertices
[
i
].
multiplyScalar
(
globals
.
export
Scale
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment