This reverts commit 5bd224ae86
.
This commit is contained in:
parent
5bd224ae86
commit
ef96fa1974
5 changed files with 8 additions and 38 deletions
|
@ -1,11 +1,10 @@
|
||||||
import {editable as e, RefreshSnapshot, SheetProvider} from '@theatre/r3f'
|
import {editable as e, RefreshSnapshot, SheetProvider} from '@theatre/r3f'
|
||||||
import {Stars} from '@react-three/drei'
|
import { Stars} from '@react-three/drei'
|
||||||
import {getProject} from '@theatre/core'
|
import {getProject} from '@theatre/core'
|
||||||
import React, {Suspense, useMemo, useState} from 'react'
|
import React, {Suspense, useState} from 'react'
|
||||||
import {Canvas} from '@react-three/fiber'
|
import {Canvas} from '@react-three/fiber'
|
||||||
import {useGLTF, PerspectiveCamera} from '@react-three/drei'
|
import {useGLTF, PerspectiveCamera} from '@react-three/drei'
|
||||||
import sceneGLB from './scene.glb'
|
import sceneGLB from './scene.glb'
|
||||||
import {Color} from 'three'
|
|
||||||
|
|
||||||
document.body.style.backgroundColor = '#171717'
|
document.body.style.backgroundColor = '#171717'
|
||||||
|
|
||||||
|
@ -56,13 +55,7 @@ function App() {
|
||||||
>
|
>
|
||||||
<Canvas dpr={[1.5, 2]} linear shadows frameloop="demand">
|
<Canvas dpr={[1.5, 2]} linear shadows frameloop="demand">
|
||||||
<SheetProvider getSheet={() => getProject('Space').sheet('Scene')}>
|
<SheetProvider getSheet={() => getProject('Space').sheet('Scene')}>
|
||||||
<e.fog
|
<fog attach="fog" args={[bg, 16, 30]} />
|
||||||
attach="fog"
|
|
||||||
color={useMemo(() => new Color(bg), [bg])}
|
|
||||||
near={16}
|
|
||||||
far={30}
|
|
||||||
uniqueName="Fog"
|
|
||||||
/>
|
|
||||||
<color attach="background" args={[bg]} />
|
<color attach="background" args={[bg]} />
|
||||||
<ambientLight intensity={0.75} />
|
<ambientLight intensity={0.75} />
|
||||||
<EditableCamera
|
<EditableCamera
|
||||||
|
|
|
@ -59,15 +59,11 @@ const EditableProxy: VFC<EditableProxyProps> = ({
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
const scene = useThree((state) => state.scene)
|
const scene = useThree((state) => state.scene)
|
||||||
const helper = useMemo<Helper | undefined>(
|
const helper = useMemo<Helper>(
|
||||||
() => editable.objectConfig.createHelper?.(object),
|
() => editable.objectConfig.createHelper(object),
|
||||||
[object],
|
[object],
|
||||||
)
|
)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (helper == undefined) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selected === uniqueName || hovered) {
|
if (selected === uniqueName || hovered) {
|
||||||
scene.add(helper)
|
scene.add(helper)
|
||||||
invalidate()
|
invalidate()
|
||||||
|
@ -79,10 +75,6 @@ const EditableProxy: VFC<EditableProxyProps> = ({
|
||||||
}
|
}
|
||||||
}, [selected, hovered, helper, scene])
|
}, [selected, hovered, helper, scene])
|
||||||
useFrame(() => {
|
useFrame(() => {
|
||||||
if (helper == undefined) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (helper.update) {
|
if (helper.update) {
|
||||||
helper.update()
|
helper.update()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import type {EditableFactoryConfig} from './editableFactoryConfigUtils'
|
import type {EditableFactoryConfig} from './editableFactoryConfigUtils'
|
||||||
import {
|
import {
|
||||||
createColorPropConfig,
|
|
||||||
createNumberPropConfig,
|
createNumberPropConfig,
|
||||||
createVector,
|
createVector,
|
||||||
createVectorPropConfig,
|
createVectorPropConfig,
|
||||||
|
@ -101,15 +100,6 @@ const defaultEditableFactoryConfig = {
|
||||||
line: baseObjectConfig,
|
line: baseObjectConfig,
|
||||||
lineLoop: baseObjectConfig,
|
lineLoop: baseObjectConfig,
|
||||||
lineSegments: baseObjectConfig,
|
lineSegments: baseObjectConfig,
|
||||||
fog: {
|
|
||||||
props: {
|
|
||||||
color: createColorPropConfig('color'),
|
|
||||||
near: createNumberPropConfig('near', 1, {nudgeMultiplier: 0.1}),
|
|
||||||
far: createNumberPropConfig('far', 1000, {nudgeMultiplier: 0.1}),
|
|
||||||
},
|
|
||||||
useTransformControls: false,
|
|
||||||
icon: 'cloud' as const,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert that the config is indeed of EditableFactoryConfig without actually
|
// Assert that the config is indeed of EditableFactoryConfig without actually
|
||||||
|
|
|
@ -17,7 +17,7 @@ type Meta<T> = {
|
||||||
updateObject?: (object: T) => void
|
updateObject?: (object: T) => void
|
||||||
icon: IconID
|
icon: IconID
|
||||||
dimensionless?: boolean
|
dimensionless?: boolean
|
||||||
createHelper?: (object: T) => Helper
|
createHelper: (object: T) => Helper
|
||||||
}
|
}
|
||||||
export type ObjectConfig<T> = {props: Props} & Meta<T>
|
export type ObjectConfig<T> = {props: Props} & Meta<T>
|
||||||
export type EditableFactoryConfig = Partial<
|
export type EditableFactoryConfig = Partial<
|
||||||
|
@ -79,7 +79,7 @@ export const createNumberPropConfig = (
|
||||||
{nudgeMultiplier = 0.01} = {},
|
{nudgeMultiplier = 0.01} = {},
|
||||||
): PropConfig<number> => ({
|
): PropConfig<number> => ({
|
||||||
parse: (props) => {
|
parse: (props) => {
|
||||||
return props[key] ?? defaultValue
|
return props[key] ?? defaultValue ?? 0
|
||||||
},
|
},
|
||||||
apply: (value, object) => {
|
apply: (value, object) => {
|
||||||
object[key] = value
|
object[key] = value
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
import {
|
import {BsCameraVideoFill, BsFillCollectionFill} from 'react-icons/bs'
|
||||||
BsCameraVideoFill,
|
|
||||||
BsFillCollectionFill,
|
|
||||||
BsCloudFill,
|
|
||||||
} from 'react-icons/bs'
|
|
||||||
import {GiCube, GiLightBulb, GiLightProjector} from 'react-icons/gi'
|
import {GiCube, GiLightBulb, GiLightProjector} from 'react-icons/gi'
|
||||||
import {BiSun} from 'react-icons/bi'
|
import {BiSun} from 'react-icons/bi'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
@ -14,7 +10,6 @@ const icons = {
|
||||||
spotLight: <GiLightProjector />,
|
spotLight: <GiLightProjector />,
|
||||||
sun: <BiSun />,
|
sun: <BiSun />,
|
||||||
camera: <BsCameraVideoFill />,
|
camera: <BsCameraVideoFill />,
|
||||||
cloud: <BsCloudFill />,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type IconID = keyof typeof icons
|
export type IconID = keyof typeof icons
|
||||||
|
|
Loading…
Reference in a new issue