summaryrefslogtreecommitdiff
path: root/apps/web/src/lib/animation/effect-param-channel.ts
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2026-04-20 11:31:17 +0200
committerMaze Winther <mazewinther@gmail.com>2026-04-20 11:31:17 +0200
commit3e89d2998588f8e35c524e523ba2ee853f0f6475 (patch)
tree57221f96c1259b3b07e3ddf8c1adefc502b9d8eb /apps/web/src/lib/animation/effect-param-channel.ts
parent729d10592f4e802f91c555c309ff3ba4b119f843 (diff)
downloadopencut-3e89d2998588f8e35c524e523ba2ee853f0f6475.tar.gz
refactor: restructure files to their domains, new preview overlay system, and dep graph
Diffstat (limited to 'apps/web/src/lib/animation/effect-param-channel.ts')
-rw-r--r--apps/web/src/lib/animation/effect-param-channel.ts100
1 files changed, 0 insertions, 100 deletions
diff --git a/apps/web/src/lib/animation/effect-param-channel.ts b/apps/web/src/lib/animation/effect-param-channel.ts
deleted file mode 100644
index 3080e6ff..00000000
--- a/apps/web/src/lib/animation/effect-param-channel.ts
+++ /dev/null
@@ -1,100 +0,0 @@
-import type { ParamValues } from "@/lib/params";
-import type { Effect } from "@/lib/effects/types";
-import type {
- ElementAnimations,
- EffectParamPath,
-} from "@/lib/animation/types";
-import { removeElementKeyframe } from "./keyframes";
-import { resolveAnimationPathValueAtTime } from "./resolve";
-
-export const EFFECT_PARAM_PATH_PREFIX = "effects.";
-export const EFFECT_PARAM_PATH_SUFFIX = ".params.";
-
-export function buildEffectParamPath({
- effectId,
- paramKey,
-}: {
- effectId: string;
- paramKey: string;
-}): EffectParamPath {
- return `${EFFECT_PARAM_PATH_PREFIX}${effectId}${EFFECT_PARAM_PATH_SUFFIX}${paramKey}`;
-}
-
-export function isEffectParamPath(
- propertyPath: string,
-): propertyPath is EffectParamPath {
- return (
- propertyPath.startsWith(EFFECT_PARAM_PATH_PREFIX) &&
- propertyPath.includes(EFFECT_PARAM_PATH_SUFFIX)
- );
-}
-
-export function parseEffectParamPath({
- propertyPath,
-}: {
- propertyPath: string;
-}): { effectId: string; paramKey: string } | null {
- if (!isEffectParamPath(propertyPath)) {
- return null;
- }
-
- const withoutPrefix = propertyPath.slice(EFFECT_PARAM_PATH_PREFIX.length);
- const separatorIndex = withoutPrefix.indexOf(EFFECT_PARAM_PATH_SUFFIX);
- if (separatorIndex <= 0) {
- return null;
- }
-
- const effectId = withoutPrefix.slice(0, separatorIndex);
- const paramKey = withoutPrefix.slice(
- separatorIndex + EFFECT_PARAM_PATH_SUFFIX.length,
- );
- if (!effectId || !paramKey) {
- return null;
- }
-
- return { effectId, paramKey };
-}
-
-export function resolveEffectParamsAtTime({
- effect,
- animations,
- localTime,
-}: {
- effect: Effect;
- animations: ElementAnimations | undefined;
- localTime: number;
-}): ParamValues {
- const resolved: ParamValues = {};
-
- for (const [paramKey, staticValue] of Object.entries(effect.params)) {
- const path = buildEffectParamPath({ effectId: effect.id, paramKey });
- resolved[paramKey] = animations?.bindings[path]
- ? resolveAnimationPathValueAtTime({
- animations,
- propertyPath: path,
- localTime,
- fallbackValue: staticValue,
- })
- : staticValue;
- }
-
- return resolved;
-}
-
-export function removeEffectParamKeyframe({
- animations,
- effectId,
- paramKey,
- keyframeId,
-}: {
- animations: ElementAnimations | undefined;
- effectId: string;
- paramKey: string;
- keyframeId: string;
-}): ElementAnimations | undefined {
- return removeElementKeyframe({
- animations,
- propertyPath: buildEffectParamPath({ effectId, paramKey }),
- keyframeId,
- });
-}