hdr-canvas 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdr-canvas",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "HDR capable HTML canvas",
5
5
  "main": "dist/hdr-canvas.js",
6
6
  "files": [
@@ -46,8 +46,8 @@
46
46
  "@types/eslint__js": "^8.42.3",
47
47
  "eslint": "^9.6.0",
48
48
  "prettier": "^3.3.2",
49
- "rimraf": "^5.0.7",
50
- "rollup": "^4.18.0",
49
+ "rimraf": "^6.0.0",
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",
@@ -67,7 +67,7 @@ export class Uint16Image {
67
67
  this.data[pos + 3] = px[3];
68
68
  }
69
69
 
70
- // Only use this for aplha, since it doesn't to color space conversions
70
+ // Only use this for alpha, since it doesn't to color space conversions
71
71
  static scaleUint8ToUint16(val: number): number {
72
72
  return (val << 8) | val;
73
73
  }
@@ -181,4 +181,10 @@ export class Uint16Image {
181
181
  }
182
182
  this.colorSpace = Uint16Image.DEFAULT_COLORSPACE;
183
183
  }
184
+
185
+ clone(): Uint16Image {
186
+ const i = new Uint16Image(this.width, this.height, this.colorSpace);
187
+ i.data = this.data.slice();
188
+ return i;
189
+ }
184
190
  }
@@ -1,4 +1,4 @@
1
- import WebGPU from 'three/addons/capabilities/WebGPU.js';
1
+ import WebGPU from './WebGPU.js';
2
2
 
3
3
  import Renderer from 'three/addons/renderers/common/Renderer.js';
4
4
  import WebGLBackend from 'three/addons/renderers/webgl/WebGLBackend.js';
@@ -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;