Improve light support in theatre/r3f (#316)

Add color to all light types and add ambient and hemisphere lights
This commit is contained in:
Andrew Prifer 2022-10-14 15:43:53 +02:00 committed by GitHub
parent 6497bf2097
commit 54ed4c3c41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,6 +17,7 @@ import type {
import {
BoxHelper,
CameraHelper,
Color,
DirectionalLightHelper,
PointLightHelper,
SpotLightHelper,
@ -38,6 +39,7 @@ const baseLightConfig = {
intensity: createNumberPropConfig('intensity', 1),
distance: createNumberPropConfig('distance'),
decay: createNumberPropConfig('decay'),
color: createColorPropConfig('color', new Color('white')),
}),
dimensionless: true,
}
@ -80,6 +82,7 @@ const defaultEditableFactoryConfig = {
directionalLight: {
...extendObjectProps(baseObjectConfig, {
intensity: createNumberPropConfig('intensity', 1),
color: createColorPropConfig('color', new Color('white')),
}),
icon: 'sun' as const,
dimensionless: true,
@ -92,6 +95,23 @@ const defaultEditableFactoryConfig = {
createHelper: (light: PointLight) =>
new PointLightHelper(light, 1, selectionColor),
},
ambientLight: {
props: {
intensity: createNumberPropConfig('intensity', 1),
color: createColorPropConfig('color', new Color('white')),
},
useTransformControls: false,
icon: 'lightBulb' as const,
},
hemisphereLight: {
props: {
intensity: createNumberPropConfig('intensity', 1),
color: createColorPropConfig('color', new Color('white')),
groundColor: createColorPropConfig('groundColor', new Color('white')),
},
useTransformControls: false,
icon: 'lightBulb' as const,
},
perspectiveCamera: extendObjectProps(baseCameraConfig, {
fov: createNumberPropConfig('fov', 50, {nudgeMultiplier: 0.1}),
zoom: createNumberPropConfig('zoom', 1),