Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Amanda Ghassaei
OrigamiSimulator
Commits
2269d703
Commit
2269d703
authored
May 06, 2017
by
amandaghassaei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stl save options
parent
54fd4251
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
10 deletions
+67
-10
css/main.css
css/main.css
+14
-0
index.html
index.html
+9
-4
js/controls.js
js/controls.js
+15
-0
js/globals.js
js/globals.js
+2
-1
js/model.js
js/model.js
+7
-1
js/saveSTL.js
js/saveSTL.js
+20
-4
No files found.
css/main.css
View file @
2269d703
...
...
@@ -325,3 +325,17 @@ svg{
margin-top
:
9px
;
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 @@
<span
aria-hidden=
"true"
>
×
</span>
</button>
<p><b>
Export STL
</b><br/><br/>
settings:
<br/>
single sided/double sided
<br/>
scale
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=
"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>
</div>
<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>
</div>
</div>
<!-- /.modal-content -->
...
...
js/controls.js
View file @
2269d703
...
...
@@ -22,8 +22,22 @@ function initControls(globals){
});
setLink
(
"
#exportSTL
"
,
function
(){
updateDimensions
();
$
(
"
#stlFilename
"
).
val
(
globals
.
filename
+
"
:
"
+
parseInt
(
globals
.
creasePercent
*
100
)
+
"
PercentFolded
"
);
$
(
'
#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
(){
saveSTL
();
...
...
@@ -261,6 +275,7 @@ function initControls(globals){
if
(
$input
.
hasClass
(
"
int
"
)){
if
(
isNaN
(
parseInt
(
val
)))
return
;
val
=
parseInt
(
val
);
}
else
if
(
$input
.
hasClass
(
"
text
"
)){
}
else
{
if
(
isNaN
(
parseFloat
(
val
)))
return
;
val
=
parseFloat
(
val
);
...
...
js/globals.js
View file @
2269d703
...
...
@@ -8,6 +8,7 @@ function initGlobals(){
var
_globals
=
{
navMode
:
"
simulation
"
,
scale
:
1
,
//view
colorMode
:
"
color
"
,
...
...
@@ -54,7 +55,7 @@ function initGlobals(){
filename
:
null
,
extension
:
null
,
doublesidedSTL
:
false
,
scale
:
1
,
s
tlS
cale
:
1
,
userInteractionEnabled
:
false
...
...
js/model.js
View file @
2269d703
...
...
@@ -343,6 +343,11 @@ function initModel(globals){
return
creases
;
}
function
getDimensions
(){
geometry
.
computeBoundingBox
();
return
geometry
.
boundingBox
.
max
.
clone
().
sub
(
geometry
.
boundingBox
.
min
);
}
return
{
pause
:
pause
,
resume
:
resume
,
...
...
@@ -361,6 +366,7 @@ function initModel(globals){
getColorsArray
:
getColorsArray
,
sync
:
sync
,
getMesh
:
getMesh
,
getVertices
:
getVertices
getVertices
:
getVertices
,
getDimensions
:
getDimensions
}
}
\ No newline at end of file
js/saveSTL.js
View file @
2269d703
...
...
@@ -4,17 +4,33 @@
function
saveSTL
(){
var
geo
=
globals
.
model
.
getGeometry
().
clone
();
if
(
geo
.
vertices
.
length
==
0
)
{
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
.
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
=
[];
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
,
globals
.
filename
+
"
:
"
+
parseInt
(
globals
.
creasePercent
*
100
)
+
"
PercentFolded.stl
"
);
$
(
"
#exportSTLModal
"
).
modal
(
"
hide
"
);
var
filename
=
$
(
"
#stlFilename
"
).
val
();
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