Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
computergrafik-03
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Temple
computergrafik-03
Commits
ed12702e
Unverified
Commit
ed12702e
authored
3 years ago
by
Jamie Temple
Browse files
Options
Downloads
Patches
Plain Diff
refactor: naming
parent
e7ec1c65
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
images/simulation.png
+0
-0
0 additions, 0 deletions
images/simulation.png
src/03-simulation/Simulation.ts
+1
-1
1 addition, 1 deletion
src/03-simulation/Simulation.ts
src/03-simulation/SimulationData.ts
+12
-13
12 additions, 13 deletions
src/03-simulation/SimulationData.ts
with
13 additions
and
14 deletions
images/simulation.png
+
0
−
0
View replaced file @
e7ec1c65
View file @
ed12702e
163 KiB
|
W:
|
H:
163 KiB
|
W:
|
H:
2-up
Swipe
Onion skin
This diff is collapsed.
Click to expand it.
src/03-simulation/Simulation.ts
+
1
−
1
View file @
ed12702e
...
...
@@ -22,7 +22,7 @@ export class Simulation implements PipelineObserver {
Simulation
.
current
=
p
;
let
x
=
[
p
.
position
.
x
,
p
.
position
.
y
,
p
.
position
.
z
,
p
.
velocity
.
x
,
p
.
velocity
.
y
,
p
.
velocity
.
z
];
x
=
SimulationData
.
INTEGRATORS
[
SimulationData
.
integrat
orType
].
step
(
x
,
h
,
Simulation
.
derivation
);
x
=
SimulationData
.
INTEGRATORS
[
SimulationData
.
integrat
ionMethod
].
step
(
x
,
h
,
Simulation
.
derivation
);
p
.
setState
(
x
[
0
],
x
[
1
],
x
[
2
],
x
[
3
],
x
[
4
],
x
[
5
]);
}
});
...
...
This diff is collapsed.
Click to expand it.
src/03-simulation/SimulationData.ts
+
12
−
13
View file @
ed12702e
...
...
@@ -6,9 +6,10 @@ import { Particle } from './physics/particle';
import
{
EulerIntegrator
,
Integrator
,
MidpointIntegrator
,
RungeKuttaIntegrator
}
from
'
./physics/Integrators
'
;
document
.
addEventListener
(
'
keydown
'
,
(
event
:
KeyboardEvent
)
=>
{
if
(
event
.
key
===
'
e
'
)
{
SimulationData
.
switchParticlePhysics
();
}
else
if
(
event
.
key
===
'
w
'
)
{
SimulationData
.
paused
=
!
SimulationData
.
paused
;
}
});
...
...
@@ -16,6 +17,8 @@ class SimulationData implements PipelineGUI, PipelineRenderable {
public
static
container
:
THREE
.
Group
=
new
THREE
.
Group
();
public
static
paused
:
boolean
=
false
;
// cloth settings
public
static
readonly
MAX_TOTAL_MASS
=
10
;
public
static
readonly
MIN_TOTAL_MASS
=
0.1
;
...
...
@@ -59,12 +62,9 @@ class SimulationData implements PipelineGUI, PipelineRenderable {
new
RungeKuttaIntegrator
]
public
static
integratorType
:
number
=
2
;
public
static
stepSize
:
number
=
0
;
public
static
setEuler
=
()
=>
{
SimulationData
.
integratorType
=
0
;
}
public
static
setMidpoint
=
()
=>
{
SimulationData
.
integratorType
=
1
;
}
public
static
setRungeKutta
=
()
=>
{
SimulationData
.
integratorType
=
2
;
}
public
static
integrationMethod
:
number
=
2
;
public
static
stepSizeMethod
:
number
=
0
;
public
static
errorMax
:
number
=
0
;
public
static
resetExternalForce
():
void
{
SimulationData
.
externalForce
.
x
=
0
;
...
...
@@ -73,6 +73,7 @@ class SimulationData implements PipelineGUI, PipelineRenderable {
}
public
static
generateTextile
():
void
{
// 1. reset pList
delete
SimulationData
.
pList
;
SimulationData
.
pList
=
new
Array
<
Array
<
Particle
>>
();
...
...
@@ -344,9 +345,8 @@ class SimulationData implements PipelineGUI, PipelineRenderable {
}
gui
(
gui
:
GUI
):
void
{
const
general
=
gui
.
addFolder
(
'
General
'
);
general
.
add
(
SimulationData
,
'
paused
'
).
name
(
"
Pause Simulation
"
).
listen
();
general
.
add
(
SimulationData
,
'
totalMass
'
,
SimulationData
.
MIN_TOTAL_MASS
,
SimulationData
.
MAX_TOTAL_MASS
)
.
step
(
0.1
).
name
(
'
Total Mass
'
).
onChange
(
SimulationData
.
changedParticleSize
);
general
.
add
(
SimulationData
,
'
width
'
,
SimulationData
.
MIN_WIDTH
,
SimulationData
.
MAX_WIDTH
)
...
...
@@ -357,11 +357,10 @@ class SimulationData implements PipelineGUI, PipelineRenderable {
.
step
(
1
).
name
(
'
Resolution
'
).
onChange
(
SimulationData
.
generateTextile
);
general
.
open
();
const
integration
=
gui
.
addFolder
(
'
Integrator
'
);
integration
.
add
(
SimulationData
,
'
setEuler
'
).
name
(
'
Euler
'
).
onChange
(()
=>
{
console
.
log
(
SimulationData
.
integratorType
)}
);
integration
.
add
(
SimulationData
,
'
s
etMidpoint
'
).
name
(
'
Midpoint
'
).
onChange
(()
=>
{
console
.
log
(
SimulationData
.
integratorType
)}
);
integration
.
add
(
SimulationData
,
'
setRungeKutta
'
).
name
(
'
Runge Kutta (4th order)
'
).
onChange
(()
=>
{
console
.
log
(
SimulationData
.
integratorType
)}
);
integration
.
add
(
SimulationData
,
'
integrationMethod
'
,
{
'
Euler
'
:
0
,
'
Midpoint
'
:
1
,
'
Runge-Kutta
'
:
2
}).
name
(
'
Method
'
);
integration
.
add
(
SimulationData
,
'
s
tepSizeMethod
'
,
{
'
Fixed
'
:
0
,
'
Adaptive
'
:
1
}).
name
(
'
Step Size
'
);
integration
.
add
(
SimulationData
,
'
errorMax
'
,
-
30
,
0
,
1
).
name
(
'
Error Max
'
);
integration
.
open
();
const
extForce
=
general
.
addFolder
(
'
External Force
'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment