@threlte/theatre
Version:
Threlte Components for Theatre, an animation library with a professional motion design toolset
15 lines (14 loc) • 679 B
JavaScript
import { resolvePropertyPath } from '@threlte/core';
import { getDefaultTransformer } from '../../transfomers/getDefaultTransformer';
import { isComplexProp } from './isComplexProp';
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
};
};