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
f8d44b53
Commit
f8d44b53
authored
May 04, 2017
by
amandaghassaei
Browse files
start stop reset
parent
eed5b668
Changes
8
Hide whitespace changes
Inline
Side-by-side
css/main.css
View file @
f8d44b53
...
...
@@ -309,3 +309,13 @@ svg{
#aboutStiffness
{
line-height
:
28px
;
}
#start
,
#stepForwardOptions
{
display
:
none
;
}
#reset
{
margin-left
:
20px
;
}
#stepForward
{
margin-left
:
13px
;
}
index.html
View file @
f8d44b53
...
...
@@ -460,8 +460,18 @@
<div
class=
"indent"
>
<label>
Average node error:
<span
id=
"globalError"
></span></label>
<a
class=
"about floatRight"
href=
"#"
id=
"aboutError"
><span
class=
"fui-question-circle"
></span></a>
</div><br/>
<b>
Animation Settings:
</b><br/>
<span
class=
"floatRight"
>
Δ
t =
<span
id=
"deltaT"
></span>
seconds
</span><br/><br/>
<a
href=
"#"
id=
"reset"
class=
"btn btn-lg btn-default"
>
Reset
</a>
<a
href=
"#"
id=
"start"
class=
"btn btn-lg btn-success"
>
Start Simulation
</a>
<a
href=
"#"
id=
"pause"
class=
"btn btn-lg btn-warning"
>
Pause Simulation
</a>
<br/><br/>
<div
id=
"stepForwardOptions"
class=
"floatRight"
>
Num Steps:
<input
id=
"numSteps"
value=
"100"
placeholder=
""
class=
"form-control"
type=
"text"
>
<a
href=
"#"
id=
"stepForward"
class=
"btn btn-lg btn-default"
>
Step Forward
</a>
</div>
<br/><br/>
<div
class=
"extraSpace"
></div>
</div>
<div
id=
"svgViewer"
></div>
...
...
js/controls.js
View file @
f8d44b53
...
...
@@ -409,6 +409,32 @@ function initControls(globals){
$
(
"
#aboutAxialStrainModal
"
).
modal
(
"
show
"
);
});
setLink
(
"
#start
"
,
function
(){
$
(
"
#pause
"
).
show
();
$
(
"
#reset
"
).
show
();
$
(
"
#start
"
).
hide
();
$
(
"
#stepForwardOptions
"
).
hide
();
globals
.
model
.
resume
();
});
setLink
(
"
#pause
"
,
function
(){
$
(
"
#start
"
).
show
();
$
(
"
#stepForwardOptions
"
).
show
();
$
(
"
#pause
"
).
hide
();
globals
.
model
.
pause
();
});
setLink
(
"
#reset
"
,
function
(){
if
(
!
globals
.
threeView
.
running
())
$
(
"
#reset
"
).
hide
();
globals
.
model
.
reset
();
});
setLink
(
"
#stepForward
"
,
function
(){
var
numSteps
=
$
(
"
#numSteps
"
).
val
();
numSteps
=
parseInt
(
numSteps
);
if
(
isNaN
(
numSteps
))
return
;
if
(
numSteps
<=
0
)
return
;
$
(
"
#numSteps
"
).
val
(
numSteps
);
globals
.
model
.
step
(
numSteps
);
});
setInput
(
"
#strainClip
"
,
globals
.
strainClip
,
function
(
val
){
globals
.
strainClip
=
val
;
},
0.0001
,
100
);
...
...
js/dynamic/dynamicSolver.js
View file @
f8d44b53
...
...
@@ -61,6 +61,7 @@ function initDynamicSolver(globals){
globals
.
gpuMath
.
step
(
"
zeroTexture
"
,
[],
"
u_lastPosition
"
);
globals
.
gpuMath
.
step
(
"
zeroTexture
"
,
[],
"
u_velocity
"
);
globals
.
gpuMath
.
step
(
"
zeroTexture
"
,
[],
"
u_lastVelocity
"
);
render
();
//todo zero thetas
// for (var i=0;i<creases.length;i++){
// lastTheta[i*4] = 0;
...
...
@@ -68,10 +69,9 @@ function initDynamicSolver(globals){
// }
}
function
solve
(){
function
solve
(
_numSteps
){
if
(
globals
.
shouldSyncWithModel
){
syncNodesAndEdges
();
// reset();
globals
.
shouldSyncWithModel
=
false
;
}
else
{
if
(
globals
.
forceHasChanged
)
{
...
...
@@ -94,17 +94,14 @@ function initDynamicSolver(globals){
updateMaterials
();
globals
.
materialHasChanged
=
false
;
}
if
(
globals
.
shouldResetDynamicSim
)
{
reset
();
globals
.
shouldResetDynamicSim
=
false
;
}
if
(
globals
.
shouldChangeCreasePercent
)
{
setCreasePercent
(
globals
.
creasePercent
);
globals
.
shouldChangeCreasePercent
=
false
;
}
}
for
(
var
j
=
0
;
j
<
steps
;
j
++
){
if
(
_numSteps
==
undefined
)
_numSteps
=
steps
;
for
(
var
j
=
0
;
j
<
_numSteps
;
j
++
){
solveStep
();
}
render
();
...
...
@@ -200,6 +197,7 @@ function initDynamicSolver(globals){
function
setSolveParams
(){
var
dt
=
calcDt
()
/
10
;
//todo factor of ten?
$
(
"
#deltaT
"
).
html
(
dt
);
var
numSteps
=
0.5
/
dt
;
globals
.
gpuMath
.
setProgram
(
"
thetaCalc
"
);
globals
.
gpuMath
.
setUniformForProgram
(
"
thetaCalc
"
,
"
u_dt
"
,
dt
,
"
1f
"
);
...
...
@@ -494,6 +492,7 @@ function initDynamicSolver(globals){
return
{
syncNodesAndEdges
:
syncNodesAndEdges
,
updateFixed
:
updateFixed
,
solve
:
solve
solve
:
solve
,
reset
:
reset
}
}
\ No newline at end of file
js/globals.js
View file @
f8d44b53
...
...
@@ -52,7 +52,8 @@ function initGlobals(){
//save stl settings
filename
:
null
,
extension
:
null
,
doublesidedSTL
:
false
doublesidedSTL
:
false
,
scale
:
1
};
...
...
js/model.js
View file @
f8d44b53
...
...
@@ -126,6 +126,32 @@ function initModel(globals){
startSolver
();
}
function
reset
(){
if
(
globals
.
simType
==
"
dynamic
"
){
globals
.
dynamicSolver
.
reset
();
}
else
{
globals
.
staticSolver
.
reset
();
}
setGeoUpdates
();
globals
.
threeView
.
render
();
}
function
step
(
numSteps
){
if
(
globals
.
simType
==
"
dynamic
"
){
globals
.
dynamicSolver
.
solve
(
numSteps
);
}
else
{
globals
.
staticSolver
.
step
(
numSteps
);
}
setGeoUpdates
();
globals
.
threeView
.
render
();
}
function
setGeoUpdates
(){
geometry
.
attributes
.
position
.
needsUpdate
=
true
;
if
(
globals
.
colorMode
==
"
axialStrain
"
)
geometry
.
attributes
.
color
.
needsUpdate
=
true
;
geometry
.
computeVertexNormals
();
}
var
inited
=
false
;
startSolver
();
...
...
@@ -138,9 +164,7 @@ function initModel(globals){
console
.
log
(
"
static
"
);
}
geometry
.
attributes
.
position
.
needsUpdate
=
true
;
if
(
globals
.
colorMode
==
"
axialStrain
"
)
geometry
.
attributes
.
color
.
needsUpdate
=
true
;
geometry
.
computeVertexNormals
();
// geometry.computeFlatVertexNormals();
setGeoUpdates
();
});
}
...
...
@@ -287,6 +311,8 @@ function initModel(globals){
return
{
pause
:
pause
,
resume
:
resume
,
reset
:
reset
,
step
:
step
,
getNodes
:
getNodes
,
getEdges
:
getEdges
,
getFaces
:
getFaces
,
...
...
js/pattern.js
View file @
f8d44b53
...
...
@@ -174,7 +174,6 @@ function initPattern(globals){
}
function
getFacesAndVerticesForEdges
(
faces
,
allEdges
){
//todo merge this
var
allCreaseParams
=
[];
//face1Ind, vertInd, face2Ind, ver2Ind, edgeInd, angle
for
(
var
i
=
outlines
.
length
;
i
<
allEdges
.
length
;
i
++
){
if
(
i
>=
outlines
.
length
+
mountains
.
length
+
valleys
.
length
&&
...
...
js/threeView.js
View file @
f8d44b53
...
...
@@ -61,6 +61,7 @@ function initThreeView(globals) {
controls
.
noPan
=
true
;
controls
.
staticMoving
=
true
;
controls
.
dynamicDampingFactor
=
0.3
;
controls
.
addEventListener
(
"
change
"
,
render
);
var
renderPass
=
new
THREE
.
RenderPass
(
scene
,
camera
);
...
...
@@ -90,9 +91,9 @@ function initThreeView(globals) {
}
function
render
()
{
//
if (!animationRunning) {
//
_render();
//
}
if
(
!
animationRunning
)
{
_render
();
}
}
function
startAnimation
(
callback
){
...
...
@@ -113,6 +114,10 @@ function initThreeView(globals) {
if
(
animationRunning
)
pauseFlag
=
true
;
}
function
running
(){
return
animationRunning
;
}
function
_render
(){
if
(
globals
.
ambientOcclusion
)
{
// Render depth into depthRenderTarget
...
...
@@ -186,6 +191,7 @@ function initThreeView(globals) {
pauseAnimation
:
pauseAnimation
,
enableControls
:
enableControls
,
scene
:
scene
,
camera
:
camera
camera
:
camera
,
running
:
running
}
}
\ No newline at end of file
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