UNPKG

@threlte/theatre

Version:

Threlte Components for Theatre, an animation library with a professional motion design toolset

15 lines (14 loc) 685 B
import { resolvePropertyPath } from '@threlte/core'; import { getDefaultTransformer } from '../../transfomers/getDefaultTransformer.js'; import { isComplexProp } from './isComplexProp.js'; export const getInitialValue = (propertyPath, propertyValue, targetObject) => { const { target, key } = resolvePropertyPath(targetObject, propertyPath); const rawValue = target[key]; const customTransformer = isComplexProp(propertyValue) ? propertyValue.transformer : undefined; const transformer = customTransformer ?? getDefaultTransformer(target, key, propertyPath); const value = transformer?.transform(rawValue); return { value, transformer }; };