diff --git a/packages/r3f/src/components/editable.tsx b/packages/r3f/src/components/editable.tsx index bff0d5e..9072d6a 100644 --- a/packages/r3f/src/components/editable.tsx +++ b/packages/r3f/src/components/editable.tsx @@ -40,6 +40,8 @@ const editable = < type Props = Omit, 'visible'> & { uniqueName: string visible?: boolean | 'editor' + additionalProps?: $FixMe + objRef?: $FixMe } & (T extends 'primitive' ? { editableType: U @@ -48,7 +50,17 @@ const editable = < RefAttributes return forwardRef( - ({uniqueName, visible, editableType, ...props}: Props, ref) => { + ( + { + uniqueName, + visible, + editableType, + additionalProps, + objRef, + ...props + }: Props, + ref, + ) => { const objectRef = useRef() const sheet = useCurrentSheet() @@ -61,14 +73,19 @@ const editable = < useLayoutEffect(() => { if (!sheet) return - const sheetObject = sheet.object(uniqueName, baseSheetObjectType) + const sheetObject = sheet.object(uniqueName, { + ...baseSheetObjectType, + ...additionalProps, + }) allRegisteredObjects.add(sheetObject) setSheetObject(sheetObject) + if (objRef) objRef!.current = sheetObject + useEditorStore .getState() .setSheetObject(uniqueName, sheetObject as $FixMe) - }, [sheet, uniqueName]) + }, [sheet, uniqueName, additionalProps]) const transformDeps: string[] = []