Created
September 1, 2016 06:40
-
-
Save ikeryou/c92f7a5b604171c6011ea100a852573e to your computer and use it in GitHub Desktop.
バネ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var spring = 0.5; | |
var friction = 0.5; | |
var v = 0; | |
var t = 100; // 目標値 | |
var val = 0; // 現在値 | |
function update() { | |
v += (t - val) * spring; | |
val += (v *= friction); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment