Skip to content

Commit

Permalink
Disable scene-viewer on browsers that don't handle intents (google#1649)
Browse files Browse the repository at this point in the history
* intents don't work on Firefox

* trivial

* fix oculus for scene-viewer
  • Loading branch information
elalish authored Oct 16, 2020
1 parent 23a0ed9 commit 07eecbf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@
"husky": "^4.2.1",
"lerna": "^3.20.2",
"typescript": "4.0.3"
}
},
"dependencies": {}
}
4 changes: 4 additions & 0 deletions packages/model-viewer/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ export const IS_AR_QUICKLOOK_CANDIDATE = (() => {

// @see https://developer.chrome.com/multidevice/user-agent
export const IS_SAFARI = /Safari\//.test(navigator.userAgent);
export const IS_FIREFOX = /firefox/i.test(navigator.userAgent);
export const IS_OCULUS = /OculusBrowser/.test(navigator.userAgent);
export const IS_IOS_CHROME = IS_IOS && /CriOS\//.test(navigator.userAgent);
export const IS_IOS_SAFARI = IS_IOS && IS_SAFARI;
export const IS_IE11 =
!((window as any).ActiveXObject) && 'ActiveXObject' in window;

export const IS_SCENEVIEWER_CANDIDATE = IS_ANDROID && !IS_FIREFOX && !IS_OCULUS;
5 changes: 3 additions & 2 deletions packages/model-viewer/src/features/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import {property} from 'lit-element';
import {Event as ThreeEvent} from 'three';

import {IS_ANDROID, IS_AR_QUICKLOOK_CANDIDATE, IS_IOS_CHROME, IS_IOS_SAFARI, IS_WEBXR_AR_CANDIDATE} from '../constants.js';
import {IS_AR_QUICKLOOK_CANDIDATE, IS_IOS_CHROME, IS_IOS_SAFARI, IS_SCENEVIEWER_CANDIDATE, IS_WEBXR_AR_CANDIDATE} from '../constants.js';
import ModelViewerElementBase, {$loaded, $renderer, $scene, $shouldAttemptPreload, $updateSource} from '../model-viewer-base.js';
import {enumerationDeserializer} from '../styles/deserializers.js';
import {ARStatus} from '../three-components/ARRenderer.js';
Expand Down Expand Up @@ -211,7 +211,8 @@ configuration or device capabilities');
this[$arMode] = ARMode.WEBXR;
break;
} else if (
value === 'scene-viewer' && IS_ANDROID && !isSceneViewerBlocked) {
value === 'scene-viewer' && IS_SCENEVIEWER_CANDIDATE &&
!isSceneViewerBlocked) {
this[$arMode] = ARMode.SCENE_VIEWER;
break;
} else if (
Expand Down

0 comments on commit 07eecbf

Please sign in to comment.