diff options
Diffstat (limited to 'apps/web/src/lib/animation/resolve.ts')
| -rw-r--r-- | apps/web/src/lib/animation/resolve.ts | 69 |
1 files changed, 28 insertions, 41 deletions
diff --git a/apps/web/src/lib/animation/resolve.ts b/apps/web/src/lib/animation/resolve.ts index 147be1b3..8709627d 100644 --- a/apps/web/src/lib/animation/resolve.ts +++ b/apps/web/src/lib/animation/resolve.ts @@ -1,8 +1,16 @@ -import type { AnimationPropertyPath, ElementAnimations } from "@/types/animation"; -import type { Transform } from "@/types/timeline"; -import { getColorValueAtTime, getNumberChannelValueAtTime } from "./interpolation"; +import type { + AnimationPropertyPath, + ElementAnimations, +} from "@/lib/animation/types"; +import type { Transform } from "@/lib/rendering"; +import { + getColorValueAtTime, + getNumberChannelValueAtTime, + getVectorChannelValueAtTime, +} from "./interpolation"; import { getColorChannelForPath } from "./color-channel"; import { getNumberChannelForPath } from "./number-channel"; +import { getVectorChannelForPath } from "./vector-channel"; export function getElementLocalTime({ timelineTime, @@ -36,31 +44,29 @@ export function resolveTransformAtTime({ }): Transform { const safeLocalTime = Math.max(0, localTime); return { - position: { - x: getNumberChannelValueAtTime({ - channel: getNumberChannelForPath({ - animations, - propertyPath: "transform.position.x", - }), - time: safeLocalTime, - fallbackValue: baseTransform.position.x, + position: getVectorChannelValueAtTime({ + channel: getVectorChannelForPath({ + animations, + propertyPath: "transform.position", }), - y: getNumberChannelValueAtTime({ - channel: getNumberChannelForPath({ - animations, - propertyPath: "transform.position.y", - }), - time: safeLocalTime, - fallbackValue: baseTransform.position.y, + time: safeLocalTime, + fallbackValue: baseTransform.position, + }), + scaleX: getNumberChannelValueAtTime({ + channel: getNumberChannelForPath({ + animations, + propertyPath: "transform.scaleX", }), - }, - scale: getNumberChannelValueAtTime({ + time: safeLocalTime, + fallbackValue: baseTransform.scaleX, + }), + scaleY: getNumberChannelValueAtTime({ channel: getNumberChannelForPath({ animations, - propertyPath: "transform.scale", + propertyPath: "transform.scaleY", }), time: safeLocalTime, - fallbackValue: baseTransform.scale, + fallbackValue: baseTransform.scaleY, }), rotate: getNumberChannelValueAtTime({ channel: getNumberChannelForPath({ @@ -127,22 +133,3 @@ export function resolveColorAtTime({ fallbackValue: baseColor, }); } - -export function resolveVolumeAtTime({ - baseVolume, - animations, - localTime, -}: { - baseVolume: number; - animations: ElementAnimations | undefined; - localTime: number; -}): number { - return getNumberChannelValueAtTime({ - channel: getNumberChannelForPath({ - animations, - propertyPath: "volume", - }), - time: Math.max(0, localTime), - fallbackValue: baseVolume, - }); -} |
