Made the extension mechanism in r3f explicit

This commit is contained in:
Aria Minaei 2021-09-05 23:24:53 +02:00
parent 2605401e06
commit 7af470a053
4 changed files with 26 additions and 24 deletions

View file

@ -1,4 +1,9 @@
import {editable as e, RefreshSnapshot, Wrapper} from '@theatre/plugin-r3f' import {
editable as e,
RefreshSnapshot,
Wrapper,
extension,
} from '@theatre/plugin-r3f'
import {OrbitControls, Stars} from '@react-three/drei' import {OrbitControls, Stars} from '@react-three/drei'
import {getProject} from '@theatre/core' import {getProject} from '@theatre/core'
import React, {Suspense, useState} from 'react' import React, {Suspense, useState} from 'react'
@ -7,6 +12,7 @@ import {useGLTF} from '@react-three/drei'
import sceneGLB from './scene.glb' import sceneGLB from './scene.glb'
import studio from '@theatre/studio' import studio from '@theatre/studio'
studio.extend(extension)
studio.initialize() studio.initialize()
document.body.style.backgroundColor = '#171717' document.body.style.backgroundColor = '#171717'

View file

@ -0,0 +1,18 @@
import SnapshotEditor from './components/SnapshotEditor'
import type {IExtension} from '@theatre/studio'
import Toolbar from './components/Toolbar/Toolbar'
const r3fExtension: IExtension = {
id: '@theatre/plugin-r3f',
globalToolbar: {
component: Toolbar,
},
panes: [
{
class: 'snapshotEditor',
component: SnapshotEditor,
},
],
}
export default r3fExtension

View file

@ -1,4 +1,4 @@
import setupPlugin from './setupPlugin' export {default as extension} from './extension'
export {default as EditorHelper} from './components/EditorHelper' export {default as EditorHelper} from './components/EditorHelper'
export type {EditorHelperProps} from './components/EditorHelper' export type {EditorHelperProps} from './components/EditorHelper'
export {default as editable} from './components/editable' export {default as editable} from './components/editable'
@ -6,7 +6,3 @@ export type {EditableState, BindFunction} from './store'
export {default as Wrapper} from './Wrapper' export {default as Wrapper} from './Wrapper'
export {default as useRefreshSnapshot} from './components/useRefreshSnapshot' export {default as useRefreshSnapshot} from './components/useRefreshSnapshot'
export {default as RefreshSnapshot} from './components/RefreshSnapshot' export {default as RefreshSnapshot} from './components/RefreshSnapshot'
if (process.env.NODE_ENV === 'development') {
setupPlugin()
}

View file

@ -1,18 +0,0 @@
import SnapshotEditor from './components/SnapshotEditor'
import studio from '@theatre/studio'
import Toolbar from './components/Toolbar/Toolbar'
export default function setupPlugin() {
studio.extend({
id: '@theatre/plugin-r3f',
globalToolbar: {
component: Toolbar,
},
panes: [
{
class: 'snapshotEditor',
component: SnapshotEditor,
},
],
})
}