From 1e5d91b01bf27479fdaaad4216cc5ce24617e4c5 Mon Sep 17 00:00:00 2001 From: Daniel Belmes Date: Fri, 22 Dec 2023 10:54:26 -0800 Subject: [PATCH] Fix shadow and camera --- .../engine/src/camera/systems/CameraInputSystem.ts | 5 ++++- packages/engine/src/scene/systems/ShadowSystem.tsx | 11 ++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/engine/src/camera/systems/CameraInputSystem.ts b/packages/engine/src/camera/systems/CameraInputSystem.ts index 3d38c768e1d..1df96ae8f6b 100644 --- a/packages/engine/src/camera/systems/CameraInputSystem.ts +++ b/packages/engine/src/camera/systems/CameraInputSystem.ts @@ -50,6 +50,7 @@ import { XRState } from '../../xr/XRState' import { InputState } from '../../input/state/InputState' +import { isMobile } from '../../common/functions/isMobile' import { InputSystemGroup } from '../../ecs/functions/EngineFunctions' import { CameraSettings } from '../CameraState' import { FollowCameraComponent } from '../components/FollowCameraComponent' @@ -214,7 +215,9 @@ const execute = () => { if (keys?.KeyC?.down) onKeyC() const pointerState = getState(InputState).pointerState - const mouseMoved = keys?.PrimaryClick?.pressed + const mouseMoved = isMobile + ? pointerState.movement.lengthSq() > 0 && keys?.PrimaryClick?.pressed + : keys?.PrimaryClick?.pressed for (const entity of avatarControllerEntities) { if (!inputSource) continue diff --git a/packages/engine/src/scene/systems/ShadowSystem.tsx b/packages/engine/src/scene/systems/ShadowSystem.tsx index 0a732a44a7b..eb61a17cc8f 100644 --- a/packages/engine/src/scene/systems/ShadowSystem.tsx +++ b/packages/engine/src/scene/systems/ShadowSystem.tsx @@ -61,7 +61,7 @@ import { } from '../../ecs/functions/ComponentFunctions' import { AnimationSystemGroup } from '../../ecs/functions/EngineFunctions' import { createEntity, removeEntity, useEntityContext } from '../../ecs/functions/EntityFunctions' -import { iterateEntityNode } from '../../ecs/functions/EntityTree' +import { EntityTreeComponent, iterateEntityNode } from '../../ecs/functions/EntityTree' import { QueryReactor, defineSystem } from '../../ecs/functions/SystemFunctions' import { RendererState } from '../../renderer/RendererState' import { EngineRenderer, RenderSettingsState } from '../../renderer/WebGLRendererSystem' @@ -72,14 +72,13 @@ import { XRLightProbeState } from '../../xr/XRLightProbeSystem' import { isMobileXRHeadset } from '../../xr/XRState' import { DirectionalLightComponent } from '../components/DirectionalLightComponent' import { DropShadowComponent } from '../components/DropShadowComponent' +import { GroundPlaneComponent } from '../components/GroundPlaneComponent' import { GroupComponent, GroupQueryReactor, addObjectToGroup } from '../components/GroupComponent' import { MeshComponent } from '../components/MeshComponent' import { useContainsMesh } from '../components/ModelComponent' import { NameComponent } from '../components/NameComponent' -import { ObjectLayerComponents } from '../components/ObjectLayerComponent' import { ShadowComponent } from '../components/ShadowComponent' import { VisibleComponent } from '../components/VisibleComponent' -import { ObjectLayers } from '../constants/ObjectLayers' export const ShadowSystemState = defineState({ name: 'ee.engine.scene.ShadowSystemState', @@ -240,6 +239,7 @@ const DropShadowReactor = () => { const shadowMaterial = useHookstate(shadowState) const containsMesh = useContainsMesh(entity) const shadow = useComponent(entity, ShadowComponent) + const entityTree = getComponent(entity, EntityTreeComponent) useEffect(() => { if ( @@ -247,7 +247,8 @@ const DropShadowReactor = () => { !shadow.cast.value || !shadowMaterial.value || !containsMesh || - hasComponent(entity, DropShadowComponent) + hasComponent(entity, DropShadowComponent) || + entityTree.parentEntity !== null ) return @@ -315,7 +316,7 @@ const shadowOffset = new Vector3(0, 0.01, 0) const sortAndApplyPriorityQueue = createSortAndApplyPriorityQueue(dropShadowComponentQuery, compareDistanceToCamera) const sortedEntityTransforms = [] as Entity[] -const sceneLayerQuery = defineQuery([ObjectLayerComponents[ObjectLayers.Scene]]) +const sceneLayerQuery = defineQuery([GroundPlaneComponent]) const updateDropShadowTransforms = () => { const { deltaSeconds } = getState(EngineState)