mirror of
https://github.com/overte-org/overte.git
synced 2025-05-09 15:19:02 +02:00
37 lines
No EOL
1.4 KiB
JavaScript
37 lines
No EOL
1.4 KiB
JavaScript
/*
|
|
|
|
Easing Animation Module
|
|
easing.js
|
|
Created by Milad Nazeri on 2019-05-02
|
|
Copyright 2019 High Fidelity, Inc.
|
|
|
|
Distributed under the Apache License, Version 2.0.
|
|
See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
|
|
*/
|
|
|
|
|
|
// https://gist.github.com/gre/1650294
|
|
var EasingFunctions = {
|
|
easeInOutQuad: function (t) { return t<.5 ? 2*t*t : -1+(4-2*t)*t },
|
|
// accelerating from zero velocity
|
|
easeInCubic: function (t) { return t*t*t },
|
|
// decelerating to zero velocity
|
|
easeOutCubic: function (t) { return (--t)*t*t+1 },
|
|
// acceleration until halfway, then deceleration
|
|
easeInOutCubic: function (t) { return t<.5 ? 4*t*t*t : (t-1)*(2*t-2)*(2*t-2)+1 },
|
|
// accelerating from zero velocity
|
|
easeInQuart: function (t) { return t*t*t*t },
|
|
// decelerating to zero velocity
|
|
easeOutQuart: function (t) { return 1-(--t)*t*t*t },
|
|
// acceleration until halfway, then deceleration
|
|
easeInOutQuart: function (t) { return t<.5 ? 8*t*t*t*t : 1-8*(--t)*t*t*t },
|
|
// accelerating from zero velocity
|
|
easeInQuint: function (t) { return t*t*t*t*t },
|
|
// decelerating to zero velocity
|
|
easeOutQuint: function (t) { return 1+(--t)*t*t*t*t },
|
|
// acceleration until halfway, then deceleration
|
|
easeInOutQuint: function (t) { return t<.5 ? 16*t*t*t*t*t : 1+16*(--t)*t*t*t*t }
|
|
};
|
|
|
|
module.exports = EasingFunctions; |