diff --git a/fission/src/systems/preferences/PreferenceTypes.ts b/fission/src/systems/preferences/PreferenceTypes.ts index 401081ddd6..f55387df78 100644 --- a/fission/src/systems/preferences/PreferenceTypes.ts +++ b/fission/src/systems/preferences/PreferenceTypes.ts @@ -7,6 +7,8 @@ export type GlobalPreference = | "ZoomSensitivity" | "PitchSensitivity" | "YawSensitivity" + | "SceneRotationSensitivity" + | "ViewCubeRotationSensitivity" | "ReportAnalytics" | "UseMetric" | "RenderScoringZones" @@ -32,6 +34,8 @@ export const DefaultGlobalPreferences: { [key: string]: unknown } = { ZoomSensitivity: 15, PitchSensitivity: 10, YawSensitivity: 3, + SceneRotationSensitivity: 0.5, + ViewCubeRotationSensitivity: 0.025, ReportAnalytics: false, UseMetric: false, RenderScoringZones: true, diff --git a/fission/src/systems/scene/CameraControls.ts b/fission/src/systems/scene/CameraControls.ts index e57da5ca72..ce94b5a8c0 100644 --- a/fission/src/systems/scene/CameraControls.ts +++ b/fission/src/systems/scene/CameraControls.ts @@ -7,6 +7,7 @@ import ScreenInteractionHandler, { PRIMARY_MOUSE_INTERACTION, SECONDARY_MOUSE_INTERACTION, } from "./ScreenInteractionHandler" +import PreferencesSystem from "@/systems/preferences/PreferencesSystem" export type CameraControlsType = "Orbit" @@ -43,8 +44,6 @@ const CO_MAX_PHI = Math.PI / 2.1 const CO_MIN_PHI = -Math.PI / 2.1 const CO_SENSITIVITY_ZOOM = 4.0 -const CO_SENSITIVITY_PHI = 0.5 -const CO_SENSITIVITY_THETA = 0.5 const CO_DEFAULT_ZOOM = 3.5 const CO_DEFAULT_PHI = -Math.PI / 6.0 @@ -264,8 +263,10 @@ export class CustomOrbitControls extends CameraControls { } : { theta: 0, phi: 0, r: 0 } - this._coords.theta += omega.theta * deltaT * CO_SENSITIVITY_THETA - this._coords.phi += omega.phi * deltaT * CO_SENSITIVITY_PHI + this._coords.theta += + omega.theta * deltaT * PreferencesSystem.getGlobalPreference("SceneRotationSensitivity") + this._coords.phi += + omega.phi * deltaT * PreferencesSystem.getGlobalPreference("SceneRotationSensitivity") this._coords.r += omega.r * deltaT * CO_SENSITIVITY_ZOOM * Math.pow(this._coords.r, 1.4) this._coords.phi = Math.min(CO_MAX_PHI, Math.max(CO_MIN_PHI, this._coords.phi)) diff --git a/fission/src/ui/components/ViewCube.tsx b/fission/src/ui/components/ViewCube.tsx index ec479825de..5092b76cd3 100644 --- a/fission/src/ui/components/ViewCube.tsx +++ b/fission/src/ui/components/ViewCube.tsx @@ -3,6 +3,7 @@ import * as THREE from "three" import { Box } from "@mui/material" import World from "@/systems/World" import { CustomOrbitControls } from "@/systems/scene/CameraControls" +import PreferencesSystem from "@/systems/preferences/PreferencesSystem" interface ViewCubeProps { size?: number @@ -67,7 +68,7 @@ const ViewCube: React.FC = ({ const deltaX = event.clientX - lastMousePos.x const deltaY = event.clientY - lastMousePos.y - const sensitivity = 0.025 + const sensitivity = PreferencesSystem.getGlobalPreference("ViewCubeRotationSensitivity") const controls = World.SceneRenderer.currentCameraControls if (controls instanceof CustomOrbitControls) { @@ -821,7 +822,7 @@ const ViewCube: React.FC = ({ const deltaX = event.clientX - lastMousePos.x const deltaY = event.clientY - lastMousePos.y - const sensitivity = 0.004 + const sensitivity = PreferencesSystem.getGlobalPreference("ViewCubeRotationSensitivity") const controls = World.SceneRenderer.currentCameraControls if (controls instanceof CustomOrbitControls) { diff --git a/fission/src/ui/modals/configuring/SettingsModal.tsx b/fission/src/ui/modals/configuring/SettingsModal.tsx index 854ebaacaf..2f2337aeb3 100644 --- a/fission/src/ui/modals/configuring/SettingsModal.tsx +++ b/fission/src/ui/modals/configuring/SettingsModal.tsx @@ -53,6 +53,12 @@ const SettingsModal: React.FC = ({ modalId }) => { PreferencesSystem.getGlobalPreference("MuteAllSound") ) const [sfxVolume, setSFXVolume] = useState(PreferencesSystem.getGlobalPreference("SFXVolume")) + const [sceneRotationSensitivity, setSceneRotationSensitivity] = useState( + PreferencesSystem.getGlobalPreference("SceneRotationSensitivity") + ) + const [viewCubeRotationSensitivity, setViewCubeRotationSensitivity] = useState( + PreferencesSystem.getGlobalPreference("ViewCubeRotationSensitivity") * 60 + ) const saveSettings = () => { PreferencesSystem.setGlobalPreference("ReportAnalytics", reportAnalytics) @@ -63,6 +69,8 @@ const SettingsModal: React.FC = ({ modalId }) => { PreferencesSystem.setGlobalPreference("ShowViewCube", showViewCube) PreferencesSystem.setGlobalPreference("MuteAllSound", muteAllSound) PreferencesSystem.setGlobalPreference("SFXVolume", sfxVolume) + PreferencesSystem.setGlobalPreference("SceneRotationSensitivity", sceneRotationSensitivity) + PreferencesSystem.setGlobalPreference("ViewCubeRotationSensitivity", viewCubeRotationSensitivity / 60) SoundPlayer.changeVolume() // Apply the new sound volume @@ -126,6 +134,29 @@ const SettingsModal: React.FC = ({ modalId }) => { onChange={(_, value) => setYawSensitivity(value as number)} tooltipText="Moving the camera left and right." />*/} + {Spacer(5)} + + setSceneRotationSensitivity(value as number)} + step={0.1} + tooltipText="Controls how fast the scene rotates when dragging with the mouse." + /> + {Spacer(2)} + setViewCubeRotationSensitivity(value as number)} + step={0.06} + tooltipText="Controls how fast the view changes when dragging on the view cube." + /> {Spacer(10)}