Skip to content

Commit

Permalink
Merge pull request #11005 from PolygonalSun/PolygonalSun/safari-context
Browse files Browse the repository at this point in the history
Fixed Context code to omit Safari
  • Loading branch information
sebavan committed Sep 8, 2021
2 parents 56e5fa7 + dd0dd70 commit 3cc0378
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Cameras/Inputs/BaseCameraPointersInput.ts
Expand Up @@ -33,6 +33,7 @@ export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
protected _buttonsPressed: number;

private _currentActiveButton: number = -1;
private _usingSafari = Tools.IsSafari();

/**
* Defines the buttons associated with the input to handle camera move.
Expand Down Expand Up @@ -64,6 +65,7 @@ export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
this._pointerInput = (p, s) => {
var evt = <IPointerEvent>p.event;
let isTouch = evt.pointerType === "touch";
let ignoreContext = isTouch || this._usingSafari;

if (engine.isInVRExclusivePointerMode) {
return;
Expand Down Expand Up @@ -131,7 +133,7 @@ export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
}
} else if (p.type === PointerEventTypes.POINTERDOUBLETAP) {
this.onDoubleTap(evt.pointerType);
} else if (p.type === PointerEventTypes.POINTERUP && srcElement) {
} else if (srcElement && (p.type === PointerEventTypes.POINTERUP || (p.type === PointerEventTypes.POINTERMOVE && p.event.button === this._currentActiveButton && this._currentActiveButton !== -1 && !ignoreContext))) {
try {
srcElement.releasePointerCapture(evt.pointerId);
} catch (e) {
Expand Down
3 changes: 2 additions & 1 deletion src/Cameras/Inputs/freeCameraMouseInput.ts
Expand Up @@ -44,6 +44,7 @@ export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
public _allowCameraRotation = true;

private _currentActiveButton: number = -1;
private _usingSafari = Tools.IsSafari();

/**
* Manage the mouse inputs to control the movement of a free camera.
Expand Down Expand Up @@ -109,7 +110,7 @@ export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
if (engine.isPointerLock && this._onMouseMove) {
this._onMouseMove(p.event);
}
} else if (p.type === PointerEventTypes.POINTERUP && srcElement) {
} else if (srcElement && (p.type === PointerEventTypes.POINTERUP || (p.type === PointerEventTypes.POINTERMOVE && p.event.button === this._currentActiveButton && this._currentActiveButton !== -1 && !this._usingSafari))) {
try {
srcElement.releasePointerCapture(evt.pointerId);
} catch (e) {
Expand Down

0 comments on commit 3cc0378

Please sign in to comment.