@monogrid/gainmap-js 2.0.6 → 3.0.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,28 @@
1
+ # [3.0.0](https://github.com/MONOGRID/gainmap-js/compare/v2.0.7...v3.0.0) (2023-11-29)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **loaders:** properly catches render errors and calls onError callback ([b9bcdd1](https://github.com/MONOGRID/gainmap-js/commit/b9bcdd127576fa61c6ee92c876f4845cd80b4d34)), closes [#16](https://github.com/MONOGRID/gainmap-js/issues/16)
7
+
8
+
9
+ ### Features
10
+
11
+ * **core:** disables default mipmap generation, enables user to specify renderTarget (and toDataTexture) options ([147d278](https://github.com/MONOGRID/gainmap-js/commit/147d2783224cb0a2039d762abf4e4b972b0e86da)), closes [#14](https://github.com/MONOGRID/gainmap-js/issues/14) [#15](https://github.com/MONOGRID/gainmap-js/issues/15)
12
+
13
+
14
+ ### BREAKING CHANGES
15
+
16
+ * **core:** `generateMipmaps` is no longer `true` by default, both `minFilter` is no longer `LinearMipMapLinearFilter` by default but `LinearFilter`, `wrapS` and `warpT` are no longer `RepeatWrapping` by default but `ClampToEdgeWrapping`
17
+
18
+ ## [2.0.7](https://github.com/MONOGRID/gainmap-js/compare/v2.0.6...v2.0.7) (2023-11-23)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * **core:** QuadRenderer dispose method now properly disposes of its internal resources ([#13](https://github.com/MONOGRID/gainmap-js/issues/13)) ([8e4473d](https://github.com/MONOGRID/gainmap-js/commit/8e4473da77732080de24f98dd271fecda06f9e53))
24
+ * **HDRJPGLoader:** renders (and returns) an SDR image when provided with a normal jpeg file ([#12](https://github.com/MONOGRID/gainmap-js/issues/12)) ([5222151](https://github.com/MONOGRID/gainmap-js/commit/5222151e6b5c95df79f1c4085cf36f30bd9c2dc4))
25
+
1
26
  ## [2.0.6](https://github.com/MONOGRID/gainmap-js/compare/v2.0.5...v2.0.6) (2023-11-20)
2
27
 
3
28
 
package/README.md CHANGED
@@ -79,7 +79,7 @@ const renderer = new WebGLRenderer()
79
79
 
80
80
  const loader = new HDRJPGLoader(renderer)
81
81
 
82
- const result = loader.load('gainmap.jpeg')
82
+ const result = await loader.loadAsync('gainmap.jpeg')
83
83
  // `result` can be used to populate a Texture
84
84
 
85
85
  const scene = new Scene()
@@ -99,6 +99,11 @@ scene.background = result.toDataTexture()
99
99
  scene.background.mapping = EquirectangularReflectionMapping
100
100
  scene.background.minFilter = LinearFilter
101
101
 
102
+
103
+ // result must be manually disposed
104
+ // when you are done using it
105
+ result.dispose()
106
+
102
107
  ```
103
108
 
104
109
  ### Using separate files
@@ -127,7 +132,7 @@ const renderer = new WebGLRenderer()
127
132
 
128
133
  const loader = new GainMapLoader(renderer)
129
134
 
130
- const result = loader.load(['sdr.jpeg', 'gainmap.jpeg', 'metadata.json'])
135
+ const result = await loader.loadAsync(['sdr.jpeg', 'gainmap.jpeg', 'metadata.json'])
131
136
  // `result` can be used to populate a Texture
132
137
 
133
138
  const scene = new Scene()
@@ -147,6 +152,9 @@ scene.background = result.toDataTexture()
147
152
  scene.background.mapping = EquirectangularReflectionMapping
148
153
  scene.background.minFilter = LinearFilter
149
154
 
155
+ // result must be manually disposed
156
+ // when you are done using it
157
+ result.dispose()
150
158
  ```
151
159
 
152
160
  ### Encoding
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.5
2
+ * @monogrid/gainmap-js v2.0.7
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
6
- import { Scene, OrthographicCamera, HalfFloatType, FloatType, Mesh, PlaneGeometry, WebGLRenderTarget, RGBAFormat, LinearFilter, LinearMipMapLinearFilter, RepeatWrapping, WebGLRenderer, DataTexture, UVMapping, LinearSRGBColorSpace, IntType, ShortType, ByteType, UnsignedIntType, UnsignedByteType, MeshBasicMaterial } from 'three';
6
+ import { RGBAFormat, LinearFilter, ClampToEdgeWrapping, Scene, OrthographicCamera, HalfFloatType, FloatType, Mesh, PlaneGeometry, WebGLRenderTarget, UVMapping, WebGLRenderer, DataTexture, LinearSRGBColorSpace, ShaderMaterial, Texture, IntType, ShortType, ByteType, UnsignedIntType, UnsignedByteType, MeshBasicMaterial } from 'three';
7
7
 
8
8
  const getBufferForType = (type, width, height) => {
9
9
  let out;
@@ -44,23 +44,13 @@ let _canReadPixelsResult;
44
44
  * @param type
45
45
  * @param renderer
46
46
  * @param camera
47
+ * @param renderTargetOptions
47
48
  * @returns
48
49
  */
49
- const canReadPixels = (type, renderer, camera) => {
50
+ const canReadPixels = (type, renderer, camera, renderTargetOptions) => {
50
51
  if (_canReadPixelsResult !== undefined)
51
52
  return _canReadPixelsResult;
52
- const testRT = new WebGLRenderTarget(1, 1, {
53
- type,
54
- colorSpace: LinearSRGBColorSpace,
55
- format: RGBAFormat,
56
- magFilter: LinearFilter,
57
- minFilter: LinearFilter,
58
- wrapS: RepeatWrapping,
59
- wrapT: RepeatWrapping,
60
- depthBuffer: false,
61
- stencilBuffer: false,
62
- generateMipmaps: true
63
- });
53
+ const testRT = new WebGLRenderTarget(1, 1, renderTargetOptions);
64
54
  renderer.setRenderTarget(testRT);
65
55
  const mesh = new Mesh(new PlaneGeometry(), new MeshBasicMaterial({ color: 0xffffff }));
66
56
  renderer.render(mesh, camera);
@@ -85,7 +75,8 @@ class QuadRenderer {
85
75
  * @param sourceTexture
86
76
  * @param renderer
87
77
  */
88
- constructor(width, height, type, colorSpace, material, renderer) {
78
+ constructor(options) {
79
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
89
80
  this._rendererIsDisposable = false;
90
81
  this._supportsReadPixels = true;
91
82
  /**
@@ -102,13 +93,29 @@ class QuadRenderer {
102
93
  }
103
94
  this._renderer.setRenderTarget(null);
104
95
  };
105
- this._width = width;
106
- this._height = height;
107
- this._type = type;
108
- this._colorSpace = colorSpace;
109
- this._material = material;
110
- if (renderer) {
111
- this._renderer = renderer;
96
+ this._width = options.width;
97
+ this._height = options.height;
98
+ this._type = options.type;
99
+ this._colorSpace = options.colorSpace;
100
+ const rtOptions = {
101
+ // fixed options
102
+ format: RGBAFormat,
103
+ depthBuffer: false,
104
+ stencilBuffer: false,
105
+ // user options
106
+ type: this._type,
107
+ colorSpace: this._colorSpace,
108
+ 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,
109
+ 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,
110
+ magFilter: ((_e = options.renderTargetOptions) === null || _e === void 0 ? void 0 : _e.magFilter) !== undefined ? (_f = options.renderTargetOptions) === null || _f === void 0 ? void 0 : _f.magFilter : LinearFilter,
111
+ minFilter: ((_g = options.renderTargetOptions) === null || _g === void 0 ? void 0 : _g.minFilter) !== undefined ? (_h = options.renderTargetOptions) === null || _h === void 0 ? void 0 : _h.minFilter : LinearFilter,
112
+ 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,
113
+ wrapS: ((_l = options.renderTargetOptions) === null || _l === void 0 ? void 0 : _l.wrapS) !== undefined ? (_m = options.renderTargetOptions) === null || _m === void 0 ? void 0 : _m.wrapS : ClampToEdgeWrapping,
114
+ wrapT: ((_o = options.renderTargetOptions) === null || _o === void 0 ? void 0 : _o.wrapT) !== undefined ? (_p = options.renderTargetOptions) === null || _p === void 0 ? void 0 : _p.wrapT : ClampToEdgeWrapping
115
+ };
116
+ this._material = options.material;
117
+ if (options.renderer) {
118
+ this._renderer = options.renderer;
112
119
  }
113
120
  else {
114
121
  this._renderer = QuadRenderer.instantiateRenderer();
@@ -122,7 +129,7 @@ class QuadRenderer {
122
129
  this._camera.top = 0.5;
123
130
  this._camera.bottom = -0.5;
124
131
  this._camera.updateProjectionMatrix();
125
- if (!canReadPixels(this._type, this._renderer, this._camera)) {
132
+ if (!canReadPixels(this._type, this._renderer, this._camera, rtOptions)) {
126
133
  let alternativeType;
127
134
  switch (this._type) {
128
135
  case HalfFloatType:
@@ -141,18 +148,8 @@ class QuadRenderer {
141
148
  this._quad = new Mesh(new PlaneGeometry(), this._material);
142
149
  this._quad.geometry.computeBoundingBox();
143
150
  this._scene.add(this._quad);
144
- this._renderTarget = new WebGLRenderTarget(width, height, {
145
- type: this._type,
146
- colorSpace,
147
- format: RGBAFormat,
148
- magFilter: LinearFilter,
149
- minFilter: LinearMipMapLinearFilter,
150
- wrapS: RepeatWrapping,
151
- wrapT: RepeatWrapping,
152
- depthBuffer: false,
153
- stencilBuffer: false,
154
- generateMipmaps: true
155
- });
151
+ this._renderTarget = new WebGLRenderTarget(this.width, this.height, rtOptions);
152
+ 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 : UVMapping;
156
153
  }
157
154
  /**
158
155
  * Instantiates a temporary renderer
@@ -181,19 +178,85 @@ class QuadRenderer {
181
178
  this._renderer.readRenderTargetPixels(this._renderTarget, 0, 0, this._width, this._height, out);
182
179
  return out;
183
180
  }
184
- toDataTexture() {
185
- return new DataTexture(this.toArray(), this.width, this.height, RGBAFormat, this._type, UVMapping, RepeatWrapping, RepeatWrapping, LinearFilter, LinearMipMapLinearFilter, 1, LinearSRGBColorSpace);
181
+ /**
182
+ * Performs a readPixel operation in the renderTarget
183
+ * and returns a DataTexture containing the read data
184
+ *
185
+ * @params options
186
+ * @returns
187
+ */
188
+ toDataTexture(options) {
189
+ const returnValue = new DataTexture(
190
+ // fixed values
191
+ this.toArray(), this.width, this.height, RGBAFormat, this._type,
192
+ // user values
193
+ (options === null || options === void 0 ? void 0 : options.mapping) || UVMapping, (options === null || options === void 0 ? void 0 : options.wrapS) || ClampToEdgeWrapping, (options === null || options === void 0 ? void 0 : options.wrapT) || ClampToEdgeWrapping, (options === null || options === void 0 ? void 0 : options.magFilter) || LinearFilter, (options === null || options === void 0 ? void 0 : options.minFilter) || LinearFilter, (options === null || options === void 0 ? void 0 : options.anisotropy) || 1,
194
+ // fixed value
195
+ LinearSRGBColorSpace);
196
+ // set this afterwards, we can't set it in constructor
197
+ returnValue.generateMipmaps = (options === null || options === void 0 ? void 0 : options.generateMipmaps) !== undefined ? options === null || options === void 0 ? void 0 : options.generateMipmaps : false;
198
+ return returnValue;
186
199
  }
187
200
  /**
188
201
  * If using a disposable renderer, it will dispose it.
189
202
  */
190
- dispose() {
203
+ disposeOnDemandRenderer() {
191
204
  this._renderer.setRenderTarget(null);
192
205
  if (this._rendererIsDisposable) {
193
206
  this._renderer.dispose();
194
207
  this._renderer.forceContextLoss();
195
208
  }
196
209
  }
210
+ /**
211
+ * Will dispose of **all** assets used by this renderer.
212
+ *
213
+ *
214
+ * @param disposeRenderTarget will dispose of the renderTarget which will not be usable later
215
+ * set this to true if you passed the `renderTarget.texture` to a `PMREMGenerator`
216
+ * or are otherwise done with it.
217
+ *
218
+ * @example
219
+ * ```js
220
+ * const loader = new HDRJPGLoader(renderer)
221
+ * const result = await loader.loadAsync('gainmap.jpeg')
222
+ * const mesh = new Mesh(geometry, new MeshBasicMaterial({ map: result.renderTarget.texture }) )
223
+ * // DO NOT dispose the renderTarget here,
224
+ * // it is used directly in the material
225
+ * result.dispose()
226
+ * ```
227
+ *
228
+ * @example
229
+ * ```js
230
+ * const loader = new HDRJPGLoader(renderer)
231
+ * const pmremGenerator = new PMREMGenerator( renderer );
232
+ * const result = await loader.loadAsync('gainmap.jpeg')
233
+ * const envMap = pmremGenerator.fromEquirectangular(result.renderTarget.texture)
234
+ * const mesh = new Mesh(geometry, new MeshStandardMaterial({ envMap }) )
235
+ * // renderTarget can be disposed here
236
+ * // because it was used to generate a PMREM texture
237
+ * result.dispose(true)
238
+ * ```
239
+ */
240
+ dispose(disposeRenderTarget) {
241
+ this.disposeOnDemandRenderer();
242
+ if (disposeRenderTarget) {
243
+ this.renderTarget.dispose();
244
+ }
245
+ // dispose shader material texture uniforms
246
+ if (this.material instanceof ShaderMaterial) {
247
+ Object.values(this.material.uniforms).forEach(v => {
248
+ if (v.value instanceof Texture)
249
+ v.value.dispose();
250
+ });
251
+ }
252
+ // dispose other material properties
253
+ Object.values(this.material).forEach(value => {
254
+ if (value instanceof Texture)
255
+ value.dispose();
256
+ });
257
+ this.material.dispose();
258
+ this._quad.geometry.dispose();
259
+ }
197
260
  /**
198
261
  * Width of the texture
199
262
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.5
2
+ * @monogrid/gainmap-js v2.0.7
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.5
2
+ * @monogrid/gainmap-js v2.0.7
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
@@ -1,4 +1,5 @@
1
1
  import { ByteType, ColorSpace, DataTexture, FloatType, HalfFloatType, IntType, Material, ShortType, TextureDataType, UnsignedByteType, UnsignedIntType, WebGLRenderer, WebGLRenderTarget } from 'three';
2
+ import { QuadRendererTextureOptions } from './types';
2
3
  /**
3
4
  * Utility Type that translates `three` texture types to their TypedArray counterparts.
4
5
  *
@@ -6,6 +7,36 @@ import { ByteType, ColorSpace, DataTexture, FloatType, HalfFloatType, IntType, M
6
7
  * @group Utility
7
8
  */
8
9
  export type TextureDataTypeToBufferType<TType extends TextureDataType> = TType extends typeof UnsignedByteType ? Uint8ClampedArray : TType extends typeof HalfFloatType ? Uint16Array : TType extends typeof UnsignedIntType ? Uint32Array : TType extends typeof ByteType ? Int8Array : TType extends typeof ShortType ? Int16Array : TType extends typeof IntType ? Int32Array : TType extends typeof FloatType ? Float32Array : never;
10
+ export type QuadRendererOptions<TType extends TextureDataType, TMaterial extends Material> = {
11
+ /**
12
+ * Width of the render target
13
+ */
14
+ width: number;
15
+ /**
16
+ * height of the renderTarget
17
+ */
18
+ height: number;
19
+ /**
20
+ * TextureDataType of the renderTarget
21
+ */
22
+ type: TType;
23
+ /**
24
+ * ColorSpace of the renderTarget
25
+ */
26
+ colorSpace: ColorSpace;
27
+ /**
28
+ * material to use for rendering
29
+ */
30
+ material: TMaterial;
31
+ /**
32
+ * Renderer instance to use
33
+ */
34
+ renderer?: WebGLRenderer;
35
+ /**
36
+ * Additional renderTarget options
37
+ */
38
+ renderTargetOptions?: QuadRendererTextureOptions;
39
+ };
9
40
  /**
10
41
  * Utility class used for rendering a texture with a material
11
42
  *
@@ -30,7 +61,7 @@ export declare class QuadRenderer<TType extends TextureDataType, TMaterial exten
30
61
  * @param sourceTexture
31
62
  * @param renderer
32
63
  */
33
- constructor(width: number, height: number, type: TType, colorSpace: ColorSpace, material: TMaterial, renderer?: WebGLRenderer);
64
+ constructor(options: QuadRendererOptions<TType, TMaterial>);
34
65
  /**
35
66
  * Instantiates a temporary renderer
36
67
  *
@@ -48,11 +79,49 @@ export declare class QuadRenderer<TType extends TextureDataType, TMaterial exten
48
79
  * @returns a TypedArray containing RGBA values from this renderer
49
80
  */
50
81
  toArray(): TextureDataTypeToBufferType<TType>;
51
- toDataTexture(): DataTexture;
82
+ /**
83
+ * Performs a readPixel operation in the renderTarget
84
+ * and returns a DataTexture containing the read data
85
+ *
86
+ * @params options
87
+ * @returns
88
+ */
89
+ toDataTexture(options?: QuadRendererTextureOptions): DataTexture;
52
90
  /**
53
91
  * If using a disposable renderer, it will dispose it.
54
92
  */
55
- dispose(): void;
93
+ disposeOnDemandRenderer(): void;
94
+ /**
95
+ * Will dispose of **all** assets used by this renderer.
96
+ *
97
+ *
98
+ * @param disposeRenderTarget will dispose of the renderTarget which will not be usable later
99
+ * set this to true if you passed the `renderTarget.texture` to a `PMREMGenerator`
100
+ * or are otherwise done with it.
101
+ *
102
+ * @example
103
+ * ```js
104
+ * const loader = new HDRJPGLoader(renderer)
105
+ * const result = await loader.loadAsync('gainmap.jpeg')
106
+ * const mesh = new Mesh(geometry, new MeshBasicMaterial({ map: result.renderTarget.texture }) )
107
+ * // DO NOT dispose the renderTarget here,
108
+ * // it is used directly in the material
109
+ * result.dispose()
110
+ * ```
111
+ *
112
+ * @example
113
+ * ```js
114
+ * const loader = new HDRJPGLoader(renderer)
115
+ * const pmremGenerator = new PMREMGenerator( renderer );
116
+ * const result = await loader.loadAsync('gainmap.jpeg')
117
+ * const envMap = pmremGenerator.fromEquirectangular(result.renderTarget.texture)
118
+ * const mesh = new Mesh(geometry, new MeshStandardMaterial({ envMap }) )
119
+ * // renderTarget can be disposed here
120
+ * // because it was used to generate a PMREM texture
121
+ * result.dispose(true)
122
+ * ```
123
+ */
124
+ dispose(disposeRenderTarget?: boolean): void;
56
125
  /**
57
126
  * Width of the texture
58
127
  */
@@ -1,3 +1,4 @@
1
+ import { Mapping, RenderTargetOptions } from 'three';
1
2
  /**
2
3
  * This is the Metadata stored in an encoded Gainmap which is used
3
4
  * to decode it and return an HDR image
@@ -62,3 +63,16 @@ export type GainMapMetadata = {
62
63
  */
63
64
  gainMapMax: [number, number, number];
64
65
  };
66
+ /**
67
+ *
68
+ */
69
+ export type QuadRendererTextureOptions = Omit<RenderTargetOptions, 'type' | 'format' | 'colorSpace' | 'encoding' | 'depthTexture' | 'stencilBuffer' | 'depthBuffer' | 'internalFormat'> & {
70
+ /**
71
+ * @defaultValue {@link UVMapping}
72
+ */
73
+ mapping?: Mapping;
74
+ /**
75
+ * @defaultValue 1
76
+ */
77
+ anisotropy?: number;
78
+ };
@@ -48,6 +48,9 @@ import { DecodeParameters } from './types';
48
48
  * scene.add(mesh)
49
49
  * renderer.render(scene, new PerspectiveCamera())
50
50
  *
51
+ * // result must be manually disposed
52
+ * // when you are done using it
53
+ * result.dispose()
51
54
  *
52
55
  * @param params
53
56
  * @returns
@@ -0,0 +1,2 @@
1
+ export declare class GainMapNotFoundError extends Error {
2
+ }
@@ -0,0 +1,2 @@
1
+ export declare class XMPMetadataNotFoundError extends Error {
2
+ }
@@ -25,7 +25,7 @@ import { LoaderBase } from './LoaderBase';
25
25
  *
26
26
  * const loader = new GainMapLoader(renderer)
27
27
  *
28
- * const result = loader.load(['sdr.jpeg', 'gainmap.jpeg', 'metadata.json'])
28
+ * const result = await loader.loadAsync(['sdr.jpeg', 'gainmap.jpeg', 'metadata.json'])
29
29
  * // `result` can be used to populate a Texture
30
30
  *
31
31
  * const scene = new Scene()
@@ -45,6 +45,10 @@ import { LoaderBase } from './LoaderBase';
45
45
  * scene.background.mapping = EquirectangularReflectionMapping
46
46
  * scene.background.minFilter = LinearFilter
47
47
  *
48
+ * // result must be manually disposed
49
+ * // when you are done using it
50
+ * result.dispose()
51
+ *
48
52
  */
49
53
  export declare class GainMapLoader extends LoaderBase<[string, string, string]> {
50
54
  /**
@@ -9,7 +9,7 @@ import { LoaderBase } from './LoaderBase';
9
9
  * @group Loaders
10
10
  *
11
11
  * @example
12
- * import { JPEGRLoader } from '@monogrid/gainmap-js'
12
+ * import { HDRJPGLoader } from '@monogrid/gainmap-js'
13
13
  * import {
14
14
  * EquirectangularReflectionMapping,
15
15
  * LinearFilter,
@@ -23,9 +23,9 @@ import { LoaderBase } from './LoaderBase';
23
23
  *
24
24
  * const renderer = new WebGLRenderer()
25
25
  *
26
- * const loader = new JPEGRLoader(renderer)
26
+ * const loader = new HDRJPGLoader(renderer)
27
27
  *
28
- * const result = loader.load('gainmap.jpeg')
28
+ * const result = await loader.loadAsync('gainmap.jpeg')
29
29
  * // `result` can be used to populate a Texture
30
30
  *
31
31
  * const scene = new Scene()
@@ -44,12 +44,16 @@ import { LoaderBase } from './LoaderBase';
44
44
  * scene.background = result.toDataTexture()
45
45
  * scene.background.mapping = EquirectangularReflectionMapping
46
46
  * scene.background.minFilter = LinearFilter
47
-
47
+ *
48
+ * // result must be manually disposed
49
+ * // when you are done using it
50
+ * result.dispose()
48
51
  *
49
52
  */
50
53
  export declare class HDRJPGLoader extends LoaderBase<string> {
51
54
  /**
52
- * Loads a JPEGR Image
55
+ * Loads a JPEG containing gain map metadata
56
+ * Renders a normal SDR image if gainmap data is not found
53
57
  *
54
58
  * @param url An array in the form of [sdr.jpg, gainmap.jpg, metadata.json]
55
59
  * @param onLoad Load complete callback, will receive the result
@@ -1,9 +1,13 @@
1
1
  import { HalfFloatType, Loader, LoadingManager, WebGLRenderer } from 'three';
2
2
  import { QuadRenderer } from '../../core/QuadRenderer';
3
- import { type GainMapMetadata } from '../../core/types';
3
+ import { type GainMapMetadata, QuadRendererTextureOptions } from '../../core/types';
4
4
  import { GainMapDecoderMaterial } from '../materials/GainMapDecoderMaterial';
5
5
  export declare class LoaderBase<TUrl = string> extends Loader<QuadRenderer<typeof HalfFloatType, GainMapDecoderMaterial>, TUrl> {
6
6
  private _renderer;
7
+ private _renderTargetOptions?;
8
+ /**
9
+ * @private
10
+ */
7
11
  protected _internalLoadingManager: LoadingManager;
8
12
  /**
9
13
  *
@@ -12,17 +16,23 @@ export declare class LoaderBase<TUrl = string> extends Loader<QuadRenderer<typeo
12
16
  */
13
17
  constructor(renderer: WebGLRenderer, manager?: LoadingManager);
14
18
  /**
15
- * @private
19
+ * Specify the renderTarget options to use when rendering the gain map
20
+ *
21
+ * @param options
16
22
  * @returns
17
23
  */
18
- protected prepareQuadRenderer(): QuadRenderer<1016, GainMapDecoderMaterial>;
24
+ setRenderTargetOptions(options: QuadRendererTextureOptions): this;
19
25
  /**
20
- *
21
26
  * @private
22
- * @param quadRenderer
23
- * @param gainMapBuffer
24
- * @param sdrBuffer
25
- * @param metadata
27
+ * @returns
26
28
  */
27
- protected render(quadRenderer: QuadRenderer<typeof HalfFloatType, GainMapDecoderMaterial>, gainMapBuffer: ArrayBuffer | string, sdrBuffer: ArrayBuffer | string, metadata: GainMapMetadata): Promise<void>;
29
+ protected prepareQuadRenderer(): QuadRenderer<1016, GainMapDecoderMaterial>;
30
+ /**
31
+ * @private
32
+ * @param quadRenderer
33
+ * @param metadata
34
+ * @param sdrBuffer
35
+ * @param gainMapBuffer
36
+ */
37
+ protected render(quadRenderer: QuadRenderer<typeof HalfFloatType, GainMapDecoderMaterial>, metadata: GainMapMetadata, sdrBuffer: ArrayBuffer, gainMapBuffer?: ArrayBuffer): Promise<void>;
28
38
  }
@@ -1,5 +1,5 @@
1
1
  import { type Texture, type WebGLRenderer } from 'three';
2
- import { type GainMapMetadata } from '../core/types';
2
+ import { type GainMapMetadata, type QuadRendererTextureOptions } from '../core/types';
3
3
  /**
4
4
  * Necessary parameters for decoding a Gainmap
5
5
  *
@@ -35,4 +35,8 @@ export type DecodeParameters = {
35
35
  * WebGLRenderer used to decode the GainMap
36
36
  */
37
37
  renderer?: WebGLRenderer;
38
+ /**
39
+ * Options to use when creating the output renderTarget
40
+ */
41
+ renderTargetOptions?: QuadRendererTextureOptions;
38
42
  } & GainmapDecodingParameters & GainMapMetadata;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * private function, async get image from blob
3
+ *
4
+ * @param blob
5
+ * @returns
6
+ */
7
+ export declare const getHTMLImageFromBlob: (blob: Blob) => Promise<HTMLImageElement>;