Refactor player start settings: remove mouse camera inversion and update first-person pointer lock logic
This commit is contained in:
@@ -3735,9 +3735,6 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
||||
setPlayerStartTargetButtonCyclesActiveTargetDraft(
|
||||
DEFAULT_PLAYER_START_TARGET_BUTTON_CYCLES_ACTIVE_TARGET_VALUE
|
||||
);
|
||||
setPlayerStartInvertMouseCameraHorizontalDraft(
|
||||
DEFAULT_PLAYER_START_INVERT_MOUSE_CAMERA_HORIZONTAL_VALUE
|
||||
);
|
||||
setPlayerStartMovementTemplateDraft(createPlayerStartMovementTemplate());
|
||||
setPlayerStartMovementTemplateNumberDraft(
|
||||
createPlayerStartMovementTemplateNumberDraft(
|
||||
@@ -3907,9 +3904,6 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
||||
setPlayerStartTargetButtonCyclesActiveTargetDraft(
|
||||
selectedEntity.targetButtonCyclesActiveTarget
|
||||
);
|
||||
setPlayerStartInvertMouseCameraHorizontalDraft(
|
||||
selectedEntity.invertMouseCameraHorizontal
|
||||
);
|
||||
setPlayerStartMovementTemplateDraft(
|
||||
clonePlayerStartMovementTemplate(selectedEntity.movementTemplate)
|
||||
);
|
||||
@@ -4910,7 +4904,9 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
||||
return;
|
||||
}
|
||||
|
||||
const pointerCaptured = firstPersonTelemetry?.pointerLocked === true;
|
||||
const pointerCaptured =
|
||||
activeNavigationMode === "firstPerson" &&
|
||||
firstPersonTelemetry?.pointerLocked === true;
|
||||
|
||||
if (pointerCaptured) {
|
||||
return;
|
||||
@@ -4925,7 +4921,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
||||
return () => {
|
||||
window.removeEventListener("keydown", handleWindowKeyDown);
|
||||
};
|
||||
}, [editorState.toolMode, firstPersonTelemetry]);
|
||||
}, [activeNavigationMode, editorState.toolMode, firstPersonTelemetry]);
|
||||
|
||||
const applyProjectName = () => {
|
||||
const normalizedName = projectNameDraft.trim() || DEFAULT_PROJECT_NAME;
|
||||
@@ -8907,7 +8903,6 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
||||
overrides: {
|
||||
allowLookInputTargetSwitch?: boolean;
|
||||
colliderMode?: PlayerStartColliderMode;
|
||||
invertMouseCameraHorizontal?: boolean;
|
||||
movementTemplate?: PlayerStartMovementTemplate;
|
||||
navigationMode?: PlayerStartNavigationMode;
|
||||
inputBindings?: PlayerStartInputBindings;
|
||||
@@ -8947,9 +8942,6 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
||||
const targetButtonCyclesActiveTarget =
|
||||
overrides.targetButtonCyclesActiveTarget ??
|
||||
playerStartTargetButtonCyclesActiveTargetDraft;
|
||||
const invertMouseCameraHorizontal =
|
||||
overrides.invertMouseCameraHorizontal ??
|
||||
playerStartInvertMouseCameraHorizontalDraft;
|
||||
const nextEntity = createPlayerStartEntity({
|
||||
id: selectedPlayerStart.id,
|
||||
name: selectedPlayerStart.name,
|
||||
@@ -8960,7 +8952,6 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
||||
interactionAngleDegrees,
|
||||
allowLookInputTargetSwitch,
|
||||
targetButtonCyclesActiveTarget,
|
||||
invertMouseCameraHorizontal,
|
||||
movementTemplate,
|
||||
inputBindings,
|
||||
collider: {
|
||||
@@ -13373,7 +13364,11 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
||||
<div className="stat-card">
|
||||
<div className="label">Pointer Lock</div>
|
||||
<div className="value">
|
||||
{firstPersonTelemetry?.pointerLocked ? "active" : "idle"}
|
||||
{activeNavigationMode === "firstPerson"
|
||||
? firstPersonTelemetry?.pointerLocked
|
||||
? "active"
|
||||
: "idle"
|
||||
: "not used"}
|
||||
</div>
|
||||
</div>
|
||||
<div className="stat-card">
|
||||
@@ -20842,27 +20837,6 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
<label className="form-field form-field--toggle">
|
||||
<span className="label">Invert Mouse Camera</span>
|
||||
<input
|
||||
data-testid="player-start-invert-mouse-camera"
|
||||
type="checkbox"
|
||||
checked={
|
||||
playerStartInvertMouseCameraHorizontalDraft
|
||||
}
|
||||
onChange={(event) => {
|
||||
const nextValue = event.currentTarget.checked;
|
||||
setPlayerStartInvertMouseCameraHorizontalDraft(
|
||||
nextValue
|
||||
);
|
||||
scheduleDraftCommit(() =>
|
||||
applyPlayerStartChange({
|
||||
invertMouseCameraHorizontal: nextValue
|
||||
})
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div className="form-section">
|
||||
|
||||
@@ -198,7 +198,6 @@ import {
|
||||
PLAYER_START_GAMEPAD_CAMERA_LOOK_SCENE_DOCUMENT_VERSION,
|
||||
PLAYER_START_INTERACT_BINDINGS_SCENE_DOCUMENT_VERSION,
|
||||
PLAYER_START_INPUT_BINDINGS_SCENE_DOCUMENT_VERSION,
|
||||
PLAYER_START_MOUSE_INVERT_SCENE_DOCUMENT_VERSION,
|
||||
PLAYER_START_TARGETING_SETTINGS_SCENE_DOCUMENT_VERSION,
|
||||
PLAYER_START_NAVIGATION_MODE_SCENE_DOCUMENT_VERSION,
|
||||
PLAYER_START_PAUSE_BINDINGS_SCENE_DOCUMENT_VERSION,
|
||||
|
||||
@@ -510,25 +510,23 @@ export class FirstPersonNavigationController implements NavigationController {
|
||||
};
|
||||
|
||||
private handleMouseMove = (event: MouseEvent) => {
|
||||
const context = this.context;
|
||||
|
||||
if (
|
||||
!this.pointerLocked ||
|
||||
context?.isInputSuspended() === true ||
|
||||
context?.isCameraDrivenExternally() === true ||
|
||||
context === null
|
||||
this.context?.isInputSuspended() === true ||
|
||||
this.context?.isCameraDrivenExternally() === true
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const horizontalMouseLookSign =
|
||||
context.getRuntimeScene().playerStart?.invertMouseCameraHorizontal === true
|
||||
this.context.getRuntimeScene().playerStart?.invertMouseCameraHorizontal ===
|
||||
true
|
||||
? -1
|
||||
: 1;
|
||||
const horizontalMovement = event.movementX * horizontalMouseLookSign;
|
||||
|
||||
const targetLookResult =
|
||||
context.handleRuntimeTargetLookInput?.({
|
||||
this.context?.handleRuntimeTargetLookInput?.({
|
||||
horizontal: horizontalMovement,
|
||||
vertical: -event.movementY
|
||||
}) ?? null;
|
||||
|
||||
Reference in New Issue
Block a user