Skip to content
GitLab
Menu
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
e94f9a8a
Commit
e94f9a8a
authored
Jun 01, 2017
by
amandaghassaei
Browse files
starting to add wall thickness export
parent
593c6cb3
Changes
2
Hide whitespace changes
Inline
Side-by-side
js/globals.js
View file @
e94f9a8a
...
...
@@ -64,6 +64,8 @@ function initGlobals(){
doublesidedSTL
:
false
,
doublesidedOBJ
:
false
,
exportScale
:
1
,
thickenModel
:
true
,
thickenOffset
:
5
,
//save fold settings
foldUnits
:
"
unit
"
,
...
...
js/saveSTL.js
View file @
e94f9a8a
...
...
@@ -10,19 +10,58 @@ function makeSaveGEO(doublesided){
return
;
}
if
(
globals
.
exportScale
!=
1
){
for
(
var
i
=
0
;
i
<
geo
.
vertices
.
length
;
i
++
){
geo
.
vertices
[
i
].
multiplyScalar
(
globals
.
exportScale
);
}
for
(
var
i
=
0
;
i
<
geo
.
vertices
.
length
;
i
++
){
geo
.
vertices
[
i
].
multiplyScalar
(
globals
.
exportScale
/
globals
.
scale
);
}
if
(
doublesided
){
if
(
globals
.
thickenModel
){
var
numVertices
=
geo
.
vertices
.
length
;
geo
.
computeVertexNormals
();
geo
.
computeFaceNormals
();
for
(
var
i
=
0
;
i
<
numVertices
;
i
++
){
var
face
;
var
vertexNormal
=
null
;
for
(
var
j
=
0
;
j
<
geo
.
faces
.
length
;
j
++
){
face
=
geo
.
faces
[
j
];
if
(
face
.
a
==
i
)
vertexNormal
=
face
.
vertexNormals
[
0
];
if
(
face
.
b
==
i
)
vertexNormal
=
face
.
vertexNormals
[
1
];
if
(
face
.
c
==
i
)
vertexNormal
=
face
.
vertexNormals
[
2
];
if
(
vertexNormal
!==
null
)
break
;
}
if
(
vertexNormal
===
undefined
)
{
geo
.
vertices
.
push
(
new
THREE
.
Vector3
());
continue
;
}
var
offset
=
vertexNormal
.
clone
().
multiplyScalar
(
globals
.
thickenOffset
/
(
2
*
vertexNormal
.
dot
(
face
.
normal
)));
console
.
log
(
offset
.
length
());
geo
.
vertices
.
push
(
geo
.
vertices
[
i
].
clone
().
sub
(
offset
));
geo
.
vertices
[
i
].
add
(
offset
);
}
var
numFaces
=
geo
.
faces
.
length
;
for
(
var
i
=
0
;
i
<
numFaces
;
i
++
){
var
face
=
geo
.
faces
[
i
].
clone
();
face
.
a
+=
numVertices
;
face
.
b
+=
numVertices
;
face
.
c
+=
numVertices
;
var
b
=
face
.
b
;
face
.
b
=
face
.
c
;
face
.
c
=
b
;
geo
.
faces
.
push
(
face
);
}
geo
.
computeVertexNormals
();
geo
.
computeFaceNormals
();
}
else
if
(
doublesided
){
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
));
}
}
return
geo
;
}
...
...
Write
Preview
Supports
Markdown
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