@monogrid/gainmap-js 3.1.0 → 3.3.0

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.
Files changed (87) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/CODE_OF_CONDUCT.md +1 -1
  3. package/CONTRIBUTING.md +1 -1
  4. package/README.md +113 -57
  5. package/dist/Loader-CsjVTcg5.js +424 -0
  6. package/dist/Loader-D4XqFES7.js +5 -0
  7. package/dist/{QuadRenderer-DuOPRGA4.js → QuadRenderer-BqJ2Q8P5.js} +39 -30
  8. package/dist/QuadRenderer-De5PMMtY.js +5 -0
  9. package/dist/{_commonjsHelpers-DeBGiDfT.js → _commonjsHelpers-C2Rq7Bzs.js} +2 -2
  10. package/dist/_commonjsHelpers-FnzxO7yL.js +5 -0
  11. package/dist/compress-HAw5HoXG.js +5 -0
  12. package/dist/{compress-B6OswAu8.js → compress-bMJEJ5JM.js} +4 -3
  13. package/dist/core/QuadRenderer.d.ts +2 -2
  14. package/dist/core/get-data-texture.d.ts +4 -3
  15. package/dist/core/types.d.ts +7 -1
  16. package/dist/decode/index.d.ts +1 -11
  17. package/dist/decode/shared/Loader.d.ts +59 -0
  18. package/dist/decode/shared/decode.d.ts +24 -0
  19. package/dist/decode/{extract.d.ts → shared/extract.d.ts} +4 -4
  20. package/dist/decode/shared/index.d.ts +8 -0
  21. package/dist/decode/shared/types.d.ts +53 -0
  22. package/dist/decode/{utils → shared/utils}/MPFExtractor.d.ts +1 -1
  23. package/dist/decode/{utils → shared/utils}/extractXMP.d.ts +1 -1
  24. package/dist/decode/{decode.d.ts → webgl/decode.d.ts} +6 -6
  25. package/dist/decode/webgl/index.d.ts +8 -0
  26. package/dist/decode/{loaders → webgl/loaders}/GainMapLoader.d.ts +5 -6
  27. package/dist/decode/{loaders → webgl/loaders}/HDRJPGLoader.d.ts +6 -7
  28. package/dist/decode/webgl/loaders/LoaderBaseWebGL.d.ts +20 -0
  29. package/dist/decode/{materials → webgl/materials}/GainMapDecoderMaterial.d.ts +2 -2
  30. package/dist/decode/webgpu/core/QuadRenderer.d.ts +153 -0
  31. package/dist/decode/webgpu/decode.d.ts +60 -0
  32. package/dist/decode/webgpu/index.d.ts +8 -0
  33. package/dist/decode/webgpu/loaders/GainMapLoader.d.ts +69 -0
  34. package/dist/decode/webgpu/loaders/HDRJPGLoader.d.ts +65 -0
  35. package/dist/decode/webgpu/loaders/LoaderBaseWebGPU.d.ts +20 -0
  36. package/dist/decode/webgpu/materials/GainMapDecoderMaterial.d.ts +78 -0
  37. package/dist/decode.js +45 -426
  38. package/dist/decode.min.js +5 -0
  39. package/dist/decode.umd.cjs +360 -314
  40. package/dist/decode.umd.min.cjs +5 -0
  41. package/dist/decode.webgpu.js +814 -0
  42. package/dist/decode.webgpu.min.js +5 -0
  43. package/dist/decode.webgpu.umd.cjs +1244 -0
  44. package/dist/decode.webgpu.umd.min.cjs +5 -0
  45. package/dist/encode/encode-and-compress.d.ts +4 -4
  46. package/dist/encode/encode.d.ts +3 -3
  47. package/dist/encode/find-texture-min-max.d.ts +4 -3
  48. package/dist/encode/types.d.ts +6 -5
  49. package/dist/encode.js +33 -12
  50. package/dist/encode.min.js +5 -0
  51. package/dist/encode.umd.cjs +70 -39
  52. package/dist/encode.umd.min.cjs +5 -0
  53. package/dist/libultrahdr/encode-jpeg-metadata.d.ts +6 -6
  54. package/dist/libultrahdr/jpeg-assembler.d.ts +41 -0
  55. package/dist/libultrahdr/jpeg-markers.d.ts +47 -0
  56. package/dist/libultrahdr/mpf-generator.d.ts +20 -0
  57. package/dist/libultrahdr/xmp-generator.d.ts +33 -0
  58. package/dist/libultrahdr.d.ts +0 -3
  59. package/dist/libultrahdr.js +548 -6598
  60. package/dist/libultrahdr.min.js +5 -0
  61. package/dist/libultrahdr.umd.cjs +633 -6686
  62. package/dist/libultrahdr.umd.min.cjs +5 -0
  63. package/dist/third-party.txt +301 -0
  64. package/dist/worker-interface.js +74 -64
  65. package/dist/worker-interface.min.js +5 -0
  66. package/dist/worker-interface.umd.cjs +73 -63
  67. package/dist/worker-interface.umd.min.cjs +5 -0
  68. package/dist/worker.js +103 -88
  69. package/dist/worker.min.js +5 -0
  70. package/dist/worker.umd.cjs +105 -89
  71. package/dist/worker.umd.min.cjs +5 -0
  72. package/package.json +79 -72
  73. package/dist/decode/loaders/LoaderBase.d.ts +0 -45
  74. package/dist/decode/types.d.ts +0 -42
  75. package/dist/libultrahdr/decode-jpeg-metadata.d.ts +0 -28
  76. package/dist/libultrahdr/library.d.ts +0 -9
  77. package/dist/libultrahdr-esm.wasm +0 -0
  78. package/libultrahdr-wasm/build/libultrahdr-debug.js +0 -7156
  79. package/libultrahdr-wasm/build/libultrahdr-debug.wasm +0 -0
  80. package/libultrahdr-wasm/build/libultrahdr-esm.js +0 -6633
  81. package/libultrahdr-wasm/build/libultrahdr-esm.wasm +0 -0
  82. package/libultrahdr-wasm/build/libultrahdr.d.ts +0 -30
  83. package/libultrahdr-wasm/build/libultrahdr.js +0 -6591
  84. package/libultrahdr-wasm/build/libultrahdr.wasm +0 -0
  85. /package/dist/decode/{errors → shared/errors}/GainMapNotFoundError.d.ts +0 -0
  86. /package/dist/decode/{errors → shared/errors}/XMPMetadataNotFoundError.d.ts +0 -0
  87. /package/dist/decode/{utils → shared/utils}/get-html-image-from-blob.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [3.3.0](https://github.com/MONOGRID/gainmap-js/compare/v3.2.0...v3.3.0) (2025-11-22)
2
+
3
+
4
+ ### Features
5
+
6
+ * removes wasm dependency and implements pure-js JPG encoder ([#73](https://github.com/MONOGRID/gainmap-js/issues/73)) ([00b6e43](https://github.com/MONOGRID/gainmap-js/commit/00b6e43f2ada89e39d76491017ff173574a20873))
7
+
8
+ # [3.2.0](https://github.com/MONOGRID/gainmap-js/compare/v3.1.0...v3.2.0) (2025-11-17)
9
+
10
+
11
+ ### Features
12
+
13
+ * WebGPU support ([#72](https://github.com/MONOGRID/gainmap-js/issues/72)) ([0d85bec](https://github.com/MONOGRID/gainmap-js/commit/0d85becd0e8b79fc5adfb5bbd757e35e032ee77e))
14
+
1
15
  # [3.1.0](https://github.com/MONOGRID/gainmap-js/compare/v3.0.6...v3.1.0) (2024-12-05)
2
16
 
3
17
 
@@ -60,7 +60,7 @@ representative at an online or offline event.
60
60
 
61
61
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
62
  reported to the community leaders responsible for enforcement at
63
- rnd@monogrid.com.
63
+ gainmap@monogrid.com.
64
64
  All complaints will be reviewed and investigated promptly and fairly.
65
65
 
66
66
  All community leaders are obligated to respect the privacy and security of the
package/CONTRIBUTING.md CHANGED
@@ -81,7 +81,7 @@ A good bug report shouldn't leave others needing to chase you up for more inform
81
81
  <!-- omit in toc -->
82
82
  #### How Do I Submit a Good Bug Report?
83
83
 
84
- > You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by email to <rnd@monogrid.com>.
84
+ > You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by email to <gainmap@monogrid.com>.
85
85
  <!-- You may add a PGP key to allow the messages to be sent encrypted as well. -->
86
86
 
87
87
  We use GitHub issues to track bugs and errors. If you run into an issue with the project:
package/README.md CHANGED
@@ -3,15 +3,23 @@
3
3
 
4
4
  A Javascript (TypeScript) Encoder/Decoder Implementation of Adobe's Gain Map Technology for storing HDR Images using an SDR Image + a "Gain map"
5
5
 
6
- > :warning: This library **is primarily intended** for encoding and decoding gain map images for the [three.js](https://github.com/mrdoob/three.js/) 3D Library
6
+ > :warning: This library is intended for encoding and decoding gain map images for the [three.js](https://github.com/mrdoob/three.js/) 3D Library
7
7
  >
8
8
  > It can be used for general encode/decode of gain maps but it depends on the three.js library which, in itself, is quite heavy if you only use it to encode/decode gain maps.
9
9
 
10
+ ## Share Your Project!
11
+ Have you built something awesome using this library? We’d love to see what you’ve created!
12
+ Whether it’s a small demo or a full-scale application, your project can inspire others and help improve the library. Please share your work in one of these ways:
13
+ * GitHub Issues: [Open a new issue](https://github.com/MONOGRID/gainmap-js/issues/new) in this repository with a brief description, screenshots, and links to your project.
14
+ * Email: Send us an email at gainmap@monogrid.com with your project details.
15
+ Your contributions and creative ideas make our community stronger. We can’t wait to see what you build!
16
+
10
17
  ## Live Demo
11
18
 
12
- https://monogrid.github.io/gainmap-js/
19
+ * [WebGPU Version](https://monogrid.github.io/gainmap-js/webgpu.html)
20
+ * [Legacy WebGL Version](https://monogrid.github.io/gainmap-js/)
13
21
 
14
- Compares loading:
22
+ Both compares loading:
15
23
  1. a `JPEG` file with embedded gain map data
16
24
  2. a `webp` sdr file + a `webp` gain map + metadata JSON
17
25
  3. a comparable size `.hdr` file for comparison
@@ -80,6 +88,7 @@ import {
80
88
  const renderer = new WebGLRenderer()
81
89
 
82
90
  const loader = new HDRJPGLoader(renderer)
91
+ .setRenderTargetOptions({ mapping: EquirectangularReflectionMapping })
83
92
 
84
93
  const result = await loader.loadAsync('gainmap.jpeg')
85
94
  // `result` can be used to populate a Texture
@@ -99,7 +108,6 @@ renderer.render(scene, new PerspectiveCamera())
99
108
  // it was previously needed to convert it
100
109
  // to a DataTexture with `result.toDataTexture()`
101
110
  scene.background = result.renderTarget.texture
102
- scene.background.mapping = EquirectangularReflectionMapping
103
111
 
104
112
  // result must be manually disposed
105
113
  // when you are done using it
@@ -130,6 +138,7 @@ import {
130
138
  const renderer = new WebGLRenderer()
131
139
 
132
140
  const loader = new GainMapLoader(renderer)
141
+ .setRenderTargetOptions({ mapping: EquirectangularReflectionMapping })
133
142
 
134
143
  const result = await loader.loadAsync(['sdr.jpeg', 'gainmap.jpeg', 'metadata.json'])
135
144
  // `result` can be used to populate a Texture
@@ -149,13 +158,108 @@ renderer.render(scene, new PerspectiveCamera())
149
158
  // it was previously needed to convert it
150
159
  // to a DataTexture with `result.toDataTexture()`
151
160
  scene.background = result.renderTarget.texture
152
- scene.background.mapping = EquirectangularReflectionMapping
153
161
 
154
162
  // result must be manually disposed
155
163
  // when you are done using it
156
164
  result.dispose()
157
165
  ```
158
166
 
167
+ ### Decoding with WebGPU
168
+
169
+ > NOTE: WebGPU decoding requires three.js r163 or higher and a browser that supports WebGPU
170
+
171
+ The library provides WebGPU-accelerated decoding through the `@monogrid/gainmap-js/webgpu` entry point. WebGPU decoding uses Three.js Shading Language (TSL) and offers improved performance and modern GPU architecture support.
172
+
173
+ #### Using a single JPEG with embedded Gain map Metadata (WebGPU)
174
+
175
+ ```ts
176
+ import { HDRJPGLoader } from '@monogrid/gainmap-js/webgpu'
177
+ import {
178
+ EquirectangularReflectionMapping,
179
+ Mesh,
180
+ MeshBasicMaterial,
181
+ PerspectiveCamera,
182
+ PlaneGeometry,
183
+ Scene,
184
+ WebGPURenderer
185
+ } from 'three/webgpu'
186
+
187
+ const renderer = new WebGPURenderer()
188
+ await renderer.init()
189
+
190
+ const loader = new HDRJPGLoader(renderer)
191
+ .setRenderTargetOptions({ mapping: EquirectangularReflectionMapping })
192
+
193
+ const result = await loader.loadAsync('gainmap.jpeg')
194
+ // `result` can be used to populate a Texture
195
+
196
+ const scene = new Scene()
197
+ const mesh = new Mesh(
198
+ new PlaneGeometry(),
199
+ new MeshBasicMaterial({ map: result.renderTarget.texture })
200
+ )
201
+ scene.add(mesh)
202
+ renderer.render(scene, new PerspectiveCamera())
203
+
204
+ // Starting from three.js r159
205
+ // `result.renderTarget.texture` can
206
+ // also be used as Equirectangular scene background
207
+ scene.background = result.renderTarget.texture
208
+
209
+ // result must be manually disposed
210
+ // when you are done using it
211
+ result.dispose()
212
+ ```
213
+
214
+ #### Using separate files (WebGPU)
215
+
216
+ ```ts
217
+ import { GainMapLoader } from '@monogrid/gainmap-js/webgpu'
218
+ import {
219
+ EquirectangularReflectionMapping,
220
+ Mesh,
221
+ MeshBasicMaterial,
222
+ PerspectiveCamera,
223
+ PlaneGeometry,
224
+ Scene,
225
+ WebGPURenderer
226
+ } from 'three/webgpu'
227
+
228
+ const renderer = new WebGPURenderer()
229
+ await renderer.init()
230
+
231
+ const loader = new GainMapLoader(renderer)
232
+ .setRenderTargetOptions({ mapping: EquirectangularReflectionMapping })
233
+
234
+ const result = await loader.loadAsync(['sdr.jpeg', 'gainmap.jpeg', 'metadata.json'])
235
+ // `result` can be used to populate a Texture
236
+
237
+ const scene = new Scene()
238
+ const mesh = new Mesh(
239
+ new PlaneGeometry(),
240
+ new MeshBasicMaterial({ map: result.renderTarget.texture })
241
+ )
242
+ scene.add(mesh)
243
+ renderer.render(scene, new PerspectiveCamera())
244
+
245
+ // Starting from three.js r159
246
+ // `result.renderTarget.texture` can
247
+ // also be used as Equirectangular scene background
248
+ scene.background = result.renderTarget.texture
249
+
250
+ // result must be manually disposed
251
+ // when you are done using it
252
+ result.dispose()
253
+ ```
254
+
255
+ #### Key differences between WebGL and WebGPU
256
+
257
+ 1. **Import path**: Use `@monogrid/gainmap-js/webgpu` instead of `@monogrid/gainmap-js`
258
+ 2. **Three.js imports**: Use `three/webgpu` instead of `three`
259
+ 3. **Renderer**: Use `WebGPURenderer` instead of `WebGLRenderer`
260
+ 4. **Renderer initialization**: Call `await renderer.init()` before using WebGPU renderer
261
+ 5. **Async decoding**: The `decode()` function is async in WebGPU
262
+
159
263
  ### Encoding
160
264
 
161
265
  Encoding a Gain map starting from an EXR file.
@@ -212,7 +316,7 @@ const metadata = encodingResult.getMetadata()
212
316
 
213
317
  // embed the compressed images + metadata into a single
214
318
  // JPEG file
215
- const jpeg = await encodeJPEGMetadata({
319
+ const jpeg = encodeJPEGMetadata({
216
320
  ...encodingResult,
217
321
  ...metadata,
218
322
  sdr,
@@ -246,62 +350,14 @@ module.exports = defineConfig({
246
350
  ```
247
351
 
248
352
 
249
- ## Building with full encoding support (libultrahdr-wasm)
250
-
251
- Clone the repository with git submodules recursively:
252
- ```bash
253
- $ git clone --recurse-submodules git@github.com:MONOGRID/gainmap-js.git
254
- ```
255
-
256
- Proceed to build the libultrahdr-wasm module following the [documentation found here](https://github.com/MONOGRID/libultrahdr-wasm#building), here's a quick summary
257
-
258
- ```bash
259
- $ cd gainmap-js/libultrahdr-wasm/
260
- ```
261
- Create a meson "cross compile config" named em.txt and place the following content inside:
262
- ```ini
263
- [binaries]
264
- c = 'emcc'
265
- cpp = 'em++'
266
- ar = 'emar'
267
- nm = 'emnm'
268
-
269
- [host_machine]
270
- system = 'emscripten'
271
- cpu_family = 'wasm32'
272
- cpu = 'wasm32'
273
- endian = 'little'
274
- ```
275
- Then execute
276
-
277
- ```bash
278
- $ meson setup build --cross-file=em.txt
279
- $ meson compile -C build
280
- ```
281
-
282
- After compiling the WASM, head back to the main repository
283
-
284
- ```bash
285
- $ cd ..
286
- $ npm i
287
- $ npm run build
288
- ```
289
-
290
- ## Building with no encoding support (requires no wasm)
291
-
292
- > :warning: Building the library with decode only capabilities will not allow to run playwright e2e tests with `npm run test`
293
- > this method should only be used by people who would like to customize the "decoding" part of the library but are unable to build the WASM module for some reason (emscripten can be tricky sometimes, I've been there)
353
+ ## Building
294
354
 
295
- Clone the repository normally:
355
+ Clone the repository:
296
356
  ```bash
297
357
  $ git clone git@github.com:MONOGRID/gainmap-js.git
298
358
  $ cd gainmap-js
299
359
  $ npm i
300
- ```
301
-
302
- build with
303
- ```bash
304
- $ npm run build --config rollup.config.decodeonly.mjs
360
+ $ npm run build
305
361
  ```
306
362
 
307
363