Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Amanda Ghassaei
OrigamiSimulator
Commits
2269d703
Commit
2269d703
authored
May 06, 2017
by
amandaghassaei
Browse files
stl save options
parent
54fd4251
Changes
6
Hide whitespace changes
Inline
Side-by-side
css/main.css
View file @
2269d703
...
@@ -325,3 +325,17 @@ svg{
...
@@ -325,3 +325,17 @@ svg{
margin-top
:
9px
;
margin-top
:
9px
;
color
:
white
;
color
:
white
;
}
}
.bigLabel
{
font-size
:
18px
;
}
.checkbox.bigLabel
.icons
,
.radio
.icons
{
top
:
2px
;
}
.smallTxt
{
font-size
:
14px
;
}
#stlFilename
{
width
:
300px
;
}
index.html
View file @
2269d703
...
@@ -597,13 +597,18 @@
...
@@ -597,13 +597,18 @@
<span
aria-hidden=
"true"
>
×
</span>
<span
aria-hidden=
"true"
>
×
</span>
</button>
</button>
<p><b>
Export STL
</b><br/><br/>
<p><b>
Export STL
</b><br/><br/>
settings:
<br/>
Filename:
<input
id=
"stlFilename"
value=
""
placeholder=
""
class=
"text form-control"
type=
"text"
>
.stl
<br/><br/>
single sided/double sided
<br/>
Scale:
<input
id=
"stlScale"
value=
""
placeholder=
""
class=
"form-control"
type=
"text"
><br/><br/>
scale
Dimensions:
<b><span
id=
"stlDimensions"
></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>
Double Sided
</label>
</p>
</p>
</div>
</div>
<div
class=
"modal-footer"
>
<div
class=
"modal-footer"
>
<button
id=
"doSTLsave"
type=
"button"
class=
"btn btn-success"
>
Save
</button>
<button
id=
"doSTLsave"
type=
"button"
class=
"btn btn-success"
data-dismiss=
"modal"
>
Save
</button>
<button
type=
"button"
class=
"btn btn default"
data-dismiss=
"modal"
>
Cancel
</button>
<button
type=
"button"
class=
"btn btn default"
data-dismiss=
"modal"
>
Cancel
</button>
</div>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-content -->
...
...
js/controls.js
View file @
2269d703
...
@@ -22,8 +22,22 @@ function initControls(globals){
...
@@ -22,8 +22,22 @@ function initControls(globals){
});
});
setLink
(
"
#exportSTL
"
,
function
(){
setLink
(
"
#exportSTL
"
,
function
(){
updateDimensions
();
$
(
"
#stlFilename
"
).
val
(
globals
.
filename
+
"
:
"
+
parseInt
(
globals
.
creasePercent
*
100
)
+
"
PercentFolded
"
);
$
(
'
#exportSTLModal
'
).
modal
(
'
show
'
);
$
(
'
#exportSTLModal
'
).
modal
(
'
show
'
);
});
});
setInput
(
"
#stlScale
"
,
globals
.
stlScale
,
function
(
val
){
globals
.
stlScale
=
val
;
updateDimensions
();
},
0
);
function
updateDimensions
(){
var
dim
=
globals
.
model
.
getDimensions
();
dim
.
multiplyScalar
(
globals
.
stlScale
/
globals
.
scale
);
$
(
"
#stlDimensions
"
).
html
(
dim
.
x
.
toFixed
(
2
)
+
"
x
"
+
dim
.
y
.
toFixed
(
2
)
+
"
x
"
+
dim
.
z
.
toFixed
(
2
));
}
setCheckbox
(
"
#doublesidedSTL
"
,
globals
.
doublesidedSTL
,
function
(
val
){
globals
.
doublesidedSTL
=
val
;
});
setLink
(
"
#doSTLsave
"
,
function
(){
setLink
(
"
#doSTLsave
"
,
function
(){
saveSTL
();
saveSTL
();
...
@@ -261,6 +275,7 @@ function initControls(globals){
...
@@ -261,6 +275,7 @@ function initControls(globals){
if
(
$input
.
hasClass
(
"
int
"
)){
if
(
$input
.
hasClass
(
"
int
"
)){
if
(
isNaN
(
parseInt
(
val
)))
return
;
if
(
isNaN
(
parseInt
(
val
)))
return
;
val
=
parseInt
(
val
);
val
=
parseInt
(
val
);
}
else
if
(
$input
.
hasClass
(
"
text
"
)){
}
else
{
}
else
{
if
(
isNaN
(
parseFloat
(
val
)))
return
;
if
(
isNaN
(
parseFloat
(
val
)))
return
;
val
=
parseFloat
(
val
);
val
=
parseFloat
(
val
);
...
...
js/globals.js
View file @
2269d703
...
@@ -8,6 +8,7 @@ function initGlobals(){
...
@@ -8,6 +8,7 @@ function initGlobals(){
var
_globals
=
{
var
_globals
=
{
navMode
:
"
simulation
"
,
navMode
:
"
simulation
"
,
scale
:
1
,
//view
//view
colorMode
:
"
color
"
,
colorMode
:
"
color
"
,
...
@@ -54,7 +55,7 @@ function initGlobals(){
...
@@ -54,7 +55,7 @@ function initGlobals(){
filename
:
null
,
filename
:
null
,
extension
:
null
,
extension
:
null
,
doublesidedSTL
:
false
,
doublesidedSTL
:
false
,
scale
:
1
,
s
tlS
cale
:
1
,
userInteractionEnabled
:
false
userInteractionEnabled
:
false
...
...
js/model.js
View file @
2269d703
...
@@ -343,6 +343,11 @@ function initModel(globals){
...
@@ -343,6 +343,11 @@ function initModel(globals){
return
creases
;
return
creases
;
}
}
function
getDimensions
(){
geometry
.
computeBoundingBox
();
return
geometry
.
boundingBox
.
max
.
clone
().
sub
(
geometry
.
boundingBox
.
min
);
}
return
{
return
{
pause
:
pause
,
pause
:
pause
,
resume
:
resume
,
resume
:
resume
,
...
@@ -361,6 +366,7 @@ function initModel(globals){
...
@@ -361,6 +366,7 @@ function initModel(globals){
getColorsArray
:
getColorsArray
,
getColorsArray
:
getColorsArray
,
sync
:
sync
,
sync
:
sync
,
getMesh
:
getMesh
,
getMesh
:
getMesh
,
getVertices
:
getVertices
getVertices
:
getVertices
,
getDimensions
:
getDimensions
}
}
}
}
\ No newline at end of file
js/saveSTL.js
View file @
2269d703
...
@@ -4,17 +4,33 @@
...
@@ -4,17 +4,33 @@
function
saveSTL
(){
function
saveSTL
(){
var
geo
=
globals
.
model
.
getGeometry
().
clone
();
var
geo
=
new
THREE
.
Geometry
().
fromBufferGeometry
(
globals
.
model
.
getGeometry
()
);
if
(
geo
.
vertices
.
length
==
0
)
{
if
(
geo
.
vertices
.
length
==
0
||
geo
.
faces
.
length
==
0
)
{
globals
.
warn
(
"
No geometry to save.
"
);
globals
.
warn
(
"
No geometry to save.
"
);
return
;
return
;
}
}
if
(
globals
.
stlScale
!=
1
){
for
(
var
i
=
0
;
i
<
geo
.
vertices
.
length
;
i
++
){
geo
.
vertices
[
i
].
multiplyScalar
(
globals
.
stlScale
);
}
}
if
(
globals
.
doublesidedSTL
){
var
numFaces
=
geo
.
faces
.
length
;
for
(
var
i
=
0
;
i
<
numFaces
;
i
++
){
var
face
=
geo
.
faces
[
i
];
geo
.
faces
.
push
(
new
THREE
.
Face3
(
face
.
a
,
face
.
c
,
face
.
b
));
}
}
var
data
=
[];
var
data
=
[];
data
.
push
({
geo
:
geo
,
offset
:
new
THREE
.
Vector3
(
0
,
0
,
0
),
orientation
:
new
THREE
.
Quaternion
(
0
,
0
,
0
,
1
)});
data
.
push
({
geo
:
geo
,
offset
:
new
THREE
.
Vector3
(
0
,
0
,
0
),
orientation
:
new
THREE
.
Quaternion
(
0
,
0
,
0
,
1
)});
var
stlBin
=
geometryToSTLBin
(
data
);
var
stlBin
=
geometryToSTLBin
(
data
);
if
(
!
stlBin
)
return
;
if
(
!
stlBin
)
return
;
var
blob
=
new
Blob
([
stlBin
],
{
type
:
'
application/octet-binary
'
});
var
blob
=
new
Blob
([
stlBin
],
{
type
:
'
application/octet-binary
'
});
saveAs
(
blob
,
globals
.
filename
+
"
:
"
+
parseInt
(
globals
.
creasePercent
*
100
)
+
"
PercentFolded.stl
"
);
var
filename
=
$
(
"
#stlFilename
"
).
val
();
$
(
"
#exportSTLModal
"
).
modal
(
"
hide
"
);
if
(
filename
==
""
)
filename
=
globals
.
filename
;
saveAs
(
blob
,
filename
+
"
.stl
"
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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