mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-10-03 12:01:24 +08:00
Progress: Interpolation & Smoothing
This commit is contained in:
1 parent
e321a24909
commit
ad79f1a67a
2 files changed
+10
-10
No files matched your search
@@ -22,17 +22,13 @@ $(function () {
|
||||
}
|
||||
return state;
|
||||
},
|
||||
onInterpolation: function (currentState, previousState, targetState, amount, delta) {
|
||||
var interpolationState = {},
|
||||
smoothState = {};
|
||||
onInterpolation: function (currentState, previousState, targetState, amount) {
|
||||
var interpolationState = {};
|
||||
|
||||
interpolationState.x = (previousState.x + amount * (targetState.x - previousState.x));
|
||||
interpolationState.y = (previousState.y + amount * (targetState.y - previousState.y));
|
||||
|
||||
smoothState.x = (currentState.x + (20 * delta) * (interpolationState.x - currentState.x));
|
||||
smoothState.y = (currentState.y + (20 * delta) * (interpolationState.y - currentState.y));
|
||||
|
||||
return smoothState;
|
||||
return interpolationState;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user