From a379ca38eaa0ef1f9e2375f7cfb0b3cad7e96194 Mon Sep 17 00:00:00 2001 From: Rahul Ghosh Date: Fri, 8 Sep 2023 07:08:46 +0530 Subject: [PATCH] Force-shadow-on-model (#8693) * force shadow component on model * fix the node editor text values * minor fix --- packages/client-core/i18n/en/editor.json | 8 ++++++-- .../src/components/properties/ShadowProperties.tsx | 11 ++++++++--- .../engine/src/scene/components/ModelComponent.ts | 4 +++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/client-core/i18n/en/editor.json b/packages/client-core/i18n/en/editor.json index 87930d5e2f..7b9ec1c516 100755 --- a/packages/client-core/i18n/en/editor.json +++ b/packages/client-core/i18n/en/editor.json @@ -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.", @@ -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", diff --git a/packages/editor/src/components/properties/ShadowProperties.tsx b/packages/editor/src/components/properties/ShadowProperties.tsx index 3a6a46b119..a3324e7a44 100644 --- a/packages/editor/src/components/properties/ShadowProperties.tsx +++ b/packages/editor/src/components/properties/ShadowProperties.tsx @@ -44,11 +44,16 @@ export const ShadowProperties: EditorComponentType = (props) => { if (!hasComponent(props.entity, ShadowComponent)) return <> const shadowComponent = useComponent(props.entity, ShadowComponent) return ( - - + + - + diff --git a/packages/engine/src/scene/components/ModelComponent.ts b/packages/engine/src/scene/components/ModelComponent.ts index e486f55dfa..7ed69fac94 100644 --- a/packages/engine/src/scene/components/ModelComponent.ts +++ b/packages/engine/src/scene/components/ModelComponent.ts @@ -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' @@ -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