@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.
- package/CHANGELOG.md +25 -0
- package/README.md +14 -12
- package/dist/{QuadRenderer-QXcVmgNm.js → QuadRenderer-pEe6Kzcn.js} +45 -38
- package/dist/{_commonjsHelpers-ftl_lJMx.js → _commonjsHelpers-Gkwpb-h5.js} +1 -1
- package/dist/{compress-MvOX-rlz.js → compress-6L6-d1aM.js} +1 -1
- package/dist/core/QuadRenderer.d.ts +34 -2
- package/dist/core/types.d.ts +14 -0
- package/dist/decode/index.d.ts +2 -0
- package/dist/decode/loaders/GainMapLoader.d.ts +7 -7
- package/dist/decode/loaders/HDRJPGLoader.d.ts +7 -7
- package/dist/decode/loaders/LoaderBase.d.ts +9 -1
- package/dist/decode/types.d.ts +5 -1
- package/dist/decode.js +73 -23
- package/dist/decode.umd.js +116 -57
- package/dist/encode/get-sdr-rendition.d.ts +3 -1
- package/dist/encode/types.d.ts +5 -0
- package/dist/encode.js +42 -13
- package/dist/encode.umd.js +84 -48
- package/dist/libultrahdr.js +1 -1
- package/dist/libultrahdr.umd.js +1 -1
- package/dist/worker-interface.js +2 -2
- package/dist/worker-interface.umd.js +1 -1
- package/dist/worker.js +3 -3
- package/dist/worker.umd.js +1 -1
- package/package.json +25 -24
- /package/dist/decode/utils/{extract-metadata-from-jpeg.d.ts → extractXMP.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
## [3.0.1](https://github.com/MONOGRID/gainmap-js/compare/v3.0.0...v3.0.1) (2023-12-03)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **encode:** hdrCapacityMax correctly computed in output metadata ([f5f2215](https://github.com/MONOGRID/gainmap-js/commit/f5f22152eb236831cb9f23646445e6459be18285))
|
|
7
|
+
* **encode:** findTextureMinMax correctly finds min values in textures ([fd94680](https://github.com/MONOGRID/gainmap-js/commit/fd94680a76fdb04b5aa85b4210f3aec21b45a727))
|
|
8
|
+
|
|
9
|
+
# [3.0.0](https://github.com/MONOGRID/gainmap-js/compare/v2.0.7...v3.0.0) (2023-11-29)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **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)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **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)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### BREAKING CHANGES
|
|
23
|
+
|
|
24
|
+
* **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`
|
|
25
|
+
|
|
1
26
|
## [2.0.7](https://github.com/MONOGRID/gainmap-js/compare/v2.0.6...v2.0.7) (2023-11-23)
|
|
2
27
|
|
|
3
28
|
|
package/README.md
CHANGED
|
@@ -90,14 +90,15 @@ const mesh = new Mesh(
|
|
|
90
90
|
scene.add(mesh)
|
|
91
91
|
renderer.render(scene, new PerspectiveCamera())
|
|
92
92
|
|
|
93
|
-
// `result.renderTarget.texture` must be
|
|
94
|
-
// converted to `DataTexture` in order
|
|
95
|
-
// to use it as Equirectangular scene background
|
|
96
|
-
// if needed
|
|
97
93
|
|
|
98
|
-
|
|
94
|
+
// Starting from three.js r159
|
|
95
|
+
// `result.renderTarget.texture` can
|
|
96
|
+
// also be used as Equirectangular scene background
|
|
97
|
+
//
|
|
98
|
+
// it was previously needed to convert it
|
|
99
|
+
// to a DataTexture with `result.toDataTexture()`
|
|
100
|
+
scene.background = result.renderTarget.texture
|
|
99
101
|
scene.background.mapping = EquirectangularReflectionMapping
|
|
100
|
-
scene.background.minFilter = LinearFilter
|
|
101
102
|
|
|
102
103
|
|
|
103
104
|
// result must be manually disposed
|
|
@@ -143,14 +144,15 @@ const mesh = new Mesh(
|
|
|
143
144
|
scene.add(mesh)
|
|
144
145
|
renderer.render(scene, new PerspectiveCamera())
|
|
145
146
|
|
|
146
|
-
// `result.renderTarget.texture` must be
|
|
147
|
-
// converted to `DataTexture` in order
|
|
148
|
-
// to use it as Equirectangular scene background
|
|
149
|
-
// if needed
|
|
150
147
|
|
|
151
|
-
|
|
148
|
+
// Starting from three.js r159
|
|
149
|
+
// `result.renderTarget.texture` can
|
|
150
|
+
// also be used as Equirectangular scene background
|
|
151
|
+
//
|
|
152
|
+
// it was previously needed to convert it
|
|
153
|
+
// to a DataTexture with `result.toDataTexture()`
|
|
154
|
+
scene.background = result.renderTarget.texture
|
|
152
155
|
scene.background.mapping = EquirectangularReflectionMapping
|
|
153
|
-
scene.background.minFilter = LinearFilter
|
|
154
156
|
|
|
155
157
|
// result must be manually disposed
|
|
156
158
|
// when you are done using it
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js
|
|
2
|
+
* @monogrid/gainmap-js v3.0.1
|
|
3
3
|
* With ❤️, by MONOGRID <hello@mono-grid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Scene, OrthographicCamera, HalfFloatType, FloatType, Mesh, PlaneGeometry, WebGLRenderTarget,
|
|
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(
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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, // set in class property
|
|
107
|
+
colorSpace: this._colorSpace, // set in class property
|
|
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
|
-
|
|
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
|
|
@@ -185,10 +182,20 @@ class QuadRenderer {
|
|
|
185
182
|
* Performs a readPixel operation in the renderTarget
|
|
186
183
|
* and returns a DataTexture containing the read data
|
|
187
184
|
*
|
|
185
|
+
* @params options
|
|
188
186
|
* @returns
|
|
189
187
|
*/
|
|
190
|
-
toDataTexture() {
|
|
191
|
-
|
|
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;
|
|
192
199
|
}
|
|
193
200
|
/**
|
|
194
201
|
* If using a disposable renderer, it will dispose it.
|
|
@@ -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(
|
|
64
|
+
constructor(options: QuadRendererOptions<TType, TMaterial>);
|
|
34
65
|
/**
|
|
35
66
|
* Instantiates a temporary renderer
|
|
36
67
|
*
|
|
@@ -52,9 +83,10 @@ export declare class QuadRenderer<TType extends TextureDataType, TMaterial exten
|
|
|
52
83
|
* Performs a readPixel operation in the renderTarget
|
|
53
84
|
* and returns a DataTexture containing the read data
|
|
54
85
|
*
|
|
86
|
+
* @params options
|
|
55
87
|
* @returns
|
|
56
88
|
*/
|
|
57
|
-
toDataTexture(): DataTexture;
|
|
89
|
+
toDataTexture(options?: QuadRendererTextureOptions): DataTexture;
|
|
58
90
|
/**
|
|
59
91
|
* If using a disposable renderer, it will dispose it.
|
|
60
92
|
*/
|
package/dist/core/types.d.ts
CHANGED
|
@@ -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
|
+
};
|
package/dist/decode/index.d.ts
CHANGED
|
@@ -36,14 +36,14 @@ import { LoaderBase } from './LoaderBase';
|
|
|
36
36
|
* scene.add(mesh)
|
|
37
37
|
* renderer.render(scene, new PerspectiveCamera())
|
|
38
38
|
*
|
|
39
|
-
* //
|
|
40
|
-
* //
|
|
41
|
-
* //
|
|
42
|
-
* //
|
|
43
|
-
*
|
|
44
|
-
*
|
|
39
|
+
* // Starting from three.js r159
|
|
40
|
+
* // `result.renderTarget.texture` can
|
|
41
|
+
* // also be used as Equirectangular scene background
|
|
42
|
+
* //
|
|
43
|
+
* // it was previously needed to convert it
|
|
44
|
+
* // to a DataTexture with `result.toDataTexture()`
|
|
45
|
+
* scene.background = result.renderTarget.texture
|
|
45
46
|
* scene.background.mapping = EquirectangularReflectionMapping
|
|
46
|
-
* scene.background.minFilter = LinearFilter
|
|
47
47
|
*
|
|
48
48
|
* // result must be manually disposed
|
|
49
49
|
* // when you are done using it
|
|
@@ -36,14 +36,14 @@ import { LoaderBase } from './LoaderBase';
|
|
|
36
36
|
* scene.add(mesh)
|
|
37
37
|
* renderer.render(scene, new PerspectiveCamera())
|
|
38
38
|
*
|
|
39
|
-
* //
|
|
40
|
-
* //
|
|
41
|
-
* //
|
|
42
|
-
* //
|
|
43
|
-
*
|
|
44
|
-
*
|
|
39
|
+
* // Starting from three.js r159
|
|
40
|
+
* // `result.renderTarget.texture` can
|
|
41
|
+
* // also be used as Equirectangular scene background
|
|
42
|
+
* //
|
|
43
|
+
* // it was previously needed to convert it
|
|
44
|
+
* // to a DataTexture with `result.toDataTexture()`
|
|
45
|
+
* scene.background = result.renderTarget.texture
|
|
45
46
|
* scene.background.mapping = EquirectangularReflectionMapping
|
|
46
|
-
* scene.background.minFilter = LinearFilter
|
|
47
47
|
*
|
|
48
48
|
* // result must be manually disposed
|
|
49
49
|
* // when you are done using it
|
|
@@ -1,9 +1,10 @@
|
|
|
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?;
|
|
7
8
|
/**
|
|
8
9
|
* @private
|
|
9
10
|
*/
|
|
@@ -14,6 +15,13 @@ export declare class LoaderBase<TUrl = string> extends Loader<QuadRenderer<typeo
|
|
|
14
15
|
* @param manager
|
|
15
16
|
*/
|
|
16
17
|
constructor(renderer: WebGLRenderer, manager?: LoadingManager);
|
|
18
|
+
/**
|
|
19
|
+
* Specify the renderTarget options to use when rendering the gain map
|
|
20
|
+
*
|
|
21
|
+
* @param options
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
setRenderTargetOptions(options: QuadRendererTextureOptions): this;
|
|
17
25
|
/**
|
|
18
26
|
* @private
|
|
19
27
|
* @returns
|
package/dist/decode/types.d.ts
CHANGED
|
@@ -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;
|
package/dist/decode.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js
|
|
2
|
+
* @monogrid/gainmap-js v3.0.1
|
|
3
3
|
* With ❤️, by MONOGRID <hello@mono-grid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Q as QuadRenderer } from './QuadRenderer-
|
|
6
|
+
import { Q as QuadRenderer } from './QuadRenderer-pEe6Kzcn.js';
|
|
7
7
|
import { ShaderMaterial, Vector3, NoBlending, SRGBColorSpace, LinearSRGBColorSpace, HalfFloatType, Loader, LoadingManager, Texture, UVMapping, ClampToEdgeWrapping, LinearFilter, LinearMipMapLinearFilter, RGBAFormat, UnsignedByteType, FileLoader } from 'three';
|
|
8
8
|
|
|
9
9
|
const vertexShader = /* glsl */ `
|
|
@@ -221,9 +221,19 @@ const decode = (params) => {
|
|
|
221
221
|
sdr,
|
|
222
222
|
gainMap
|
|
223
223
|
});
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
const quadRenderer = new QuadRenderer({
|
|
225
|
+
// TODO: three types are generic, eslint complains here, see how we can solve
|
|
226
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
227
|
+
width: sdr.image.width,
|
|
228
|
+
// TODO: three types are generic, eslint complains here, see how we can solve
|
|
229
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
230
|
+
height: sdr.image.height,
|
|
231
|
+
type: HalfFloatType,
|
|
232
|
+
colorSpace: LinearSRGBColorSpace,
|
|
233
|
+
material,
|
|
234
|
+
renderer,
|
|
235
|
+
renderTargetOptions: params.renderTargetOptions
|
|
236
|
+
});
|
|
227
237
|
try {
|
|
228
238
|
quadRenderer.render();
|
|
229
239
|
}
|
|
@@ -540,6 +550,16 @@ class LoaderBase extends Loader {
|
|
|
540
550
|
this._renderer = renderer;
|
|
541
551
|
this._internalLoadingManager = new LoadingManager();
|
|
542
552
|
}
|
|
553
|
+
/**
|
|
554
|
+
* Specify the renderTarget options to use when rendering the gain map
|
|
555
|
+
*
|
|
556
|
+
* @param options
|
|
557
|
+
* @returns
|
|
558
|
+
*/
|
|
559
|
+
setRenderTargetOptions(options) {
|
|
560
|
+
this._renderTargetOptions = options;
|
|
561
|
+
return this;
|
|
562
|
+
}
|
|
543
563
|
/**
|
|
544
564
|
* @private
|
|
545
565
|
* @returns
|
|
@@ -558,7 +578,15 @@ class LoaderBase extends Loader {
|
|
|
558
578
|
gainMap: new Texture(),
|
|
559
579
|
sdr: new Texture()
|
|
560
580
|
});
|
|
561
|
-
return new QuadRenderer(
|
|
581
|
+
return new QuadRenderer({
|
|
582
|
+
width: 16,
|
|
583
|
+
height: 16,
|
|
584
|
+
type: HalfFloatType,
|
|
585
|
+
colorSpace: LinearSRGBColorSpace,
|
|
586
|
+
material,
|
|
587
|
+
renderer: this._renderer,
|
|
588
|
+
renderTargetOptions: this._renderTargetOptions
|
|
589
|
+
});
|
|
562
590
|
}
|
|
563
591
|
/**
|
|
564
592
|
* @private
|
|
@@ -648,14 +676,14 @@ class LoaderBase extends Loader {
|
|
|
648
676
|
* scene.add(mesh)
|
|
649
677
|
* renderer.render(scene, new PerspectiveCamera())
|
|
650
678
|
*
|
|
651
|
-
* //
|
|
652
|
-
* //
|
|
653
|
-
* //
|
|
654
|
-
* //
|
|
655
|
-
*
|
|
656
|
-
*
|
|
679
|
+
* // Starting from three.js r159
|
|
680
|
+
* // `result.renderTarget.texture` can
|
|
681
|
+
* // also be used as Equirectangular scene background
|
|
682
|
+
* //
|
|
683
|
+
* // it was previously needed to convert it
|
|
684
|
+
* // to a DataTexture with `result.toDataTexture()`
|
|
685
|
+
* scene.background = result.renderTarget.texture
|
|
657
686
|
* scene.background.mapping = EquirectangularReflectionMapping
|
|
658
|
-
* scene.background.minFilter = LinearFilter
|
|
659
687
|
*
|
|
660
688
|
* // result must be manually disposed
|
|
661
689
|
* // when you are done using it
|
|
@@ -684,7 +712,19 @@ class GainMapLoader extends LoaderBase {
|
|
|
684
712
|
let metadata;
|
|
685
713
|
const loadCheck = async () => {
|
|
686
714
|
if (sdr && gainMap && metadata) {
|
|
687
|
-
|
|
715
|
+
// solves #16
|
|
716
|
+
try {
|
|
717
|
+
await this.render(quadRenderer, metadata, sdr, gainMap);
|
|
718
|
+
}
|
|
719
|
+
catch (error) {
|
|
720
|
+
this.manager.itemError(sdrUrl);
|
|
721
|
+
this.manager.itemError(gainMapUrl);
|
|
722
|
+
this.manager.itemError(metadataUrl);
|
|
723
|
+
if (typeof onError === 'function')
|
|
724
|
+
onError(error);
|
|
725
|
+
quadRenderer.disposeOnDemandRenderer();
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
688
728
|
if (typeof onLoad === 'function')
|
|
689
729
|
onLoad(quadRenderer);
|
|
690
730
|
this.manager.itemEnd(sdrUrl);
|
|
@@ -813,14 +853,14 @@ class GainMapLoader extends LoaderBase {
|
|
|
813
853
|
* scene.add(mesh)
|
|
814
854
|
* renderer.render(scene, new PerspectiveCamera())
|
|
815
855
|
*
|
|
816
|
-
* //
|
|
817
|
-
* //
|
|
818
|
-
* //
|
|
819
|
-
* //
|
|
820
|
-
*
|
|
821
|
-
*
|
|
856
|
+
* // Starting from three.js r159
|
|
857
|
+
* // `result.renderTarget.texture` can
|
|
858
|
+
* // also be used as Equirectangular scene background
|
|
859
|
+
* //
|
|
860
|
+
* // it was previously needed to convert it
|
|
861
|
+
* // to a DataTexture with `result.toDataTexture()`
|
|
862
|
+
* scene.background = result.renderTarget.texture
|
|
822
863
|
* scene.background.mapping = EquirectangularReflectionMapping
|
|
823
|
-
* scene.background.minFilter = LinearFilter
|
|
824
864
|
*
|
|
825
865
|
* // result must be manually disposed
|
|
826
866
|
* // when you are done using it
|
|
@@ -879,7 +919,17 @@ class HDRJPGLoader extends LoaderBase {
|
|
|
879
919
|
throw e;
|
|
880
920
|
}
|
|
881
921
|
}
|
|
882
|
-
|
|
922
|
+
// solves #16
|
|
923
|
+
try {
|
|
924
|
+
await this.render(quadRenderer, metadata, sdrJPEG, gainMapJPEG);
|
|
925
|
+
}
|
|
926
|
+
catch (error) {
|
|
927
|
+
this.manager.itemError(url);
|
|
928
|
+
if (typeof onError === 'function')
|
|
929
|
+
onError(error);
|
|
930
|
+
quadRenderer.disposeOnDemandRenderer();
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
883
933
|
if (typeof onLoad === 'function')
|
|
884
934
|
onLoad(quadRenderer);
|
|
885
935
|
this.manager.itemEnd(url);
|
|
@@ -893,4 +943,4 @@ class HDRJPGLoader extends LoaderBase {
|
|
|
893
943
|
}
|
|
894
944
|
}
|
|
895
945
|
|
|
896
|
-
export { GainMapDecoderMaterial, GainMapLoader, HDRJPGLoader, HDRJPGLoader as JPEGRLoader, QuadRenderer, decode, extractGainmapFromJPEG };
|
|
946
|
+
export { GainMapDecoderMaterial, GainMapLoader, HDRJPGLoader, HDRJPGLoader as JPEGRLoader, MPFExtractor, QuadRenderer, decode, extractGainmapFromJPEG, extractXMP };
|