js/Detector.js

Thu, 06 Apr 2017 16:21:21 +0200

author
mdd
date
Thu, 06 Apr 2017 16:21:21 +0200
changeset 18
ff1941c85fd3
parent 16
800e8da193a7
permissions
-rw-r--r--

added 2d image to 3d viewer

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

mercurial