import type {VFC} from 'react' import React, {useEffect, useRef, Suspense} from 'react' import {Canvas} from '@react-three/fiber' import {useEditorStore} from '../store' import {OrbitControls, Environment} from '@react-three/drei' import shallow from 'zustand/shallow' import root from 'react-shadow' import styles from '../bundle.css.txt' import UI from './UI' import ProxyManager from './ProxyManager' import {Button, Heading, Code, PortalManager, IdProvider} from './elements' import studio from '@theatre/studio' const EditorScene = () => { const orbitControlsRef = useRef() const [ selectedHdr, useHdrAsBackground, showGrid, showAxes, helpersRoot, setOrbitControlsRef, ] = useEditorStore( (state) => [ state.selectedHdr, state.useHdrAsBackground, state.showGrid, state.showAxes, state.helpersRoot, state.setOrbitControlsRef, ], shallow, ) useEffect(() => { setOrbitControlsRef(orbitControlsRef) }, [setOrbitControlsRef]) return ( <> {selectedHdr && ( )} {showGrid && } {showAxes && } {/* @ts-ignore */} ) } const Editor: VFC = () => { const [ sceneSnapshot, editorOpen, initialState, initialEditorCamera, setEditorOpen, createSnapshot, ] = useEditorStore( (state) => [ state.sceneSnapshot, state.editorOpen, state.initialState, state.initialEditorCamera, state.setEditorOpen, state.createSnapshot, ], shallow, ) return (
{sceneSnapshot ? ( <>
{ gl.setClearColor('white') }} shadowMap pixelRatio={window.devicePixelRatio} onPointerMissed={() => studio.__experimental_setSelection([]) } >
) : (
No canvas connected
Please use configure() and{' '} bind() to connect a canvas to React Three Editable.
{`import React from 'react'; import { Canvas } from '@react-three/fiber'; import { configure, editable as e } from 'react-three-editable'; const bind = configure({ localStorageNamespace: "MyProject" }); const MyComponent = () => ( );`}
For more details, please consult the{' '} documentation .
)}
{editorOpen || ( )}
) } export default Editor