@monogrid/gainmap-js 2.0.7 → 3.0.1

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.
@@ -1,12 +1,12 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.6
2
+ * @monogrid/gainmap-js v3.0.1
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
6
6
  (function (global, factory) {
7
7
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('three')) :
8
8
  typeof define === 'function' && define.amd ? define(['exports', 'three'], factory) :
9
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@monogrid/gainmap-js"] = {}, global.three));
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.encode = {}, global.three));
10
10
  })(this, (function (exports, three) { 'use strict';
11
11
 
12
12
  /**
@@ -153,23 +153,13 @@
153
153
  * @param type
154
154
  * @param renderer
155
155
  * @param camera
156
+ * @param renderTargetOptions
156
157
  * @returns
157
158
  */
158
- const canReadPixels = (type, renderer, camera) => {
159
+ const canReadPixels = (type, renderer, camera, renderTargetOptions) => {
159
160
  if (_canReadPixelsResult !== undefined)
160
161
  return _canReadPixelsResult;
161
- const testRT = new three.WebGLRenderTarget(1, 1, {
162
- type,
163
- colorSpace: three.LinearSRGBColorSpace,
164
- format: three.RGBAFormat,
165
- magFilter: three.LinearFilter,
166
- minFilter: three.LinearFilter,
167
- wrapS: three.RepeatWrapping,
168
- wrapT: three.RepeatWrapping,
169
- depthBuffer: false,
170
- stencilBuffer: false,
171
- generateMipmaps: true
172
- });
162
+ const testRT = new three.WebGLRenderTarget(1, 1, renderTargetOptions);
173
163
  renderer.setRenderTarget(testRT);
174
164
  const mesh = new three.Mesh(new three.PlaneGeometry(), new three.MeshBasicMaterial({ color: 0xffffff }));
175
165
  renderer.render(mesh, camera);
@@ -194,7 +184,8 @@
194
184
  * @param sourceTexture
195
185
  * @param renderer
196
186
  */
197
- constructor(width, height, type, colorSpace, material, renderer) {
187
+ constructor(options) {
188
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
198
189
  this._rendererIsDisposable = false;
199
190
  this._supportsReadPixels = true;
200
191
  /**
@@ -211,13 +202,29 @@
211
202
  }
212
203
  this._renderer.setRenderTarget(null);
213
204
  };
214
- this._width = width;
215
- this._height = height;
216
- this._type = type;
217
- this._colorSpace = colorSpace;
218
- this._material = material;
219
- if (renderer) {
220
- this._renderer = renderer;
205
+ this._width = options.width;
206
+ this._height = options.height;
207
+ this._type = options.type;
208
+ this._colorSpace = options.colorSpace;
209
+ const rtOptions = {
210
+ // fixed options
211
+ format: three.RGBAFormat,
212
+ depthBuffer: false,
213
+ stencilBuffer: false,
214
+ // user options
215
+ type: this._type, // set in class property
216
+ colorSpace: this._colorSpace, // set in class property
217
+ anisotropy: ((_a = options.renderTargetOptions) === null || _a === void 0 ? void 0 : _a.anisotropy) !== undefined ? (_b = options.renderTargetOptions) === null || _b === void 0 ? void 0 : _b.anisotropy : 1,
218
+ generateMipmaps: ((_c = options.renderTargetOptions) === null || _c === void 0 ? void 0 : _c.generateMipmaps) !== undefined ? (_d = options.renderTargetOptions) === null || _d === void 0 ? void 0 : _d.generateMipmaps : false,
219
+ magFilter: ((_e = options.renderTargetOptions) === null || _e === void 0 ? void 0 : _e.magFilter) !== undefined ? (_f = options.renderTargetOptions) === null || _f === void 0 ? void 0 : _f.magFilter : three.LinearFilter,
220
+ minFilter: ((_g = options.renderTargetOptions) === null || _g === void 0 ? void 0 : _g.minFilter) !== undefined ? (_h = options.renderTargetOptions) === null || _h === void 0 ? void 0 : _h.minFilter : three.LinearFilter,
221
+ samples: ((_j = options.renderTargetOptions) === null || _j === void 0 ? void 0 : _j.samples) !== undefined ? (_k = options.renderTargetOptions) === null || _k === void 0 ? void 0 : _k.samples : undefined,
222
+ wrapS: ((_l = options.renderTargetOptions) === null || _l === void 0 ? void 0 : _l.wrapS) !== undefined ? (_m = options.renderTargetOptions) === null || _m === void 0 ? void 0 : _m.wrapS : three.ClampToEdgeWrapping,
223
+ wrapT: ((_o = options.renderTargetOptions) === null || _o === void 0 ? void 0 : _o.wrapT) !== undefined ? (_p = options.renderTargetOptions) === null || _p === void 0 ? void 0 : _p.wrapT : three.ClampToEdgeWrapping
224
+ };
225
+ this._material = options.material;
226
+ if (options.renderer) {
227
+ this._renderer = options.renderer;
221
228
  }
222
229
  else {
223
230
  this._renderer = QuadRenderer.instantiateRenderer();
@@ -231,7 +238,7 @@
231
238
  this._camera.top = 0.5;
232
239
  this._camera.bottom = -0.5;
233
240
  this._camera.updateProjectionMatrix();
234
- if (!canReadPixels(this._type, this._renderer, this._camera)) {
241
+ if (!canReadPixels(this._type, this._renderer, this._camera, rtOptions)) {
235
242
  let alternativeType;
236
243
  switch (this._type) {
237
244
  case three.HalfFloatType:
@@ -250,18 +257,8 @@
250
257
  this._quad = new three.Mesh(new three.PlaneGeometry(), this._material);
251
258
  this._quad.geometry.computeBoundingBox();
252
259
  this._scene.add(this._quad);
253
- this._renderTarget = new three.WebGLRenderTarget(width, height, {
254
- type: this._type,
255
- colorSpace,
256
- format: three.RGBAFormat,
257
- magFilter: three.LinearFilter,
258
- minFilter: three.LinearMipMapLinearFilter,
259
- wrapS: three.RepeatWrapping,
260
- wrapT: three.RepeatWrapping,
261
- depthBuffer: false,
262
- stencilBuffer: false,
263
- generateMipmaps: true
264
- });
260
+ this._renderTarget = new three.WebGLRenderTarget(this.width, this.height, rtOptions);
261
+ this._renderTarget.texture.mapping = ((_q = options.renderTargetOptions) === null || _q === void 0 ? void 0 : _q.mapping) !== undefined ? (_r = options.renderTargetOptions) === null || _r === void 0 ? void 0 : _r.mapping : three.UVMapping;
265
262
  }
266
263
  /**
267
264
  * Instantiates a temporary renderer
@@ -294,10 +291,20 @@
294
291
  * Performs a readPixel operation in the renderTarget
295
292
  * and returns a DataTexture containing the read data
296
293
  *
294
+ * @params options
297
295
  * @returns
298
296
  */
299
- toDataTexture() {
300
- return new three.DataTexture(this.toArray(), this.width, this.height, three.RGBAFormat, this._type, three.UVMapping, three.RepeatWrapping, three.RepeatWrapping, three.LinearFilter, three.LinearMipMapLinearFilter, 1, three.LinearSRGBColorSpace);
297
+ toDataTexture(options) {
298
+ const returnValue = new three.DataTexture(
299
+ // fixed values
300
+ this.toArray(), this.width, this.height, three.RGBAFormat, this._type,
301
+ // user values
302
+ (options === null || options === void 0 ? void 0 : options.mapping) || three.UVMapping, (options === null || options === void 0 ? void 0 : options.wrapS) || three.ClampToEdgeWrapping, (options === null || options === void 0 ? void 0 : options.wrapT) || three.ClampToEdgeWrapping, (options === null || options === void 0 ? void 0 : options.magFilter) || three.LinearFilter, (options === null || options === void 0 ? void 0 : options.minFilter) || three.LinearFilter, (options === null || options === void 0 ? void 0 : options.anisotropy) || 1,
303
+ // fixed value
304
+ three.LinearSRGBColorSpace);
305
+ // set this afterwards, we can't set it in constructor
306
+ returnValue.generateMipmaps = (options === null || options === void 0 ? void 0 : options.generateMipmaps) !== undefined ? options === null || options === void 0 ? void 0 : options.generateMipmaps : false;
307
+ return returnValue;
301
308
  }
302
309
  /**
303
310
  * If using a disposable renderer, it will dispose it.
@@ -541,7 +548,7 @@ void main() {
541
548
  * @see {@link GainMapMetadata.hdrCapacityMax}
542
549
  * @remarks Logarithmic space
543
550
  */
544
- get hdrCapacityMax() { return Math.min(Math.max(0, this.gainMapMax[0]), Math.max(0, this.gainMapMax[1]), Math.max(0, this.gainMapMax[2])); }
551
+ get hdrCapacityMax() { return Math.max(Math.max(0, this.gainMapMax[0]), Math.max(0, this.gainMapMax[1]), Math.max(0, this.gainMapMax[2])); }
545
552
  }
546
553
 
547
554
  /**
@@ -559,7 +566,15 @@ void main() {
559
566
  sdr: sdr.renderTarget.texture,
560
567
  hdr: dataTexture
561
568
  });
562
- const quadRenderer = new QuadRenderer(dataTexture.image.width, dataTexture.image.height, three.UnsignedByteType, three.LinearSRGBColorSpace, material, renderer);
569
+ const quadRenderer = new QuadRenderer({
570
+ width: dataTexture.image.width,
571
+ height: dataTexture.image.height,
572
+ type: three.UnsignedByteType,
573
+ colorSpace: three.LinearSRGBColorSpace,
574
+ material,
575
+ renderer,
576
+ renderTargetOptions: params.renderTargetOptions
577
+ });
563
578
  try {
564
579
  quadRenderer.render();
565
580
  }
@@ -782,11 +797,20 @@ void main() {
782
797
  * @param hdrTexture The HDR image to be rendered
783
798
  * @param renderer (optional) WebGLRenderer to use during the rendering, a disposable renderer will be create and destroyed if this is not provided.
784
799
  * @param toneMapping (optional) Tone mapping to be applied to the SDR Rendition
800
+ * @param renderTargetOptions (optional) Options to use when creating the output renderTarget
785
801
  * @throws {Error} if the WebGLRenderer fails to render the SDR image
786
802
  */
787
- const getSDRRendition = (hdrTexture, renderer, toneMapping) => {
803
+ const getSDRRendition = (hdrTexture, renderer, toneMapping, renderTargetOptions) => {
788
804
  hdrTexture.needsUpdate = true;
789
- const quadRenderer = new QuadRenderer(hdrTexture.image.width, hdrTexture.image.height, three.UnsignedByteType, three.SRGBColorSpace, new SDRMaterial({ map: hdrTexture, toneMapping }), renderer);
805
+ const quadRenderer = new QuadRenderer({
806
+ width: hdrTexture.image.width,
807
+ height: hdrTexture.image.height,
808
+ type: three.UnsignedByteType,
809
+ colorSpace: three.SRGBColorSpace,
810
+ material: new SDRMaterial({ map: hdrTexture, toneMapping }),
811
+ renderer,
812
+ renderTargetOptions
813
+ });
790
814
  try {
791
815
  quadRenderer.render();
792
816
  }
@@ -853,7 +877,7 @@ void main() {
853
877
  const encode = (params) => {
854
878
  const { image, renderer } = params;
855
879
  const dataTexture = getDataTexture(image);
856
- const sdr = getSDRRendition(dataTexture, renderer, params.toneMapping);
880
+ const sdr = getSDRRendition(dataTexture, renderer, params.toneMapping, params.renderTargetOptions);
857
881
  const gainMapRenderer = getGainMap({
858
882
  ...params,
859
883
  image: dataTexture,
@@ -865,7 +889,7 @@ void main() {
865
889
  gainMap: gainMapRenderer,
866
890
  hdr: dataTexture,
867
891
  getMetadata: () => {
868
- const meta = {
892
+ return {
869
893
  gainMapMax: gainMapRenderer.material.gainMapMax,
870
894
  gainMapMin: gainMapRenderer.material.gainMapMin,
871
895
  gamma: gainMapRenderer.material.gamma,
@@ -874,7 +898,6 @@ void main() {
874
898
  offsetHdr: gainMapRenderer.material.offsetHdr,
875
899
  offsetSdr: gainMapRenderer.material.offsetSdr
876
900
  };
877
- return meta;
878
901
  }
879
902
  };
880
903
  };
@@ -999,6 +1022,10 @@ precision mediump float;
999
1022
  #define COMPARE_FUNCTION max
1000
1023
  #endif
1001
1024
 
1025
+ #ifndef INITIAL_VALUE
1026
+ #define INITIAL_VALUE 0
1027
+ #endif
1028
+
1002
1029
  uniform sampler2D map;
1003
1030
  uniform vec2 u_srcResolution;
1004
1031
 
@@ -1014,7 +1041,8 @@ void main() {
1014
1041
  // uv for first pixel in cell. +0.5 for center of pixel
1015
1042
  vec2 uv = (srcPixel + 0.5) * onePixel;
1016
1043
 
1017
- vec4 resultColor = vec4(0);
1044
+ vec4 resultColor = vec4(INITIAL_VALUE);
1045
+
1018
1046
  for (int y = 0; y < CELL_SIZE; ++y) {
1019
1047
  for (int x = 0; x < CELL_SIZE; ++x) {
1020
1048
  resultColor = COMPARE_FUNCTION(resultColor, texture2D(map, uv + vec2(x, y) * onePixel));
@@ -1046,14 +1074,22 @@ void main() {
1046
1074
  },
1047
1075
  defines: {
1048
1076
  CELL_SIZE: cellSize,
1049
- COMPARE_FUNCTION: mode
1077
+ COMPARE_FUNCTION: mode,
1078
+ INITIAL_VALUE: mode === 'max' ? 0 : 65504 // max half float value
1050
1079
  }
1051
1080
  });
1052
1081
  srcTex.needsUpdate = true;
1053
1082
  mat.needsUpdate = true;
1054
1083
  let w = srcTex.image.width;
1055
1084
  let h = srcTex.image.height;
1056
- const quadRenderer = new QuadRenderer(w, h, srcTex.type, srcTex.colorSpace, mat, renderer);
1085
+ const quadRenderer = new QuadRenderer({
1086
+ width: w,
1087
+ height: h,
1088
+ type: srcTex.type,
1089
+ colorSpace: srcTex.colorSpace,
1090
+ material: mat,
1091
+ renderer
1092
+ });
1057
1093
  const frameBuffers = [];
1058
1094
  while (w > 1 || h > 1) {
1059
1095
  w = Math.max(1, (w + cellSize - 1) / cellSize | 0);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.6
2
+ * @monogrid/gainmap-js v3.0.1
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.6
2
+ * @monogrid/gainmap-js v3.0.1
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.6
2
+ * @monogrid/gainmap-js v3.0.1
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
6
- import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-ftl_lJMx.js';
6
+ import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-Gkwpb-h5.js';
7
7
 
8
8
  var lib$1;
9
9
  var hasRequiredLib$1;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.6
2
+ * @monogrid/gainmap-js v3.0.1
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
package/dist/worker.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.6
2
+ * @monogrid/gainmap-js v3.0.1
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
6
- import { g as getDefaultExportFromCjs } from './_commonjsHelpers-ftl_lJMx.js';
7
- import { c as compress } from './compress-MvOX-rlz.js';
6
+ import { g as getDefaultExportFromCjs } from './_commonjsHelpers-Gkwpb-h5.js';
7
+ import { c as compress } from './compress-6L6-d1aM.js';
8
8
 
9
9
  var isPromise$2 = {exports: {}};
10
10
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.6
2
+ * @monogrid/gainmap-js v3.0.1
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monogrid/gainmap-js",
3
- "version": "2.0.7",
3
+ "version": "3.0.1",
4
4
  "description": "A Javascript (TypeScript) Port of Adobe Gainmap Technology for storing HDR Images using an SDR Image + a gain map",
5
5
  "homepage": "https://github.com/MONOGRID/gainmap-js#readme",
6
6
  "repository": {
@@ -76,32 +76,37 @@
76
76
  },
77
77
  "scripts": {
78
78
  "build": "rollup -c",
79
- "dev": "rollup -c -w",
80
- "test": "jest",
81
- "pretest": "npm run build",
79
+ "dev": "concurrently -n rollup,servez -c magenta,green \"rollup -c -w\" \"servez\"",
80
+ "start": "concurrently -n rollup,servez -c magenta,green \"rollup -c -w\" \"servez\"",
81
+ "test": "playwright test",
82
+ "test:startserver": "rollup -c && servez",
83
+ "test:report-coverage": "nyc report --reporter=text --reporter=cobertura --reporter=html --reporter=json-summary",
84
+ "test:docker": "docker run --rm --network host -v $(pwd):/work -w /work -it -u $(id -u ${USER}):$(id -g ${USER}) mcr.microsoft.com/playwright:v1.40.0-jammy /bin/bash",
85
+ "test:codegen": "playwright codegen http://localhost:8080",
86
+ "prepack": "npm run build",
82
87
  "check": "concurrently -c auto npm:check:*",
83
88
  "check:typecheck-src": "tsc -p src",
84
89
  "check:eslint-src": "eslint \"src/**/*.ts\"",
85
90
  "check:typecheck-examples": "tsc -p examples",
86
91
  "check:eslint-examples": "eslint \"examples/**/*.{ts,html}\"",
87
92
  "check:typecheck-tests": "tsc -p tests",
88
- "check:eslint-tests": "eslint \"tests/**/*.{ts,html}\"",
89
- "ci:test": "JEST_JUNIT_OUTPUT_DIR=reports jest --ci --reporters=default --reporters=jest-junit",
93
+ "check:eslint-tests": "eslint \"tests/**/*.ts\"",
90
94
  "ci:check": "concurrently npm:ci:check:*",
91
95
  "ci:check:typecheck-src": "tsc --pretty false > reports/typecheck.log",
92
96
  "ci:check:eslint-src": "eslint --format json --output-file reports/eslint-src.json \"src/**/*.ts\"",
93
97
  "ci:check:typecheck-examples": "tsc --pretty false -p examples > reports/typecheck-examples.log",
94
98
  "ci:check:eslint-examples": "eslint --format json --output-file reports/eslint-examples.json \"examples/**/*.{ts,html}\"",
95
99
  "ci:check:typecheck-tests": "tsc --pretty false -p tests > reports/typecheck-tests.log",
96
- "ci:check:eslint-tests": "eslint --format json --output-file reports/eslint-tests.json \"tests/**/*.{ts,html}\""
100
+ "ci:check:eslint-tests": "eslint --format json --output-file reports/eslint-tests.json \"tests/**/*.ts\""
97
101
  },
98
102
  "peerDependencies": {
99
- "three": ">= 0.157.0 < 0.159.0"
103
+ "three": ">= 0.159.0"
100
104
  },
101
105
  "dependencies": {
102
106
  "promise-worker-transferable": "^1.0.4"
103
107
  },
104
108
  "devDependencies": {
109
+ "@playwright/test": "^1.40.1",
105
110
  "@rollup/plugin-commonjs": "^25.0.7",
106
111
  "@rollup/plugin-json": "^6.0.1",
107
112
  "@rollup/plugin-node-resolve": "^15.2.3",
@@ -110,15 +115,13 @@
110
115
  "@semantic-release/changelog": "^6.0.3",
111
116
  "@semantic-release/commit-analyzer": "^11.1.0",
112
117
  "@semantic-release/git": "github:semantic-release/git",
113
- "@semantic-release/github": "^9.2.3",
118
+ "@semantic-release/github": "^9.2.4",
114
119
  "@semantic-release/npm": "^11.0.1",
115
120
  "@semantic-release/release-notes-generator": "^12.1.0",
116
- "@types/jest": "^29.5.8",
117
121
  "@types/node": "^20.9.0",
118
122
  "@types/three": "^0.158.2",
119
- "@typescript-eslint/eslint-plugin": "^6.11.0",
120
- "@typescript-eslint/parser": "^6.11.0",
121
- "babel-jest": "^29.7.0",
123
+ "@typescript-eslint/eslint-plugin": "^6.13.1",
124
+ "@typescript-eslint/parser": "^6.13.1",
122
125
  "concurrently": "^8.2.2",
123
126
  "conventional-changelog-conventionalcommits": "^7.0.2",
124
127
  "cz-conventional-changelog": "^3.3.0",
@@ -128,27 +131,25 @@
128
131
  "eslint-plugin-compat": "^4.2.0",
129
132
  "eslint-plugin-html": "^7.1.0",
130
133
  "eslint-plugin-import": "^2.29.0",
131
- "eslint-plugin-jest-extended": "^2.0.0",
132
134
  "eslint-plugin-n": "^16.3.1",
133
135
  "eslint-plugin-promise": "^6.0.0",
134
136
  "eslint-plugin-quasar": "^1.1.0",
135
137
  "eslint-plugin-simple-import-sort": "^10.0.0",
136
138
  "eslint-plugin-unused-imports": "^3.0.0",
137
- "jest": "^29.7.0",
138
- "jest-environment-jsdom": "^29.7.0",
139
- "jest-extended": "^4.0.2",
140
- "jest-junit": "^16.0.0",
141
- "puppeteer": "^21.5.2",
142
- "rollup": "^4.5.0",
139
+ "nyc": "^15.1.0",
140
+ "rollup": "^4.6.1",
143
141
  "rollup-plugin-copy": "^3.5.0",
142
+ "rollup-plugin-delete": "^2.0.0",
143
+ "rollup-plugin-istanbul": "^5.0.0",
144
144
  "rollup-plugin-license": "^3.2.0",
145
145
  "semantic-release": "^22.0.8",
146
- "three": "^0.158.0",
147
- "ts-jest": "^29.1.1",
148
- "typedoc": "^0.25.3",
146
+ "servez": "^2.1.2",
147
+ "sharp": "^0.33.0",
148
+ "three": "^0.159.0",
149
+ "typedoc": "^0.25.4",
149
150
  "typedoc-github-wiki-theme": "^1.1.0",
150
151
  "typedoc-plugin-markdown": "^3.17.1",
151
- "typescript": "^5.2.2"
152
+ "typescript": "^5.3.2"
152
153
  },
153
154
  "browserslist": [
154
155
  "> 1%, not dead, not ie 11, not op_mini all"