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

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
speigg committed Jun 27, 2024
1 parent 7c90470 commit a94404e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
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
9 changes: 9 additions & 0 deletions packages/engine/src/avatar/systems/AvatarInputSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ import { AvatarComponent } from '../components/AvatarComponent'
import { applyInputSourcePoseToIKTargets } from '../functions/applyInputSourcePoseToIKTargets'
import { setIkFootTarget } from '../functions/avatarFootHeuristics'

import { FollowCameraComponent } from '@etherealengine/spatial/src/camera/components/FollowCameraComponent'
import { FollowCameraMode } from '@etherealengine/spatial/src/camera/types/FollowCameraMode'
import { getThumbstickOrThumbpadAxes } from '@etherealengine/spatial/src/input/functions/getThumbstickOrThumbpadAxes'

const _quat = new Quaternion()
Expand Down Expand Up @@ -260,6 +262,13 @@ const execute = () => {
(buttons[StandardGamepadButton.StandardGamepadDPadUp]?.pressed ? -1 : 0) +
(buttons[StandardGamepadButton.StandardGamepadDPadDown]?.pressed ? -1 : 0)

if (keyDeltaZ === 1) {
// todo: auto-adjust target distance in follow camera system based on target velocity
const follow = getOptionalComponent(controller.cameraEntity, FollowCameraComponent)
if (follow?.mode === FollowCameraMode.ThirdPerson || follow?.mode === FollowCameraMode.ShoulderCam)
follow.targetDistance = Math.max(follow.targetDistance, follow.effectiveMaxDistance * 0.5)
}

controller.gamepadLocalInput.set(keyDeltaX, 0, keyDeltaZ).normalize()

controller.gamepadJumpActive = !!buttons.Space?.pressed || gamepadJump || doubleClicked
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/src/interaction/functions/createUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function createUI(entity: Entity, uiMessage: string, isInteractable = tru
color: new Color('#B9B9B9'),
transmission: 1,
roughness: 0.5,
opacity: 0.95,
opacity: 1,
transparent: true,
side: DoubleSide
})
Expand Down

0 comments on commit a94404e

Please sign in to comment.