forked from BladeTransformerLLC/gauzilla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.js
44 lines (32 loc) · 993 Bytes
/
helper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
export function get_canvas_width() {
var canvas = document.getElementById("render_canvas");
var rect = canvas.getBoundingClientRect();
return rect.width;
}
export function get_canvas_height() {
var canvas = document.getElementById("render_canvas");
var rect = canvas.getBoundingClientRect();
return rect.height;
}
export function cpu_cores() {
return navigator.hardwareConcurrency;
}
export function get_time_milliseconds() {
return performance.now();
}
export function get_webgl1_version() {
const gl = document.createElement("canvas").getContext("webgl");
return gl.getParameter(gl.VERSION);
}
export function get_webgl2_version() {
const gl = document.createElement("canvas").getContext("webgl2");
return gl.getParameter(gl.VERSION);
}
export function get_url_param() {
const params = new URLSearchParams(location.search);
if (params.has("url")) {
return params.get("url");
} else {
return "";
}
}