diff --git a/src/react-components/ui-root.js b/src/react-components/ui-root.js index 83ddd1177f5be71efe796f02043bdceedb2cc6cd..5042d1b444c9171ba4dbf62bf72dd50800276c88 100644 --- a/src/react-components/ui-root.js +++ b/src/react-components/ui-root.js @@ -131,6 +131,10 @@ class UIRoot extends Component { this.enterDaydream(); } else if (this.props.forcedVREntryType === "gearvr") { this.enterGearVR(); + } else if (this.props.forcedVREntryType === "vr") { + this.enterVR(); + } else if (this.props.forcedVREntryType === "2d") { + this.enter2D(); } }; @@ -246,18 +250,22 @@ class UIRoot extends Component { }; enterGearVR = async () => { - this.exit(); + if (this.state.availableVREntryTypes.gearvr === VR_DEVICE_AVAILABILITY.yes) { + await this.performDirectEntryFlow(true); + } else { + this.exit(); - // Launch via Oculus Browser - const location = window.location; - const qs = queryString.parse(location.search); - qs.vr_entry_type = "gearvr"; // Auto-choose 'gearvr' after landing in Oculus Browser + // Launch via Oculus Browser + const location = window.location; + const qs = queryString.parse(location.search); + qs.vr_entry_type = "gearvr"; // Auto-choose 'gearvr' after landing in Oculus Browser - const ovrwebUrl = - `ovrweb://${location.protocol || "http:"}//${location.host}` + - `${location.pathname || ""}?${queryString.stringify(qs)}#${location.hash || ""}`; + const ovrwebUrl = + `ovrweb://${location.protocol || "http:"}//${location.host}` + + `${location.pathname || ""}?${queryString.stringify(qs)}#${location.hash || ""}`; - window.location = ovrwebUrl; + window.location = ovrwebUrl; + } }; enterDaydream = async () => { diff --git a/src/utils/vr-caps-detect.js b/src/utils/vr-caps-detect.js index d0c96d8fbff5b277622a28cd55cb649fc4054efd..5f312c23b7a20ca33f7f2d88fc9bd192d90df609 100644 --- a/src/utils/vr-caps-detect.js +++ b/src/utils/vr-caps-detect.js @@ -41,6 +41,7 @@ const GENERIC_ENTRY_TYPE_DEVICE_BLACKLIST = [/cardboard/i]; export async function getAvailableVREntryTypes() { const isWebVRCapableBrowser = !!navigator.getVRDisplays; const isSamsungBrowser = browser.name === "chrome" && navigator.userAgent.match(/SamsungBrowser/); + const isOculusBrowser = navigator.userAgent.match(/Oculus/); const isDaydreamCapableBrowser = !!(isWebVRCapableBrowser && browser.name === "chrome" && !isSamsungBrowser); let generic = VR_DEVICE_AVAILABILITY.no; @@ -49,7 +50,11 @@ export async function getAvailableVREntryTypes() { // We only consider GearVR support as "maybe" and never "yes". The only browser // that will detect GearVR outside of VR is Samsung Internet, and we'd prefer to launch into Oculus // Browser for now since Samsung Internet requires an additional WebVR installation + flag, so return "maybe". - const gearvr = isMaybeGearVRCompatibleDevice() ? VR_DEVICE_AVAILABILITY.maybe : VR_DEVICE_AVAILABILITY.no; + // + // If we are in Oculus Browser (ie, we are literally wearing a GearVR) then return 'yes'. + const gearvr = isMaybeGearVRCompatibleDevice() + ? isOculusBrowser ? VR_DEVICE_AVAILABILITY.yes : VR_DEVICE_AVAILABILITY.maybe + : VR_DEVICE_AVAILABILITY.no; // For daydream detection, we first check if they are on an Android compatible device, and assume they // may support daydream *unless* this browser has WebVR capabilities, in which case we can do better.