Revert "Merge pull request #161" (#162)

This reverts commit 5bd224ae86.
This commit is contained in:
Andrew Prifer 2022-05-15 22:00:54 +02:00 committed by GitHub
parent 5bd224ae86
commit ef96fa1974
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 38 deletions

View file

@ -59,15 +59,11 @@ const EditableProxy: VFC<EditableProxyProps> = ({
// Helpers
const scene = useThree((state) => state.scene)
const helper = useMemo<Helper | undefined>(
() => editable.objectConfig.createHelper?.(object),
const helper = useMemo<Helper>(
() => editable.objectConfig.createHelper(object),
[object],
)
useEffect(() => {
if (helper == undefined) {
return
}
if (selected === uniqueName || hovered) {
scene.add(helper)
invalidate()
@ -79,10 +75,6 @@ const EditableProxy: VFC<EditableProxyProps> = ({
}
}, [selected, hovered, helper, scene])
useFrame(() => {
if (helper == undefined) {
return
}
if (helper.update) {
helper.update()
}

View file

@ -1,6 +1,5 @@
import type {EditableFactoryConfig} from './editableFactoryConfigUtils'
import {
createColorPropConfig,
createNumberPropConfig,
createVector,
createVectorPropConfig,
@ -101,15 +100,6 @@ const defaultEditableFactoryConfig = {
line: baseObjectConfig,
lineLoop: 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

View file

@ -17,7 +17,7 @@ type Meta<T> = {
updateObject?: (object: T) => void
icon: IconID
dimensionless?: boolean
createHelper?: (object: T) => Helper
createHelper: (object: T) => Helper
}
export type ObjectConfig<T> = {props: Props} & Meta<T>
export type EditableFactoryConfig = Partial<
@ -79,7 +79,7 @@ export const createNumberPropConfig = (
{nudgeMultiplier = 0.01} = {},
): PropConfig<number> => ({
parse: (props) => {
return props[key] ?? defaultValue
return props[key] ?? defaultValue ?? 0
},
apply: (value, object) => {
object[key] = value

View file

@ -1,8 +1,4 @@
import {
BsCameraVideoFill,
BsFillCollectionFill,
BsCloudFill,
} from 'react-icons/bs'
import {BsCameraVideoFill, BsFillCollectionFill} from 'react-icons/bs'
import {GiCube, GiLightBulb, GiLightProjector} from 'react-icons/gi'
import {BiSun} from 'react-icons/bi'
import React from 'react'
@ -14,7 +10,6 @@ const icons = {
spotLight: <GiLightProjector />,
sun: <BiSun />,
camera: <BsCameraVideoFill />,
cloud: <BsCloudFill />,
}
export type IconID = keyof typeof icons