Thu, 06 Apr 2017 19:00:07 +0200
ht is not PVC....
16 | 1 | /** |
2 | * @author alteredq / http://alteredqualia.com/ | |
3 | * @author mr.doob / http://mrdoob.com/ | |
4 | */ | |
5 | ||
6 | var Detector = { | |
7 | ||
8 | canvas: !! window.CanvasRenderingContext2D, | |
9 | webgl: ( function () { | |
10 | ||
11 | try { | |
12 | ||
13 | var canvas = document.createElement( 'canvas' ); return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) ); | |
14 | ||
15 | } catch ( e ) { | |
16 | ||
17 | return false; | |
18 | ||
19 | } | |
20 | ||
21 | } )(), | |
22 | workers: !! window.Worker, | |
23 | fileapi: window.File && window.FileReader && window.FileList && window.Blob, | |
24 | ||
25 | getWebGLErrorMessage: function () { | |
26 | ||
27 | var element = document.createElement( 'div' ); | |
28 | element.id = 'webgl-error-message'; | |
29 | element.style.fontFamily = 'monospace'; | |
30 | element.style.fontSize = '13px'; | |
31 | element.style.fontWeight = 'normal'; | |
32 | element.style.textAlign = 'center'; | |
33 | element.style.background = '#fff'; | |
34 | element.style.color = '#000'; | |
35 | element.style.padding = '1.5em'; | |
36 | element.style.width = '400px'; | |
37 | element.style.margin = '5em auto 0'; | |
38 | ||
39 | if ( ! this.webgl ) { | |
40 | ||
41 | element.innerHTML = window.WebGLRenderingContext ? [ | |
42 | 'Your graphics card does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">WebGL</a>.<br />', | |
43 | 'Find out how to get it <a href="http://get.webgl.org/" style="color:#000">here</a>.' | |
44 | ].join( '\n' ) : [ | |
45 | 'Your browser does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">WebGL</a>.<br/>', | |
46 | 'Find out how to get it <a href="http://get.webgl.org/" style="color:#000">here</a>.' | |
47 | ].join( '\n' ); | |
48 | ||
49 | } | |
50 | ||
51 | return element; | |
52 | ||
53 | }, | |
54 | ||
55 | addGetWebGLMessage: function ( parameters ) { | |
56 | ||
57 | var parent, id, element; | |
58 | ||
59 | parameters = parameters || {}; | |
60 | ||
61 | parent = parameters.parent !== undefined ? parameters.parent : document.body; | |
62 | id = parameters.id !== undefined ? parameters.id : 'oldie'; | |
63 | ||
64 | element = Detector.getWebGLErrorMessage(); | |
65 | element.id = id; | |
66 | ||
67 | parent.appendChild( element ); | |
68 | ||
69 | } | |
70 | ||
71 | }; | |
72 | ||
73 | // browserify support | |
74 | if ( typeof module === 'object' ) { | |
75 | ||
76 | module.exports = Detector; | |
77 | ||
78 | } |