mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-07-04 17:20:40 +08:00
Progress: Interpolation & Smoothing
This commit is contained in:
@@ -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