hdr-canvas 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +2 -2
- package/three/HDRWebGPURenderer.js +1 -1
- package/three/WebGPU.js +60 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hdr-canvas",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.5",
|
4
4
|
"description": "HDR capable HTML canvas",
|
5
5
|
"main": "dist/hdr-canvas.js",
|
6
6
|
"files": [
|
@@ -47,7 +47,7 @@
|
|
47
47
|
"eslint": "^9.6.0",
|
48
48
|
"prettier": "^3.3.2",
|
49
49
|
"rimraf": "^6.0.0",
|
50
|
-
"rollup": "^4.18.
|
50
|
+
"rollup": "^4.18.1",
|
51
51
|
"rollup-plugin-dts": "^6.1.1",
|
52
52
|
"three": "^0.166.1",
|
53
53
|
"tslib": "^2.6.3",
|
package/three/WebGPU.js
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
if ( self.GPUShaderStage === undefined ) {
|
2
|
+
|
3
|
+
self.GPUShaderStage = { VERTEX: 1, FRAGMENT: 2, COMPUTE: 4 };
|
4
|
+
|
5
|
+
}
|
6
|
+
|
7
|
+
// statics
|
8
|
+
|
9
|
+
let isAvailable = navigator.gpu !== undefined;
|
10
|
+
|
11
|
+
|
12
|
+
if ( typeof window !== 'undefined' && isAvailable ) {
|
13
|
+
|
14
|
+
//isAvailable = await navigator.gpu.requestAdapter();
|
15
|
+
isAvailable = navigator.gpu.requestAdapter().then((isAvailable) => {
|
16
|
+
return isAvailable;
|
17
|
+
});
|
18
|
+
|
19
|
+
}
|
20
|
+
|
21
|
+
class WebGPU {
|
22
|
+
|
23
|
+
static isAvailable() {
|
24
|
+
|
25
|
+
return Boolean( isAvailable );
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
static getStaticAdapter() {
|
30
|
+
|
31
|
+
return isAvailable;
|
32
|
+
|
33
|
+
}
|
34
|
+
|
35
|
+
static getErrorMessage() {
|
36
|
+
|
37
|
+
const message = 'Your browser does not support <a href="https://gpuweb.github.io/gpuweb/" style="color:blue">WebGPU</a> yet';
|
38
|
+
|
39
|
+
const element = document.createElement( 'div' );
|
40
|
+
element.id = 'webgpumessage';
|
41
|
+
element.style.fontFamily = 'monospace';
|
42
|
+
element.style.fontSize = '13px';
|
43
|
+
element.style.fontWeight = 'normal';
|
44
|
+
element.style.textAlign = 'center';
|
45
|
+
element.style.background = '#fff';
|
46
|
+
element.style.color = '#000';
|
47
|
+
element.style.padding = '1.5em';
|
48
|
+
element.style.maxWidth = '400px';
|
49
|
+
element.style.margin = '5em auto 0';
|
50
|
+
|
51
|
+
element.innerHTML = message;
|
52
|
+
|
53
|
+
return element;
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
export default WebGPU;
|