Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
Hubs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ar-noc
Hubs
Commits
d87794e9
Unverified
Commit
d87794e9
authored
6 years ago
by
Marshall Quander
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #457 from mozilla/vr-ua-check-fix
Fix regex tests in VR capabilities checks
parents
708bf2a7
e205f442
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/utils/vr-caps-detect.js
+12
-11
12 additions, 11 deletions
src/utils/vr-caps-detect.js
with
12 additions
and
11 deletions
src/utils/vr-caps-detect.js
+
12
−
11
View file @
d87794e9
...
...
@@ -10,12 +10,12 @@ export const VR_DEVICE_AVAILABILITY = {
maybe
:
"
maybe
"
// Implies this device may support this VR platform, but may not be installed or in a compatible browser
};
function
isMaybeGearVRCompatibleDevice
()
{
return
navigator
.
userAgent
.
match
(
/
\W
Android
\W
/
);
function
isMaybeGearVRCompatibleDevice
(
ua
)
{
return
/
\W
Android
\W
/
.
test
(
ua
);
}
function
isMaybeDaydreamCompatibleDevice
()
{
return
navigator
.
userAgent
.
match
(
/
\W
Android
\W
/
);
function
isMaybeDaydreamCompatibleDevice
(
ua
)
{
return
/
\W
Android
\W
/
.
test
(
ua
);
}
// Blacklist of VR device name regex matchers that we do not want to consider as valid VR devices
...
...
@@ -43,8 +43,9 @@ const GENERIC_ENTRY_TYPE_DEVICE_BLACKLIST = [/cardboard/i];
//
// This function also detects if the user is already in a headset, and returns the isInHMD key to be `true` if so.
export
async
function
getAvailableVREntryTypes
()
{
const
isSamsungBrowser
=
browser
.
name
===
"
chrome
"
&&
navigator
.
userAgent
.
match
(
/SamsungBrowser/
);
const
isOculusBrowser
=
navigator
.
userAgent
.
match
(
/Oculus/
);
const
ua
=
navigator
.
userAgent
;
const
isSamsungBrowser
=
browser
.
name
===
"
chrome
"
&&
/SamsungBrowser/
.
test
(
ua
);
const
isOculusBrowser
=
/Oculus/
.
test
(
ua
);
const
isInHMD
=
isOculusBrowser
;
// This needs to be kept up-to-date with the latest browsers that can support VR and Hubs.
...
...
@@ -73,21 +74,21 @@ export async function getAvailableVREntryTypes() {
//
// If we are in Oculus Browser (ie, we are literally wearing a GearVR) then return 'yes'.
let
gearvr
=
VR_DEVICE_AVAILABILITY
.
no
;
if
(
isMaybeGearVRCompatibleDevice
())
{
if
(
isMaybeGearVRCompatibleDevice
(
ua
))
{
gearvr
=
isOculusBrowser
?
VR_DEVICE_AVAILABILITY
.
yes
:
VR_DEVICE_AVAILABILITY
.
maybe
;
}
// 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.
let
daydream
=
isMaybeDaydreamCompatibleDevice
()
&&
!
isInHMD
?
VR_DEVICE_AVAILABILITY
.
maybe
:
VR_DEVICE_AVAILABILITY
.
no
;
isMaybeDaydreamCompatibleDevice
(
ua
)
&&
!
isInHMD
?
VR_DEVICE_AVAILABILITY
.
maybe
:
VR_DEVICE_AVAILABILITY
.
no
;
if
(
isWebVRCapableBrowser
)
{
const
displays
=
await
navigator
.
getVRDisplays
();
// Generic is supported for non-blacklisted devices and presentable HMDs.
generic
=
displays
.
find
(
d
=>
d
.
capabilities
.
canPresent
&&
!
GENERIC_ENTRY_TYPE_DEVICE_BLACKLIST
.
find
(
r
=>
d
.
displayName
.
match
(
r
))
d
=>
d
.
capabilities
.
canPresent
&&
!
GENERIC_ENTRY_TYPE_DEVICE_BLACKLIST
.
find
(
r
=>
r
.
test
(
d
.
displayName
))
)
?
VR_DEVICE_AVAILABILITY
.
yes
:
VR_DEVICE_AVAILABILITY
.
no
;
...
...
@@ -95,12 +96,12 @@ export async function getAvailableVREntryTypes() {
cardboard
=
!
isIDevice
&&
!
isFirefoxBrowser
&&
displays
.
find
(
d
=>
d
.
capabilities
.
canPresent
&&
d
.
displayName
.
match
(
/cardboard/i
))
displays
.
find
(
d
=>
d
.
capabilities
.
canPresent
&&
/cardboard/i
.
test
(
d
.
displayName
))
?
VR_DEVICE_AVAILABILITY
.
yes
:
VR_DEVICE_AVAILABILITY
.
no
;
// For daydream detection, in a WebVR browser we can increase confidence in daydream compatibility.
const
hasDaydreamWebVRDevice
=
displays
.
find
(
d
=>
d
.
displayName
.
match
(
/daydream/i
));
const
hasDaydreamWebVRDevice
=
displays
.
find
(
d
=>
/daydream/i
.
test
(
d
.
displayName
));
if
(
hasDaydreamWebVRDevice
)
{
// If we detected daydream via WebVR
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment