working on cutscenes
This commit is contained in:
1 parent
54cc118df7
commit
6349859e66
47 files changed
+6234
-21
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import type { EasingType } from '../types/cutscene';
|
||||
|
||||
export const EASING_OPTIONS: EasingType[] = [
|
||||
'Linear',
|
||||
'EaseInSine', 'EaseOutSine', 'EaseInOutSine',
|
||||
'EaseInQuad', 'EaseOutQuad', 'EaseInOutQuad',
|
||||
'EaseInCubic', 'EaseOutCubic', 'EaseInOutCubic',
|
||||
];
|
||||
|
||||
export function applyEasing(t: number, easing: EasingType): number {
|
||||
const pi = Math.PI;
|
||||
switch (easing) {
|
||||
case 'Linear': return t;
|
||||
case 'EaseInSine': return 1 - Math.cos((t * pi) / 2);
|
||||
case 'EaseOutSine': return Math.sin((t * pi) / 2);
|
||||
case 'EaseInOutSine': return -(Math.cos(pi * t) - 1) / 2;
|
||||
case 'EaseInQuad': return t * t;
|
||||
case 'EaseOutQuad': return 1 - (1 - t) * (1 - t);
|
||||
case 'EaseInOutQuad': return t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2;
|
||||
case 'EaseInCubic': return t * t * t;
|
||||
case 'EaseOutCubic': return 1 - Math.pow(1 - t, 3);
|
||||
case 'EaseInOutCubic':return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
|
||||
default: return t;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user