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
ec4f1687
Commit
ec4f1687
authored
Jun 02, 2017
by
amandaghassaei
Browse files
small changes
parent
9013cba1
Changes
5
Hide whitespace changes
Inline
Side-by-side
index.html
View file @
ec4f1687
...
...
@@ -620,6 +620,20 @@
<span
class=
"dropdown-arrow"
></span>
<ul
class=
"dropdown-menu"
>
<li><a
id=
"menuVis"
href=
"#"
>
Toggle Menu Visibility
</a></li>
<li
class=
"divider"
></li>
<li><a
id=
"rotateX"
href=
"#"
>
Rotate Model X
</a></li>
<li><a
id=
"rotateY"
href=
"#"
>
Rotate Model Y
</a></li>
<li><a
id=
"rotateZ"
href=
"#"
>
Rotate Model Z
</a></li>
<li><a
id=
"stopRotation"
href=
"#"
>
Stop Rotation
</a></li>
<li><a
id=
"changeRotationSpeed"
href=
"#"
>
Change Rotation Speed...
</a></li>
<li
class=
"divider"
></li>
<li><a
href=
"#"
id=
"cameraZ"
>
View Front
</a></li>
<li><a
href=
"#"
id=
"cameraMinusZ"
>
View Back
</a></li>
<li><a
href=
"#"
id=
"cameraX"
>
View Right
</a></li>
<li><a
href=
"#"
id=
"cameraMinusX"
>
View Left
</a></li>
<li><a
href=
"#"
id=
"cameraY"
>
View Top
</a></li>
<li><a
href=
"#"
id=
"cameraMinusY"
>
View Bottom
</a></li>
<li><a
href=
"#"
id=
"cameraOrtho"
>
View Ortho
</a></li>
</ul>
</li>
<li><a
id=
"navPattern"
href=
"#"
>
Pattern
</a></li>
...
...
@@ -647,7 +661,7 @@
<div
id=
"controls"
>
<div
class=
"sliderInput floatRight"
id=
"creasePercent"
>
<span
class=
"label-slider"
>
Fold Angle (-1 to 1) :
</span><div
class=
"flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"
></div>
<input
value=
""
placeholder=
""
class=
"form-control"
type=
"text"
>
<input
value=
""
placeholder=
""
class=
"
float
form-control"
type=
"text"
>
</div><br/><br/>
<div
id=
"simButtons"
class=
"alignRight"
>
<a
href=
"#"
id=
"start"
class=
"paddingBottom btn btn-lg btn-success"
>
Start Simulation
</a>
...
...
@@ -655,7 +669,7 @@
<a
href=
"#"
id=
"reset"
class=
"paddingBottom btn btn-lg btn-default"
>
Reset
</a>
<div
id=
"stepForwardOptions"
class=
"floatRight"
>
<a
href=
"#"
id=
"stepForward"
class=
"btn btn-lg btn-default"
>
Step Forward
</a>
<label>
Num Steps:
</label>
<input
id=
"numSteps"
value=
"100"
placeholder=
""
class=
"form-control"
type=
"text"
>
<label>
Num Steps:
</label>
<input
id=
"numSteps"
value=
"100"
placeholder=
""
class=
"
int
form-control"
type=
"text"
>
<br/><br/>
</div>
</div>
...
...
@@ -688,23 +702,23 @@
<div
id=
"simulationSettings"
class=
"hide"
>
<div
class=
"sliderInput paddingBottom"
id=
"axialStiffness"
>
<span
class=
"label-slider"
>
Axial Stiffness :
</span><div
class=
"flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"
></div>
<input
value=
""
placeholder=
""
class=
"form-control"
type=
"text"
>
<input
value=
""
placeholder=
""
class=
"
float
form-control"
type=
"text"
>
</div>
<!--<div class="sliderInput paddingBottom" id="triStiffness">-->
<!--<span class="label-slider">Triangle Stiffness : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div>-->
<!--<input value="" placeholder="" class="form-control" type="text">-->
<!--<input value="" placeholder="" class="
float
form-control" type="text">-->
<!--</div>-->
<div
class=
"sliderInput"
id=
"creaseStiffness"
>
<span
class=
"label-slider"
>
Fold Stiffness :
</span><div
class=
"flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"
></div>
<input
value=
""
placeholder=
""
class=
"form-control"
type=
"text"
>
<input
value=
""
placeholder=
""
class=
"
float
form-control"
type=
"text"
>
</div>
<div
class=
"sliderInput"
id=
"panelStiffness"
>
<span
class=
"label-slider"
>
Facet Stiffness :
</span><div
class=
"flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"
></div>
<input
value=
""
placeholder=
""
class=
"form-control"
type=
"text"
>
<input
value=
""
placeholder=
""
class=
"
float
form-control"
type=
"text"
>
</div>
<div
class=
"sliderInput"
id=
"percentDamping"
>
<span
class=
"label-slider"
>
Damping (0-1):
</span><div
class=
"flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"
></div>
<input
value=
""
placeholder=
""
class=
"form-control"
type=
"text"
>
<input
value=
""
placeholder=
""
class=
"
float
form-control"
type=
"text"
>
</div>
</div><br/>
</div>
...
...
@@ -810,18 +824,6 @@
<a
href=
"#"
id=
"enterVR"
class=
"displayBlock btn btn-lg btn-inverse"
></a>
</div><br/><br/>
</div><br/>
<div>
<a
href=
"#"
class=
"seeMore closed"
data-id=
"cameraAngle"
><span
class=
"fui-triangle-down"
></span>
View Angle:
</a><br/>
</div>
<div
id=
"cameraAngle"
class=
"hide indent "
>
<a
href=
"#"
id=
"cameraZ"
class=
"paddingBottom btn btn-sm btn-default"
>
Front
</a>
<a
href=
"#"
id=
"cameraMinusZ"
class=
"paddingBottom btn btn-sm btn-default"
>
Back
</a>
<a
href=
"#"
id=
"cameraX"
class=
"paddingBottom btn btn-sm btn-default"
>
Right
</a>
<a
href=
"#"
id=
"cameraMinusX"
class=
"paddingBottom btn btn-sm btn-default"
>
Left
</a><br/>
<a
href=
"#"
id=
"cameraY"
class=
"btn btn-sm btn-default"
>
Top
</a>
<a
href=
"#"
id=
"cameraMinusY"
class=
"btn btn-sm btn-default"
>
Bottom
</a>
<a
href=
"#"
id=
"cameraOrtho"
class=
"btn btn-sm btn-default"
>
Ortho
</a>
</div>
<div
class=
"extraSpace"
></div>
</div>
</div>
...
...
@@ -960,7 +962,7 @@
</button>
<b>
Export STL
</b><br/><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/>
Scale:
<input
value=
""
placeholder=
""
class=
"
float
exportScale form-control"
type=
"text"
><br/><br/>
Dimensions:
<b><span
class=
"exportDimensions"
></span></b><br/>
<span
class=
"smallTxt"
>
(the STL file format is unitless, but typically assumed to be either in inches or mm)
</span><br/>
<label
class=
"bigLabel checkbox"
for=
"doublesidedSTL"
>
...
...
@@ -983,7 +985,7 @@
</button>
<b>
Export OBJ
</b><br/><br/>
Filename:
<input
id=
"objFilename"
value=
""
placeholder=
""
class=
"bigInput text form-control"
type=
"text"
>
.stl
<br/><br/>
Scale:
<input
value=
""
placeholder=
""
class=
"exportScale form-control"
type=
"text"
><br/><br/>
Scale:
<input
value=
""
placeholder=
""
class=
"
float
exportScale form-control"
type=
"text"
><br/><br/>
Dimensions:
<b><span
class=
"exportDimensions"
></span></b><br/>
<span
class=
"smallTxt"
>
(the OBJ file format is unitless, but typically assumed to be either in inches or mm)
</span><br/>
<label
class=
"bigLabel checkbox"
for=
"doublesidedOBJ"
>
...
...
@@ -1007,7 +1009,7 @@
<b>
Export FOLD
</b><br/><br/>
Filename:
<input
id=
"foldFilename"
value=
""
placeholder=
""
class=
"bigInput text form-control"
type=
"text"
>
.fold
<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"
>
Scale:
<input
value=
""
placeholder=
""
class=
"
float
exportScale form-control"
type=
"text"
>
Units:
<div
class=
"btn-group"
>
<button
data-toggle=
"dropdown"
class=
"btn btn-default dropdown-toggle"
type=
"button"
><span
class=
"unitsDisplay"
></span>
<span
class=
"caret"
></span></button>
...
...
@@ -1186,5 +1188,20 @@
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<div
class=
"modal fade"
id=
"changeRotationSpeedModal"
tabindex=
"-1"
role=
"dialog"
>
<div
class=
"modal-dialog sm"
>
<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>
ROTATION SPEED
</b><br/><br/>
Speed :
<input
id=
"rotationSpeed"
value=
""
placeholder=
""
class=
"float form-control"
type=
"text"
>
<span
class=
"smallTxt"
>
( radians per frame )
</span>
</p>
</div>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
</body>
</html>
\ No newline at end of file
js/controls.js
View file @
ec4f1687
...
...
@@ -112,6 +112,30 @@ function initControls(globals){
saveFOLD
();
});
setLink
(
"
#rotateX
"
,
function
(){
globals
.
threeView
.
resetModel
();
globals
.
rotateModel
=
"
x
"
;
});
setLink
(
"
#rotateY
"
,
function
(){
globals
.
threeView
.
resetModel
();
globals
.
rotateModel
=
"
y
"
;
});
setLink
(
"
#rotateZ
"
,
function
(){
globals
.
threeView
.
resetModel
();
globals
.
rotateModel
=
"
z
"
;
});
setLink
(
"
#stopRotation
"
,
function
(){
globals
.
rotateModel
=
null
;
globals
.
threeView
.
resetModel
();
});
setLink
(
"
#changeRotationSpeed
"
,
function
(){
$
(
"
#changeRotationSpeedModal
"
).
modal
(
"
show
"
);
});
setInput
(
"
#rotationSpeed
"
,
globals
.
rotationSpeed
,
function
(
val
){
globals
.
rotationSpeed
=
val
;
},
0
);
setLink
(
"
#navPattern
"
,
function
(){
if
(
globals
.
noCreasePatternAvailable
()){
globals
.
warn
(
"
No crease pattern available for FOLD format.
"
);
...
...
js/globals.js
View file @
ec4f1687
...
...
@@ -77,8 +77,10 @@ function initGlobals(){
userInteractionEnabled
:
false
,
vrEnabled
:
false
,
numSteps
:
100
numSteps
:
100
,
rotateModel
:
null
,
rotationSpeed
:
0.01
};
function
setCreasePercent
(
percent
){
...
...
js/saveSTL.js
View file @
ec4f1687
...
...
@@ -25,8 +25,29 @@ function makeSaveGEO(doublesided){
var
lastFaceIndex
=
0
;
for
(
var
j
=
0
;
j
<
geo
.
faces
.
length
;
j
++
){
face
=
geo
.
faces
[
j
];
if
(
face
.
a
==
i
||
face
.
b
==
i
||
face
.
c
==
i
)
{
vertexNormal
.
add
(
face
.
normal
);
if
(
face
.
a
==
i
)
{
var
a
=
geo
.
vertices
[
face
.
a
];
var
b
=
geo
.
vertices
[
face
.
b
];
var
c
=
geo
.
vertices
[
face
.
c
];
var
weight
=
Math
.
abs
(
Math
.
acos
(
(
b
.
clone
().
sub
(
a
)).
normalize
().
dot
(
(
c
.
clone
().
sub
(
a
)).
normalize
()
)
));
console
.
log
(
weight
);
vertexNormal
.
add
(
face
.
normal
.
clone
().
multiplyScalar
(
weight
));
lastFaceIndex
=
j
;
}
else
if
(
face
.
b
==
i
)
{
var
a
=
geo
.
vertices
[
face
.
a
];
var
b
=
geo
.
vertices
[
face
.
b
];
var
c
=
geo
.
vertices
[
face
.
c
];
var
weight
=
Math
.
abs
(
Math
.
acos
(
(
c
.
clone
().
sub
(
b
)).
normalize
().
dot
(
(
a
.
clone
().
sub
(
b
)).
normalize
()
)
));
console
.
log
(
weight
);
vertexNormal
.
add
(
face
.
normal
.
clone
().
multiplyScalar
(
weight
));
lastFaceIndex
=
j
;
}
else
if
(
face
.
c
==
i
)
{
var
a
=
geo
.
vertices
[
face
.
a
];
var
b
=
geo
.
vertices
[
face
.
b
];
var
c
=
geo
.
vertices
[
face
.
c
];
var
weight
=
Math
.
abs
(
Math
.
acos
(
(
b
.
clone
().
sub
(
c
)).
normalize
().
dot
(
(
a
.
clone
().
sub
(
c
)).
normalize
()
)
));
console
.
log
(
weight
);
vertexNormal
.
add
(
face
.
normal
.
clone
().
multiplyScalar
(
weight
));
lastFaceIndex
=
j
;
}
// if (vertexNormal !== null) break;
...
...
@@ -35,24 +56,24 @@ function makeSaveGEO(doublesided){
// geo.vertices.push(new THREE.Vector3());
// continue;
// }
//filter out duplicate normals
vertexNormal
.
normalize
();
console
.
log
(
vertexNormal
);
var
offset
=
vertexNormal
.
clone
().
multiplyScalar
(
globals
.
thickenOffset
/
(
2
*
vertexNormal
.
clone
().
dot
(
geo
.
faces
[
lastFaceIndex
].
normal
)));
geo
.
vertices
.
push
(
geo
.
vertices
[
i
].
clone
().
sub
(
offset
));
//
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
);
}
//
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
();
...
...
js/threeView.js
View file @
ec4f1687
...
...
@@ -104,6 +104,11 @@ function initThreeView(globals) {
}
function
_loop
(
callback
){
if
(
globals
.
rotateModel
!==
null
){
if
(
globals
.
rotateModel
==
"
x
"
)
modelWrapper
.
rotateX
(
globals
.
rotationSpeed
);
if
(
globals
.
rotateModel
==
"
y
"
)
modelWrapper
.
rotateY
(
globals
.
rotationSpeed
);
if
(
globals
.
rotateModel
==
"
z
"
)
modelWrapper
.
rotateZ
(
globals
.
rotationSpeed
);
}
if
(
globals
.
needsSync
){
globals
.
model
.
sync
();
}
...
...
@@ -182,6 +187,10 @@ function initThreeView(globals) {
document
.
body
.
removeChild
(
downloadLink
);
}
function
resetModel
(){
modelWrapper
.
rotation
.
set
(
0
,
0
,
0
);
}
return
{
sceneAddModel
:
sceneAddModel
,
...
...
@@ -203,6 +212,8 @@ function initThreeView(globals) {
setCameraX
:
setCameraX
,
setCameraY
:
setCameraY
,
setCameraZ
:
setCameraZ
,
setCameraOrtho
:
setCameraOrtho
setCameraOrtho
:
setCameraOrtho
,
resetModel
:
resetModel
//reset model orientation
}
}
\ 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