hdr-canvas 0.0.1 → 0.0.3
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/README.md +14 -0
- package/dist/hdr-canvas.cjs +24 -0
- package/dist/hdr-canvas.cjs.map +1 -1
- package/dist/hdr-canvas.d.ts +2 -0
- package/dist/hdr-canvas.js +24 -0
- package/dist/hdr-canvas.js.map +1 -1
- package/dist/hdr-canvas.min.js +1 -1
- package/dist/hdr-canvas.min.js.map +1 -1
- package/package.json +1 -1
- package/src/Uint16Image.ts +28 -0
- package/three/HDRWebGPUBackend.js +1 -1
package/package.json
CHANGED
package/src/Uint16Image.ts
CHANGED
@@ -125,6 +125,24 @@ export class Uint16Image {
|
|
125
125
|
}
|
126
126
|
}
|
127
127
|
|
128
|
+
static async loadSDRImageData(url: URL): Promise<HDRImageData | undefined> {
|
129
|
+
return fetch(url)
|
130
|
+
.then((response) => response.blob())
|
131
|
+
.then((blob: Blob) => {
|
132
|
+
return createImageBitmap(blob);
|
133
|
+
})
|
134
|
+
.then((bitmap: ImageBitmap) => {
|
135
|
+
const { width, height } = bitmap;
|
136
|
+
const offscreen = new OffscreenCanvas(width, height);
|
137
|
+
const ctx = offscreen.getContext("2d");
|
138
|
+
ctx?.drawImage(bitmap, 0, 0);
|
139
|
+
return ctx;
|
140
|
+
})
|
141
|
+
.then((ctx: OffscreenCanvasRenderingContext2D | null) => {
|
142
|
+
return ctx?.getImageData(0, 0, ctx?.canvas.width, ctx?.canvas.height);
|
143
|
+
});
|
144
|
+
}
|
145
|
+
|
128
146
|
static fromImageData(imageData: HDRImageData): Uint16Image {
|
129
147
|
const i = new Uint16Image(imageData.width, imageData.height);
|
130
148
|
if (imageData.colorSpace == "srgb") {
|
@@ -139,6 +157,16 @@ export class Uint16Image {
|
|
139
157
|
return i;
|
140
158
|
}
|
141
159
|
|
160
|
+
static async fromURL(url: URL): Promise<Uint16Image | undefined> {
|
161
|
+
return Uint16Image.loadSDRImageData(url).then(
|
162
|
+
(data: HDRImageData | undefined) => {
|
163
|
+
if (data !== undefined) {
|
164
|
+
return Uint16Image.fromImageData(data);
|
165
|
+
}
|
166
|
+
},
|
167
|
+
);
|
168
|
+
}
|
169
|
+
|
142
170
|
setImageData(imageData: HDRImageData): void {
|
143
171
|
this.width = imageData.width;
|
144
172
|
this.height = imageData.height;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import WebGPUBackend from 'three/addons/renderers/webgpu/WebGPUBackend.js';
|
2
|
-
import { GPUFeatureName, GPUTextureFormat
|
2
|
+
import { GPUFeatureName, GPUTextureFormat } from 'three/addons/renderers/webgpu/utils/WebGPUConstants.js';
|
3
3
|
|
4
4
|
class HDRWebGPUBackend extends WebGPUBackend {
|
5
5
|
|