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

Commit

Permalink
Force-shadow-on-model (#8693)
Browse files Browse the repository at this point in the history
* force shadow component on model

* fix the node editor text values

* minor fix
  • Loading branch information
SYBIOTE authored Sep 8, 2023
1 parent 44f46af commit a379ca3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 6 additions & 2 deletions packages/client-core/i18n/en/editor.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@
"map": {
"description": "3D geospatial map of e.g. a city."
},
"shadow":{
"name": "Shadows",
"description": "Shadow properties for the model",
"lbl-castShadow": "Cast Shadow",
"lbl-receiveShadow": "Receive Shadow"
},
"model": {
"title": "Model",
"description": "A 3D model in your scene, loaded from a GLTF URL or file.",
Expand All @@ -336,8 +342,6 @@
"lbl-isAvatar": "Force Avatar Animations",
"lbl-isGPUInstancing": "Is Using GPU Instancing",
"lbl-isEquippable": "Is Equippable",
"lbl-castShadow": "Cast Shadow",
"lbl-receiveShadow": "Receive Shadow",
"lbl-interactable": "Interactable",
"lbl-generateBVH": "Generate BVH",
"lbl-avoidCameraOcclusion": "Avoid Camera Occlusion",
Expand Down
11 changes: 8 additions & 3 deletions packages/editor/src/components/properties/ShadowProperties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,16 @@ export const ShadowProperties: EditorComponentType = (props) => {
if (!hasComponent(props.entity, ShadowComponent)) return <></>
const shadowComponent = useComponent(props.entity, ShadowComponent)
return (
<NodeEditor component={ShadowComponent} description={t('editor:properties.model.description')} {...props}>
<InputGroup name="Cast Shadow" label={t('editor:properties.model.lbl-castShadow')}>
<NodeEditor
name={t('editor:properties.shadow.name')}
component={ShadowComponent}
description={t('editor:properties.shadow.description')}
{...props}
>
<InputGroup name="Cast Shadow" label={t('editor:properties.shadow.lbl-castShadow')}>
<BooleanInput value={shadowComponent.cast.value} onChange={updateProperty(ShadowComponent, 'cast')} />
</InputGroup>
<InputGroup name="Receive Shadow" label={t('editor:properties.model.lbl-receiveShadow')}>
<InputGroup name="Receive Shadow" label={t('editor:properties.shadow.lbl-receiveShadow')}>
<BooleanInput value={shadowComponent.receive.value} onChange={updateProperty(ShadowComponent, 'receive')} />
</InputGroup>
</NodeEditor>
Expand Down
4 changes: 3 additions & 1 deletion packages/engine/src/scene/components/ModelComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { enableObjectLayer } from '../functions/setObjectLayers'
import { GroupComponent, addObjectToGroup, removeObjectFromGroup } from './GroupComponent'
import { SceneAssetPendingTagComponent } from './SceneAssetPendingTagComponent'
import { SceneObjectComponent } from './SceneObjectComponent'
import { ShadowComponent } from './ShadowComponent'
import { UUIDComponent } from './UUIDComponent'
import { VariantComponent } from './VariantComponent'

Expand Down Expand Up @@ -131,7 +132,8 @@ function ModelReactor() {
const source = model.src

useEffect(() => {
!hasComponent(entity, LoopAnimationComponent) && setComponent(entity, LoopAnimationComponent, {})
setComponent(entity, LoopAnimationComponent)
setComponent(entity, ShadowComponent)
}, [])

// update src
Expand Down

0 comments on commit a379ca3

Please sign in to comment.