CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/assets/threejs/r73/Detector.js
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
/**
7
* @author alteredq / http://alteredqualia.com/
8
* @author mr.doob / http://mrdoob.com/
9
*/
10
11
var Detector = {
12
13
canvas: !! window.CanvasRenderingContext2D,
14
webgl: ( function () {
15
16
try {
17
18
var canvas = document.createElement( 'canvas' ); return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );
19
20
} catch ( e ) {
21
22
return false;
23
24
}
25
26
} )(),
27
workers: !! window.Worker,
28
fileapi: window.File && window.FileReader && window.FileList && window.Blob,
29
30
getWebGLErrorMessage: function () {
31
32
var element = document.createElement( 'div' );
33
element.id = 'webgl-error-message';
34
element.style.fontFamily = 'monospace';
35
element.style.fontSize = '13px';
36
element.style.fontWeight = 'normal';
37
element.style.textAlign = 'center';
38
element.style.background = '#fff';
39
element.style.color = '#000';
40
element.style.padding = '1.5em';
41
element.style.width = '400px';
42
element.style.margin = '5em auto 0';
43
44
if ( ! this.webgl ) {
45
46
element.innerHTML = window.WebGLRenderingContext ? [
47
'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 />',
48
'Find out how to get it <a href="http://get.webgl.org/" style="color:#000">here</a>.'
49
].join( '\n' ) : [
50
'Your browser does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">WebGL</a>.<br/>',
51
'Find out how to get it <a href="http://get.webgl.org/" style="color:#000">here</a>.'
52
].join( '\n' );
53
54
}
55
56
return element;
57
58
},
59
60
addGetWebGLMessage: function ( parameters ) {
61
62
var parent, id, element;
63
64
parameters = parameters || {};
65
66
parent = parameters.parent !== undefined ? parameters.parent : document.body;
67
id = parameters.id !== undefined ? parameters.id : 'oldie';
68
69
element = Detector.getWebGLErrorMessage();
70
element.id = id;
71
72
parent.appendChild( element );
73
74
}
75
76
};
77
78
// browserify support
79
if ( typeof module === 'object' ) {
80
81
module.exports = Detector;
82
83
}
84
85