-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add webgl2 and offscreencanvas check
- Loading branch information
1 parent
8761597
commit 46136d6
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@tedengine/ted': minor | ||
--- | ||
|
||
Check for WebGL2 and OffscreenCanvas support on bootstrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export type TBrowserFeature = 'webgl2' | 'offscreencanvas'; | ||
|
||
export default class TBrowser { | ||
public supports(feature: TBrowserFeature): boolean { | ||
switch (feature) { | ||
case 'webgl2': | ||
return this.supportsWebGL2(); | ||
case 'offscreencanvas': | ||
return this.supportsOffscreenCanvas(); | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
private supportsWebGL2(): boolean { | ||
try { | ||
const canvas = document.createElement('canvas'); | ||
return !!canvas.getContext('webgl2'); | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
private supportsOffscreenCanvas(): boolean { | ||
return typeof OffscreenCanvas !== 'undefined'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters