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

Fix xrui pointer input & improved follow camera #10471

Merged
merged 44 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
bf487f2
Cleanup pointer event handling
speigg Jun 21, 2024
4458967
Update ClientInputSystem.tsx
speigg Jun 21, 2024
bf0b25f
fix gizmos
speigg Jun 21, 2024
cbf2afd
Update CameraOrbitSystem.tsx
speigg Jun 21, 2024
7f45f6d
Update ClientInputSystem.tsx
speigg Jun 21, 2024
9f80477
Update ClientInputSystem.tsx
speigg Jun 22, 2024
a621335
wip
speigg Jun 25, 2024
e641f72
Update getThumbstickOrThumbpadAxes.ts
speigg Jun 25, 2024
a1c0643
wip
speigg Jun 25, 2024
01740f1
wip
speigg Jun 26, 2024
10683c5
Merge branch 'dev' into fix-xrui-pointer-input
speigg Jun 26, 2024
6a5c825
Update ClientInputSystem.tsx
speigg Jun 26, 2024
31ec520
wip
speigg Jun 26, 2024
b831f11
wip
speigg Jun 26, 2024
efe3a1d
Update ClientInputSystem.tsx
speigg Jun 26, 2024
ccba8b7
fix for avatar movement
SamMazerIR Jun 27, 2024
690025f
fix for followcamera orbit not working and decreased sensitivity (due…
SamMazerIR Jun 27, 2024
eaaf726
some improvements
speigg Jun 27, 2024
1fd95f8
Update FollowCameraComponent.ts
speigg Jun 27, 2024
7b3f0da
Update FollowCameraComponent.ts
speigg Jun 27, 2024
7c90470
Merge branch 'dev' into fix-xrui-pointer-input
SamMazerIR Jun 27, 2024
a94404e
tweaks
speigg Jun 27, 2024
3a55034
fixing rotation issues with cameras when you're capturing another entity
SamMazerIR Jun 28, 2024
d10ce5a
better fix for the orbiting with followcam, also fixing a logical bug…
SamMazerIR Jun 28, 2024
4cacfe5
Update LinkComponent.ts
speigg Jun 28, 2024
8389b3c
fix ts errors
speigg Jun 28, 2024
a15d8e1
attempting to fix some build errors
SamMazerIR Jun 28, 2024
aee13a0
Merge branch 'dev' into fix-xrui-pointer-input
SamMazerIR Jun 28, 2024
6531167
Merge branch 'dev' into fix-xrui-pointer-input
SamMazerIR Jun 28, 2024
42b6fc6
Update ClickPlacementSystem.tsx
speigg Jun 28, 2024
32253d0
fixes to clickPlacement after camera changes
SamMazerIR Jun 28, 2024
df0b0b1
Merge branch 'fix-xrui-pointer-input' of github.com:EtherealEngine/et…
SamMazerIR Jun 28, 2024
21b68b1
fixing what i broke earlier
SamMazerIR Jun 28, 2024
e0c00bb
Merge branch 'dev' into fix-xrui-pointer-input
SamMazerIR Jun 28, 2024
f7db65e
sorting fixes for objects with multiple InputComponents and only one …
SamMazerIR Jul 1, 2024
4dae49c
fixing possible nullref in updateboundingbox
SamMazerIR Jul 1, 2024
da85b1c
Update tsconfig.json
DanielBelmes Jul 1, 2024
3490d60
Update tsconfig.json
DanielBelmes Jul 1, 2024
a62d1c2
reduce angle for follow camera raycasts
HexaField Jul 1, 2024
399fb5c
fix imports
HexaField Jul 1, 2024
348e0fc
cleanup
HexaField Jul 2, 2024
4f4e579
Merge branch 'dev' into fix-xrui-pointer-input
HexaField Jul 2, 2024
1a9feb9
fixing type check
SamMazerIR Jul 2, 2024
66e55b2
Merge branch 'dev' into fix-xrui-pointer-input
SamMazerIR Jul 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/client-core/src/systems/AvatarUISystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const raycastComponentData = {

const onSecondaryClick = () => {
const { physicsWorld } = getState(PhysicsState)
const inputPointerEntity = InputPointerComponent.getPointerForCanvas(Engine.instance.viewerEntity)
const inputPointerEntity = InputPointerComponent.getPointersForCamera(Engine.instance.viewerEntity)[0]
if (!inputPointerEntity) return
const pointerPosition = getComponent(inputPointerEntity, InputPointerComponent).position
const hits = Physics.castRayFromCamera(
Expand Down
1 change: 1 addition & 0 deletions packages/ecs/src/ComponentFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ export function _use(promise) {
* Use a component in a reactive context (a React component)
*/
export function useComponent<C extends Component<any>>(entity: Entity, Component: C) {
if (entity === UndefinedEntity) throw new Error('InvalidUsage: useComponent called with UndefinedEntity')
if (!Component.stateMap[entity]) Component.stateMap[entity] = hookstate(none)
const componentState = Component.stateMap[entity]!
// use() will suspend the component (by throwing a promise) and resume when the promise is resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { getOptionalComponent, useComponent } from '@etherealengine/ecs/src/Comp
import { defineQuery } from '@etherealengine/ecs/src/QueryFunctions'
import { CameraSettingsComponent } from '@etherealengine/engine/src/scene/components/CameraSettingsComponent'
import { ModelComponent } from '@etherealengine/engine/src/scene/components/ModelComponent'
import { CameraMode } from '@etherealengine/spatial/src/camera/types/CameraMode'
import { FollowCameraMode } from '@etherealengine/spatial/src/camera/types/FollowCameraMode'
import { MeshComponent } from '@etherealengine/spatial/src/renderer/components/MeshComponent'
import { iterateEntityNode } from '@etherealengine/spatial/src/transform/components/EntityTree'

Expand All @@ -46,28 +46,29 @@ import { commitProperties, commitProperty, EditorComponentType, updateProperty }
const cameraModeSelect = [
{
label: 'First Person',
value: CameraMode.FirstPerson
value: FollowCameraMode.FirstPerson
},
{
label: 'Shoulder Cam',
value: CameraMode.ShoulderCam
value: FollowCameraMode.ShoulderCam
},
{
label: 'Third Person',
value: CameraMode.ThirdPerson
value: FollowCameraMode.ThirdPerson
},
{
label: 'Top Down',
value: CameraMode.TopDown
},
{
label: 'Strategic',
value: CameraMode.Strategic
},
{
label: 'Dynamic',
value: CameraMode.Dynamic
value: FollowCameraMode.TopDown
}
// These are not currently defined or implemented:
// {
// label: 'Strategic',
// value: FollowCameraMode.Strategic
// },
// {
// label: 'Dynamic',
// value: FollowCameraMode.Dynamic
// }
]

/** Types copied from Camera Modes of engine. */
Expand Down
8 changes: 4 additions & 4 deletions packages/editor/src/functions/gizmoHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ export function controlUpdate(gizmoEntity: Entity) {

function pointerHover(gizmoEntity) {
// TODO support gizmos in multiple viewports
const inputPointerEntity = InputPointerComponent.getPointerForCanvas(Engine.instance.viewerEntity)
const inputPointerEntity = InputPointerComponent.getPointersForCamera(Engine.instance.viewerEntity)[0]
if (!inputPointerEntity) return
const pointerPosition = getComponent(inputPointerEntity, InputPointerComponent).position
const gizmoControlComponent = getMutableComponent(gizmoEntity, TransformGizmoControlComponent)
Expand All @@ -509,7 +509,7 @@ function pointerHover(gizmoEntity) {

function pointerDown(gizmoEntity) {
// TODO support gizmos in multiple viewports
const inputPointerEntity = InputPointerComponent.getPointerForCanvas(Engine.instance.viewerEntity)
const inputPointerEntity = InputPointerComponent.getPointersForCamera(Engine.instance.viewerEntity)[0]
if (!inputPointerEntity) return
const pointer = getComponent(inputPointerEntity, InputPointerComponent)
const gizmoControlComponent = getMutableComponent(gizmoEntity, TransformGizmoControlComponent)
Expand Down Expand Up @@ -768,7 +768,7 @@ function applyPivotRotation(entity, pivotToOriginMatrix, originToPivotMatrix, ro

function pointerMove(gizmoEntity) {
// TODO support gizmos in multiple viewports
const inputPointerEntity = InputPointerComponent.getPointerForCanvas(Engine.instance.viewerEntity)
const inputPointerEntity = InputPointerComponent.getPointersForCamera(Engine.instance.viewerEntity)[0]
if (!inputPointerEntity) return
const pointer = getComponent(inputPointerEntity, InputPointerComponent)
const gizmoControlComponent = getMutableComponent(gizmoEntity, TransformGizmoControlComponent)
Expand Down Expand Up @@ -901,7 +901,7 @@ function pointerMove(gizmoEntity) {

function pointerUp(gizmoEntity) {
// TODO support gizmos in multiple viewports
const inputPointerEntity = InputPointerComponent.getPointerForCanvas(Engine.instance.viewerEntity)
const inputPointerEntity = InputPointerComponent.getPointersForCamera(Engine.instance.viewerEntity)[0]
if (!inputPointerEntity) return
const pointer = getComponent(inputPointerEntity, InputPointerComponent)

Expand Down
4 changes: 2 additions & 2 deletions packages/engine/src/avatar/AvatarModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20
Ethereal Engine. All Rights Reserved.
*/

import { FollowCameraInputSystem } from '@etherealengine/spatial/src/camera/systems/FollowCameraInputSystem'
import { AvatarIKTargetState } from './state/AvatarIKTargetState'
import { AvatarState } from './state/AvatarNetworkState'
import { AnimationSystem } from './systems/AnimationSystem'
import { AvatarAnimationSystem } from './systems/AvatarAnimationSystem'
import { AvatarAutopilotSystem } from './systems/AvatarAutopilotSystem'
import { AvatarCameraInputSystem } from './systems/AvatarCameraInputSystem'
import { AvatarControllerSystem } from './systems/AvatarControllerSystem'
import { AvatarInputSystem } from './systems/AvatarInputSystem'
import { AvatarLoadingSystem } from './systems/AvatarLoadingSystem'
Expand All @@ -42,7 +42,7 @@ export default {
AnimationSystem,
AvatarAnimationSystem,
AvatarAutopilotSystem,
AvatarCameraInputSystem,
AvatarCameraInputSystem: FollowCameraInputSystem,
AvatarControllerSystem,
AvatarIKTargetState,
AvatarInputSystem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ import { CameraComponent } from '../../../../spatial/src/camera/components/Camer
import { setAvatarColliderTransform } from '../functions/spawnAvatarReceptor'
import { AvatarComponent } from './AvatarComponent'

export const eyeOffset = 0.25

export const AvatarControllerComponent = defineComponent({
name: 'AvatarControllerComponent',

Expand Down Expand Up @@ -109,7 +111,8 @@ export const AvatarControllerComponent = defineComponent({
const cameraEntity = avatarControllerComponent.cameraEntity.value
if (cameraEntity && entityExists(cameraEntity) && hasComponent(cameraEntity, FollowCameraComponent)) {
const cameraComponent = getComponent(cameraEntity, FollowCameraComponent)
cameraComponent.offset.set(0, avatarComponent.eyeHeight.value, 0)
cameraComponent.firstPersonOffset.set(0, avatarComponent.eyeHeight.value, eyeOffset)
cameraComponent.thirdPersonOffset.set(0, avatarComponent.eyeHeight.value, 0)
}
}, [avatarComponent.avatarHeight, camera.near])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const autopilotSetPosition = (entity: Entity) => {

const { physicsWorld } = getState(PhysicsState)

const inputPointerEntity = InputPointerComponent.getPointerForCanvas(Engine.instance.viewerEntity)
const inputPointerEntity = InputPointerComponent.getPointersForCamera(Engine.instance.viewerEntity)[0]
if (!inputPointerEntity) return
const pointerPosition = getComponent(inputPointerEntity, InputPointerComponent).position

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ import { proxifyParentChildRelationships } from '../../scene/functions/loadGLTFM
import { AnimationComponent } from '../components/AnimationComponent'
import { AvatarAnimationComponent, AvatarRigComponent } from '../components/AvatarAnimationComponent'
import { AvatarComponent } from '../components/AvatarComponent'
import { AvatarColliderComponent, AvatarControllerComponent } from '../components/AvatarControllerComponent'
import { eyeOffset } from '../systems/AvatarTransparencySystem'
import { AvatarColliderComponent, AvatarControllerComponent, eyeOffset } from '../components/AvatarControllerComponent'

export const spawnAvatarReceptor = (entityUUID: EntityUUID) => {
const entity = UUIDComponent.getEntityByUUID(entityUUID)
Expand Down
199 changes: 0 additions & 199 deletions packages/engine/src/avatar/systems/AvatarCameraInputSystem.ts

This file was deleted.

Loading
Loading