Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Fadecandy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
scanlime
Fadecandy
Commits
635c0556
Commit
635c0556
authored
11 years ago
by
Micah Elizabeth Scott
Browse files
Options
Downloads
Patches
Plain Diff
Timestep cleanup
Also allows particle lifetime to be dynamic again.
parent
58d14801
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/node/midi_particles.coffee
+4
-10
4 additions, 10 deletions
examples/node/midi_particles.coffee
with
4 additions
and
10 deletions
examples/node/midi_particles.coffee
+
4
−
10
View file @
635c0556
...
...
@@ -44,14 +44,10 @@ wobbleAmount = 24.0
origin
=
[
0
,
0
,
0
]
# Physics
# numPhysicsTimesteps = 20 TODO: Re-enable when things become more complex
frameDelay
=
5
timestepSize
=
0.010
gain
=
0.1
# Derived values
particleDecay
=
timestepSize
/
particleLifetime
# Controlled by the Pitch Transpose Knob
spinAngle
=
0
...
...
@@ -187,16 +183,14 @@ draw = () ->
y
+=
wobbleAmp
*
Math
.
sin
lfoAngle
# Update velocity; use the XZ plane
p
.
velocity
[
0
]
+=
(
x
-
p
.
point
[
0
])
*
(
gain
)
# / numPhysicsTimesteps)
p
.
velocity
[
2
]
+=
(
y
-
p
.
point
[
2
])
*
(
gain
)
# / numPhysicsTimesteps)
p
.
velocity
[
0
]
+=
(
x
-
p
.
point
[
0
])
*
gain
p
.
velocity
[
2
]
+=
(
y
-
p
.
point
[
2
])
*
gain
# Fixed timestep physics
# TODO: Re-enable this when it's not just re-adding the delta.
# for i in [1 .. numPhysicsTimesteps]
p
.
point
[
0
]
+=
p
.
velocity
[
0
]
p
.
point
[
1
]
+=
p
.
velocity
[
1
]
p
.
point
[
2
]
+=
p
.
velocity
[
2
]
p
.
life
-=
particleDecay
p
.
life
-=
timestepSize
/
particleLifetime
# Filter out dead particles
particles
=
particles
.
filter
(
p
)
->
p
.
life
>
0
...
...
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