diff --git a/frontend/apps/editor3d/app/src/pages/PageEnigma/Editor/free_cam.ts b/frontend/apps/editor3d/app/src/pages/PageEnigma/Editor/free_cam.ts index 0d35fb16ae..fbd7e6d375 100644 --- a/frontend/apps/editor3d/app/src/pages/PageEnigma/Editor/free_cam.ts +++ b/frontend/apps/editor3d/app/src/pages/PageEnigma/Editor/free_cam.ts @@ -9,6 +9,28 @@ import * as THREE from "three"; import { cameras, selectedCameraId } from "~/pages/PageEnigma/signals/camera"; import { isPromptBoxFocused } from "~/pages/PageEnigma/signals/promptBox"; + +export const isSafariUserAgent = () => { + const ua = navigator.userAgent; + + const isSafari = /^((?!chrome|android|crios|fxios).)*safari/i.test(ua); + + return isSafari; +} + +export const hasApplePay = () => { + // @ts-expect-error Apple Pay is not defined in TypeScript + return !!window.ApplePaySession; +} + +export const isSafari = () => { + return isSafariUserAgent() || hasApplePay(); +} + +export const isPointerLockSupported = () => { + return !isSafari(); +} + class FreeCam extends EventDispatcher { object: THREE.PerspectiveCamera; domElement: HTMLElement | Document; diff --git a/frontend/apps/editor3d/app/src/pages/PageEnigma/Editor/keybinds_controls.ts b/frontend/apps/editor3d/app/src/pages/PageEnigma/Editor/keybinds_controls.ts index 844558cdf6..61c6efa7c8 100644 --- a/frontend/apps/editor3d/app/src/pages/PageEnigma/Editor/keybinds_controls.ts +++ b/frontend/apps/editor3d/app/src/pages/PageEnigma/Editor/keybinds_controls.ts @@ -14,7 +14,7 @@ import { } from "three/examples/jsm/Addons.js"; import { TransformControls } from "./TransformControls"; import { SceneManager, SceneObject } from "./scene_manager_api"; -import { FreeCam } from "./free_cam"; +import { FreeCam, isPointerLockSupported } from "./free_cam"; import Stats from "three/examples/jsm/libs/stats.module.js"; import { FKHelper } from "./KinHelpers/FKHelper"; import { @@ -391,6 +391,10 @@ export class MouseControls { this.timeline_mouse = this.mouse; // this causes an issue https://discourse.threejs.org/t/unable-to-use-pointer-lock-api/11092 + if (!isPointerLockSupported()) { + return; + } + if (this.isMouseClicked && this.lockControls) { if (this.lockControls.isLocked == false) { this.lockControls.lock();