Przeglądaj źródła

Separate enterPointerlock()

Separate engine.enterPointerlock from engine.enterFullscreen
aWeirdo 6 lat temu
rodzic
commit
e9628f25ac
1 zmienionych plików z 20 dodań i 9 usunięć
  1. 20 9
      src/Engines/engine.ts

+ 20 - 9
src/Engines/engine.ts

@@ -1210,14 +1210,7 @@ export class Engine {
 
                 // Pointer lock
                 if (this.isFullscreen && this._pointerLockRequested && canvas) {
-                    canvas.requestPointerLock = canvas.requestPointerLock ||
-                        canvas.msRequestPointerLock ||
-                        canvas.mozRequestPointerLock ||
-                        canvas.webkitRequestPointerLock;
-
-                    if (canvas.requestPointerLock) {
-                        canvas.requestPointerLock();
-                    }
+                    Tools.RequestPointerlock(canvas);
                 }
             };
 
@@ -2074,6 +2067,24 @@ export class Engine {
     }
 
     /**
+     * Enters Pointerlock mode
+     */
+    public enterPointerlock(): void {
+        if (this._renderingCanvas) {
+            Tools.RequestPointerlock(this._renderingCanvas);
+        }
+    }
+
+    /**
+     * Exits Pointerlock mode
+     */
+    public exitPointerlock(): void {
+        if (this.isFullscreen) {
+            Tools.ExitPointerlock();
+        }
+    }
+
+    /**
      * Clear the current render buffer or the current render target (if any is set up)
      * @param color defines the color to use
      * @param backBuffer defines if the back buffer must be cleared
@@ -6394,4 +6405,4 @@ export class Engine {
             return false;
         }
     }
-}
+}