Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
fix directional and spot light additon (#10339)
Browse files Browse the repository at this point in the history
Co-authored-by: aditya-mitra <[email protected]>
  • Loading branch information
SYBIOTE and aditya-mitra authored Jun 10, 2024
1 parent badde2b commit 63c9434
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import ColorInput from '../../../../../primitives/tailwind/Color'
import InputGroup from '../../../input/Group'
import NumericInput from '../../../input/Numeric'
import NodeEditor from '../../nodeEditor'
import LightShadowProperties from '../shadowProperties'

/**
* DirectionalLightNodeEditor is used provides properties to customize DirectionaLight element.
Expand Down Expand Up @@ -73,7 +74,7 @@ export const DirectionalLightNodeEditor: EditorComponentType = (props) => {
unit="cd"
/>
</InputGroup>
{/*<LightShadowProperties entity={props.entity} component={DirectionalLightComponent} />*/}
<LightShadowProperties entity={props.entity} component={DirectionalLightComponent} />
<InputGroup name="Camera Near" label={t('editor:properties.directionalLight.lbl-cameraNear')}>
<NumericInput
min={0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import NumericInput from '../../../input/Numeric'
/**creating properties for LightShadowProperties component */
type LightShadowPropertiesProps = {
entity: Entity
comp: Component<any, any>
component: Component<any, any>
}

/**
Expand All @@ -50,12 +50,15 @@ type LightShadowPropertiesProps = {
export const LightShadowProperties: EditorComponentType = (props: LightShadowPropertiesProps) => {
const { t } = useTranslation()

const lightComponent = useComponent(props.entity, props.comp).value as any
const lightComponent = useComponent(props.entity, props.component) as any

return (
<>
<InputGroup name="Cast Shadows" label={t('editor:properties.directionalLight.lbl-castShadows')}>
<BooleanInput value={lightComponent.castShadow} onChange={commitProperty(props.comp, 'castShadow')} />
<BooleanInput
value={lightComponent.castShadow.value}
onChange={commitProperty(props.component, 'castShadow')}
/>
</InputGroup>
<InputGroup name="Shadow Bias" label={t('editor:properties.directionalLight.lbl-shadowBias')}>
<NumericInput
Expand All @@ -65,9 +68,9 @@ export const LightShadowProperties: EditorComponentType = (props: LightShadowPro
smallStep={0.000001}
largeStep={0.0001}
displayPrecision={0.000001}
value={lightComponent.shadowBias}
onChange={updateProperty(props.comp, 'shadowBias')}
onRelease={commitProperty(props.comp, 'shadowBias')}
value={lightComponent.shadowBias.value}
onChange={updateProperty(props.component, 'shadowBias')}
onRelease={commitProperty(props.component, 'shadowBias')}
/>
</InputGroup>
<InputGroup name="Shadow Radius" label={t('editor:properties.directionalLight.lbl-shadowRadius')}>
Expand All @@ -76,9 +79,9 @@ export const LightShadowProperties: EditorComponentType = (props: LightShadowPro
smallStep={0.1}
largeStep={1}
displayPrecision={0.0001}
value={lightComponent.shadowRadius}
onChange={updateProperty(props.comp, 'shadowRadius')}
onRelease={commitProperty(props.comp, 'shadowRadius')}
value={lightComponent.shadowRadius.value}
onChange={updateProperty(props.component, 'shadowRadius')}
onRelease={commitProperty(props.component, 'shadowRadius')}
/>
</InputGroup>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import LightShadowProperties from '../shadowProperties'
export const SpotLightNodeEditor: EditorComponentType = (props) => {
const { t } = useTranslation()

const lightComponent = useComponent(props.entity, SpotLightComponent).value
const lightComponent = useComponent(props.entity, SpotLightComponent)

return (
<NodeEditor
Expand All @@ -57,15 +57,15 @@ export const SpotLightNodeEditor: EditorComponentType = (props) => {
icon={<LuCircleDot />}
>
<InputGroup name="Color" label={t('editor:properties.spotLight.lbl-color')}>
<ColorInput value={lightComponent.color} onChange={updateProperty(SpotLightComponent, 'color')} />
<ColorInput value={lightComponent.color.value} onChange={updateProperty(SpotLightComponent, 'color')} />
</InputGroup>
<InputGroup name="Intensity" label={t('editor:properties.spotLight.lbl-intensity')}>
<NumericInput
min={0}
smallStep={0.001}
mediumStep={0.01}
largeStep={0.1}
value={lightComponent.intensity}
value={lightComponent.intensity.value}
onChange={updateProperty(SpotLightComponent, 'intensity')}
onRelease={commitProperty(SpotLightComponent, 'intensity')}
/>
Expand All @@ -76,7 +76,7 @@ export const SpotLightNodeEditor: EditorComponentType = (props) => {
max={1}
smallStep={0.01}
mediumStep={0.1}
value={lightComponent.penumbra}
value={lightComponent.penumbra.value}
onChange={updateProperty(SpotLightComponent, 'penumbra')}
onRelease={commitProperty(SpotLightComponent, 'penumbra')}
/>
Expand All @@ -88,7 +88,7 @@ export const SpotLightNodeEditor: EditorComponentType = (props) => {
smallStep={0.1}
mediumStep={1}
largeStep={10}
value={_Math.radToDeg(lightComponent.angle)}
value={_Math.radToDeg(lightComponent.angle.value)}
onChange={(value) => updateProperty(SpotLightComponent, 'angle')(_Math.degToRad(value))}
onRelease={(value) => commitProperty(SpotLightComponent, 'angle')(_Math.degToRad(value))}
unit="°"
Expand All @@ -100,7 +100,7 @@ export const SpotLightNodeEditor: EditorComponentType = (props) => {
smallStep={0.1}
mediumStep={1}
largeStep={10}
value={lightComponent.range}
value={lightComponent.range.value}
onChange={updateProperty(SpotLightComponent, 'range')}
onRelease={commitProperty(SpotLightComponent, 'range')}
unit="m"
Expand All @@ -112,7 +112,7 @@ export const SpotLightNodeEditor: EditorComponentType = (props) => {
max={10}
smallStep={0.1}
mediumStep={1}
value={lightComponent.decay}
value={lightComponent.decay.value}
onChange={updateProperty(SpotLightComponent, 'decay')}
onRelease={commitProperty(SpotLightComponent, 'decay')}
/>
Expand Down

0 comments on commit 63c9434

Please sign in to comment.