phetsims / wave-on-a-string

"Wave on a String" is an educational simulation in HTML5, by PhET Interactive Simulations.
http://phet.colorado.edu/en/simulation/wave-on-a-string
GNU General Public License v3.0
7 stars 8 forks source link

Sim speed shouldn't be affected by framerate #8

Closed jonathanolson closed 10 years ago

jonathanolson commented 11 years ago

Right now, the speed of waves is affected by the framerate. This appears to at least be due to only allowing one step per frame, but I haven't investigated thoroughly.

As an example, right now, the faster the computer, the longer the visual wavelength in oscillation mode. Below is a screenshot where I caused the sim to run slowly (just resize the window to cause it to run slowly) for what appears to be the middle section of the string, and the wavelength is significantly less there.

woas-string-speed-variable

Additionally, I ran some timing tests to see how accurate the timer was. I created a single pulse with no damping, and counted the time (according to the sim timer) it took to do 10 forward-and-back counts.

Firefox: 00:45:35 Chrome (normal): 00:39:83 Chrome (with setInterval( function() { sleep( 16 ); }, 16 ) ): 00:31:54.

Thus the timer can be affected heavily (in this case by 50%) by the framerate.

Resizing the window (and other causes of slowness) shouldn't cause the bunching of the wave, and browser/framerate variations shouldn't modify how long it takes for an undamped wave (at the highest tension) takes to travel a certain distance according to the in-sim timer.

jonathanolson commented 10 years ago

This shouldn't be an issue now that we are using the interpolated model, and should be fixed.

jonathanolson commented 10 years ago

To clarify the above comment: it is broken, and should be fixed.