Chore: Small refactor of r3f's store

This commit is contained in:
Aria Minaei 2021-06-29 15:39:47 +02:00
parent 94261107fb
commit d416da5a2f
3 changed files with 18 additions and 28 deletions

View file

@ -6,7 +6,7 @@ export {default as EditorHelper} from './components/EditorHelper'
export type {EditorHelperProps} from './components/EditorHelper'
export {default as editable} from './components/editable'
export {configure} from './store'
export {bindToCanvas} from './store'
export type {EditableState, BindFunction} from './store'
if (process.env.NODE_ENV === 'development') {

View file

@ -208,12 +208,6 @@ export type EditorStore = {
) => void
}
interface PersistedState {
canvases: {
[name: string]: EditableState
}
}
const config: StateCreator<EditorStore> = (set, get) => {
setTimeout(() => {
const existingHandler = DefaultLoadingManager.onProgress
@ -408,23 +402,21 @@ export type BindFunction = (options: {
sheet: ISheet
}) => (options: {gl: WebGLRenderer; scene: Scene}) => void
export const configure = ({} = {}): BindFunction => {
return ({
allowImplicitInstancing = false,
state,
editorCamera = {},
sheet,
}) => {
return ({gl, scene}) => {
const init = useEditorStore.getState().init
init(
scene,
gl,
allowImplicitInstancing,
{...{position: [20, 20, 20]}, ...editorCamera},
sheet,
state,
)
}
export const bindToCanvas: BindFunction = ({
allowImplicitInstancing = false,
state,
editorCamera = {},
sheet,
}) => {
return ({gl, scene}) => {
const init = useEditorStore.getState().init
init(
scene,
gl,
allowImplicitInstancing,
{...{position: [20, 20, 20]}, ...editorCamera},
sheet,
state,
)
}
}