@monogrid/gainmap-js 1.0.2 → 1.1.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 +7 -0
- package/README.md +103 -19
- package/dist/LoaderBase-aa4842c4.js +373 -0
- package/dist/_commonjsHelpers-1789f0cf.js +1 -1
- package/dist/compress-a4b59cab.js +1 -1
- package/dist/decode.d.ts +25 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +173 -246
- package/dist/index.umd.js +305 -14
- package/dist/libultrahdr-esm.wasm +0 -0
- package/dist/libultrahdr.d.ts +14 -19
- package/dist/libultrahdr.js +245 -203
- package/dist/libultrahdr.umd.js +611 -206
- package/dist/loaders/GainMapLoader.d.ts +68 -0
- package/dist/loaders/JPEGRLoader.d.ts +60 -0
- package/dist/loaders/LoaderBase.d.ts +27 -0
- package/dist/materials/GainMapDecoderMaterial.d.ts +44 -1
- package/dist/materials/GainMapEncoderMaterial.d.ts +29 -2
- package/dist/types.d.ts +10 -0
- package/dist/utils/QuadRenderer.d.ts +2 -1
- package/dist/worker-interface.js +1 -1
- package/dist/worker-interface.umd.js +1 -1
- package/dist/worker.js +1 -1
- package/dist/worker.umd.js +1 -1
- package/libultrahdr-wasm/build/libultrahdr-debug.js +156 -182
- package/libultrahdr-wasm/build/libultrahdr-debug.wasm +0 -0
- package/libultrahdr-wasm/build/libultrahdr-esm.js +153 -182
- package/libultrahdr-wasm/build/libultrahdr-esm.wasm +0 -0
- package/libultrahdr-wasm/build/libultrahdr.js +151 -180
- package/libultrahdr-wasm/build/libultrahdr.wasm +0 -0
- package/package.json +1 -1
- package/examples/README.md +0 -3
- package/examples/compress.ts +0 -43
- package/examples/decode-from-jpeg.ts +0 -40
- package/examples/decode-from-separate-data.ts +0 -41
- package/examples/decode-to-datatexture.ts +0 -65
- package/examples/encode-and-compress.ts +0 -29
- package/examples/encode-jpeg-metadata.ts +0 -57
- package/examples/encode.ts +0 -28
- package/examples/globals.d.ts +0 -6
- package/examples/worker.ts +0 -41
- package/reports/eslint-examples.json +0 -1
- package/reports/eslint-src.json +0 -1
- package/reports/eslint-tests.json +0 -1
- package/reports/junit.xml +0 -35
- package/reports/typecheck-examples.log +0 -0
- package/reports/typecheck-tests.log +0 -0
- package/reports/typecheck.log +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { HalfFloatType } from 'three';
|
|
2
|
+
import { GainMapDecoderMaterial } from '../materials/GainMapDecoderMaterial';
|
|
3
|
+
import { QuadRenderer } from '../utils/QuadRenderer';
|
|
4
|
+
import { LoaderBase } from './LoaderBase';
|
|
5
|
+
/**
|
|
6
|
+
* A Three.js Loader for the gain map format.
|
|
7
|
+
*
|
|
8
|
+
* @category Loaders
|
|
9
|
+
* @group Loaders
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { GainMapLoader } from '@monogrid/gainmap-js'
|
|
13
|
+
* import {
|
|
14
|
+
* EquirectangularReflectionMapping,
|
|
15
|
+
* LinearFilter,
|
|
16
|
+
* Mesh,
|
|
17
|
+
* MeshBasicMaterial,
|
|
18
|
+
* PerspectiveCamera,
|
|
19
|
+
* PlaneGeometry,
|
|
20
|
+
* Scene,
|
|
21
|
+
* WebGLRenderer
|
|
22
|
+
* } from 'three'
|
|
23
|
+
*
|
|
24
|
+
* const renderer = new WebGLRenderer()
|
|
25
|
+
*
|
|
26
|
+
* const loader = new GainMapLoader(renderer)
|
|
27
|
+
*
|
|
28
|
+
* const result = loader.load(['sdr.jpeg', 'gainmap.jpeg', 'metadata.json'])
|
|
29
|
+
* // `result` can be used to populate a Texture
|
|
30
|
+
*
|
|
31
|
+
* const scene = new Scene()
|
|
32
|
+
* const mesh = new Mesh(
|
|
33
|
+
* new PlaneGeometry(),
|
|
34
|
+
* new MeshBasicMaterial({ map: result.renderTarget.texture })
|
|
35
|
+
* )
|
|
36
|
+
* scene.add(mesh)
|
|
37
|
+
* renderer.render(scene, new PerspectiveCamera())
|
|
38
|
+
*
|
|
39
|
+
* // `result.renderTarget.texture` must be
|
|
40
|
+
* // converted to `DataTexture` in order
|
|
41
|
+
* // to use it as Equirectanmgular scene background
|
|
42
|
+
* // if needed
|
|
43
|
+
*
|
|
44
|
+
* scene.background = result.toDataTexture()
|
|
45
|
+
* scene.background.mapping = EquirectangularReflectionMapping
|
|
46
|
+
* scene.background.minFilter = LinearFilter
|
|
47
|
+
*
|
|
48
|
+
*
|
|
49
|
+
*/
|
|
50
|
+
export declare class GainMapLoader extends LoaderBase<[string, string, string]> {
|
|
51
|
+
/**
|
|
52
|
+
* Loads a gainmap using separate data
|
|
53
|
+
* * sdr image
|
|
54
|
+
* * gain map image
|
|
55
|
+
* * metadata json
|
|
56
|
+
*
|
|
57
|
+
* useful for webp gainmaps
|
|
58
|
+
*
|
|
59
|
+
* @param sdrUrl
|
|
60
|
+
* @param gainMapUrl
|
|
61
|
+
* @param metadataUrl
|
|
62
|
+
* @param onLoad
|
|
63
|
+
* @param onProgress
|
|
64
|
+
* @param onError
|
|
65
|
+
* @returns
|
|
66
|
+
*/
|
|
67
|
+
load([sdrUrl, gainMapUrl, metadataUrl]: [string, string, string], onLoad?: (data: QuadRenderer<typeof HalfFloatType, GainMapDecoderMaterial>) => void, onProgress?: (event: ProgressEvent) => void, onError?: (err: unknown) => void): QuadRenderer<typeof HalfFloatType, GainMapDecoderMaterial>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { HalfFloatType } from 'three';
|
|
2
|
+
import { GainMapDecoderMaterial } from '../materials/GainMapDecoderMaterial';
|
|
3
|
+
import { QuadRenderer } from '../utils/QuadRenderer';
|
|
4
|
+
import { LoaderBase } from './LoaderBase';
|
|
5
|
+
/**
|
|
6
|
+
* A Three.js Loader for a JPEG with embedded gainmap metadata.
|
|
7
|
+
*
|
|
8
|
+
* @category Loaders
|
|
9
|
+
* @group Loaders
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { JPEGRLoader } from '@monogrid/gainmap-js/libultrahdr'
|
|
13
|
+
* import {
|
|
14
|
+
* EquirectangularReflectionMapping,
|
|
15
|
+
* LinearFilter,
|
|
16
|
+
* Mesh,
|
|
17
|
+
* MeshBasicMaterial,
|
|
18
|
+
* PerspectiveCamera,
|
|
19
|
+
* PlaneGeometry,
|
|
20
|
+
* Scene,
|
|
21
|
+
* WebGLRenderer
|
|
22
|
+
* } from 'three'
|
|
23
|
+
*
|
|
24
|
+
* const renderer = new WebGLRenderer()
|
|
25
|
+
*
|
|
26
|
+
* const loader = new JPEGRLoader(renderer)
|
|
27
|
+
*
|
|
28
|
+
* const result = loader.load('gainmap.jpeg')
|
|
29
|
+
* // `result` can be used to populate a Texture
|
|
30
|
+
*
|
|
31
|
+
* const scene = new Scene()
|
|
32
|
+
* const mesh = new Mesh(
|
|
33
|
+
* new PlaneGeometry(),
|
|
34
|
+
* new MeshBasicMaterial({ map: result.renderTarget.texture })
|
|
35
|
+
* )
|
|
36
|
+
* scene.add(mesh)
|
|
37
|
+
* renderer.render(scene, new PerspectiveCamera())
|
|
38
|
+
*
|
|
39
|
+
* // `result.renderTarget.texture` must be
|
|
40
|
+
* // converted to `DataTexture` in order
|
|
41
|
+
* // to use it as Equirectanmgular scene background
|
|
42
|
+
* // if needed
|
|
43
|
+
*
|
|
44
|
+
* scene.background = result.toDataTexture()
|
|
45
|
+
* scene.background.mapping = EquirectangularReflectionMapping
|
|
46
|
+
* scene.background.minFilter = LinearFilter
|
|
47
|
+
|
|
48
|
+
*
|
|
49
|
+
*/
|
|
50
|
+
export declare class JPEGRLoader extends LoaderBase<string> {
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @param url
|
|
54
|
+
* @param onLoad
|
|
55
|
+
* @param onProgress
|
|
56
|
+
* @param onError
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
load(url: string, onLoad?: (data: QuadRenderer<typeof HalfFloatType, GainMapDecoderMaterial>) => void, onProgress?: (event: ProgressEvent) => void, onError?: (err: unknown) => void): QuadRenderer<typeof HalfFloatType, GainMapDecoderMaterial>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { HalfFloatType, Loader, LoadingManager, WebGLRenderer } from 'three';
|
|
2
|
+
import { GainMapDecoderMaterial } from '../materials/GainMapDecoderMaterial';
|
|
3
|
+
import { GainMapMetadata } from '../types';
|
|
4
|
+
import { QuadRenderer } from '../utils/QuadRenderer';
|
|
5
|
+
export declare class LoaderBase<TUrl = string> extends Loader<QuadRenderer<typeof HalfFloatType, GainMapDecoderMaterial>, TUrl> {
|
|
6
|
+
private renderer;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param renderer
|
|
10
|
+
* @param manager
|
|
11
|
+
*/
|
|
12
|
+
constructor(renderer: WebGLRenderer, manager?: LoadingManager);
|
|
13
|
+
/**
|
|
14
|
+
* @private
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
protected prepareQuadRenderer(): QuadRenderer<1016, GainMapDecoderMaterial>;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @private
|
|
21
|
+
* @param quadRenderer
|
|
22
|
+
* @param gainMapBuffer
|
|
23
|
+
* @param sdrBuffer
|
|
24
|
+
* @param metadata
|
|
25
|
+
*/
|
|
26
|
+
protected render(quadRenderer: QuadRenderer<typeof HalfFloatType, GainMapDecoderMaterial>, gainMapBuffer: ArrayBuffer | string, sdrBuffer: ArrayBuffer | string, metadata: GainMapMetadata): Promise<void>;
|
|
27
|
+
}
|
|
@@ -18,9 +18,52 @@ export declare class GainMapDecoderMaterial extends ShaderMaterial {
|
|
|
18
18
|
sdr: Texture;
|
|
19
19
|
gainMap: Texture;
|
|
20
20
|
});
|
|
21
|
+
get sdr(): Texture;
|
|
22
|
+
set sdr(value: Texture);
|
|
23
|
+
get gainMap(): Texture;
|
|
24
|
+
set gainMap(value: Texture);
|
|
21
25
|
/**
|
|
22
|
-
* @see {@link
|
|
26
|
+
* @see {@link GainMapMetadata.offsetHdr}
|
|
27
|
+
*/
|
|
28
|
+
get offsetHdr(): [number, number, number];
|
|
29
|
+
set offsetHdr(value: [number, number, number]);
|
|
30
|
+
/**
|
|
31
|
+
* @see {@link GainMapMetadata.offsetSdr}
|
|
32
|
+
*/
|
|
33
|
+
get offsetSdr(): [number, number, number];
|
|
34
|
+
set offsetSdr(value: [number, number, number]);
|
|
35
|
+
/**
|
|
36
|
+
* @see {@link GainMapMetadata.gainMapMin}
|
|
37
|
+
*/
|
|
38
|
+
get gainMapMin(): [number, number, number];
|
|
39
|
+
set gainMapMin(value: [number, number, number]);
|
|
40
|
+
/**
|
|
41
|
+
* @see {@link GainMapMetadata.gainMapMax}
|
|
42
|
+
*/
|
|
43
|
+
get gainMapMax(): [number, number, number];
|
|
44
|
+
set gainMapMax(value: [number, number, number]);
|
|
45
|
+
/**
|
|
46
|
+
* @see {@link GainmapEncodingParameters.gamma}
|
|
47
|
+
*/
|
|
48
|
+
get gamma(): [number, number, number];
|
|
49
|
+
set gamma(value: [number, number, number]);
|
|
50
|
+
/**
|
|
51
|
+
* @see {@link GainMapMetadata.hdrCapacityMin}
|
|
52
|
+
* @remarks Logarithmic space
|
|
53
|
+
*/
|
|
54
|
+
get hdrCapacityMin(): number;
|
|
55
|
+
set hdrCapacityMin(value: number);
|
|
56
|
+
/**
|
|
57
|
+
* @see {@link GainMapMetadata.hdrCapacityMin}
|
|
58
|
+
* @remarks Logarithmic space
|
|
59
|
+
*/
|
|
60
|
+
get hdrCapacityMax(): number;
|
|
61
|
+
set hdrCapacityMax(value: number);
|
|
62
|
+
/**
|
|
63
|
+
* @see {@link GainmapDecodingParameters.maxDisplayBoost}
|
|
64
|
+
* @remarks Non Logarithmic space
|
|
23
65
|
*/
|
|
24
66
|
get maxDisplayBoost(): number;
|
|
25
67
|
set maxDisplayBoost(value: number);
|
|
68
|
+
private calculateWeight;
|
|
26
69
|
}
|
|
@@ -20,24 +20,51 @@ export declare class GainMapEncoderMaterial extends ShaderMaterial {
|
|
|
20
20
|
sdr: Texture;
|
|
21
21
|
hdr: Texture;
|
|
22
22
|
} & GainmapEncodingParameters);
|
|
23
|
+
/**
|
|
24
|
+
* @see {@link GainmapEncodingParameters.gamma}
|
|
25
|
+
*/
|
|
23
26
|
get gamma(): [number, number, number];
|
|
24
27
|
set gamma(value: [number, number, number]);
|
|
28
|
+
/**
|
|
29
|
+
* @see {@link GainmapEncodingParameters.offsetHdr}
|
|
30
|
+
*/
|
|
25
31
|
get offsetHdr(): [number, number, number];
|
|
26
32
|
set offsetHdr(value: [number, number, number]);
|
|
33
|
+
/**
|
|
34
|
+
* @see {@link GainmapEncodingParameters.offsetSdr}
|
|
35
|
+
*/
|
|
27
36
|
get offsetSdr(): [number, number, number];
|
|
28
37
|
set offsetSdr(value: [number, number, number]);
|
|
29
38
|
/**
|
|
30
|
-
*
|
|
39
|
+
* @see {@link GainmapEncodingParameters.minContentBoost}
|
|
40
|
+
* @remarks Non logarithmic space
|
|
31
41
|
*/
|
|
32
42
|
get minContentBoost(): number;
|
|
33
43
|
set minContentBoost(value: number);
|
|
34
44
|
/**
|
|
35
|
-
*
|
|
45
|
+
* @see {@link GainmapEncodingParameters.maxContentBoost}
|
|
46
|
+
* @remarks Non logarithmic space
|
|
36
47
|
*/
|
|
37
48
|
get maxContentBoost(): number;
|
|
38
49
|
set maxContentBoost(value: number);
|
|
50
|
+
/**
|
|
51
|
+
* @see {@link GainMapMetadata.gainMapMin}
|
|
52
|
+
* @remarks Logarithmic space
|
|
53
|
+
*/
|
|
39
54
|
get gainMapMin(): [number, number, number];
|
|
55
|
+
/**
|
|
56
|
+
* @see {@link GainMapMetadata.gainMapMax}
|
|
57
|
+
* @remarks Logarithmic space
|
|
58
|
+
*/
|
|
40
59
|
get gainMapMax(): [number, number, number];
|
|
60
|
+
/**
|
|
61
|
+
* @see {@link GainMapMetadata.hdrCapacityMin}
|
|
62
|
+
* @remarks Logarithmic space
|
|
63
|
+
*/
|
|
41
64
|
get hdrCapacityMin(): number;
|
|
65
|
+
/**
|
|
66
|
+
* @see {@link GainMapMetadata.hdrCapacityMax}
|
|
67
|
+
* @remarks Logarithmic space
|
|
68
|
+
*/
|
|
42
69
|
get hdrCapacityMax(): number;
|
|
43
70
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export type GainMapMetadata = {
|
|
|
27
27
|
* @remarks
|
|
28
28
|
* * This value also affects how much to apply the gain map based on the display boost.
|
|
29
29
|
* * Must be 0.0 or greater.
|
|
30
|
+
*
|
|
31
|
+
* @remarks Logarithmic space
|
|
30
32
|
*/
|
|
31
33
|
hdrCapacityMin: number;
|
|
32
34
|
/**
|
|
@@ -36,6 +38,8 @@ export type GainMapMetadata = {
|
|
|
36
38
|
* * This value also affects how much to apply the gain map based on the display boost.
|
|
37
39
|
* * Must be greater than hdrCapacityMin.
|
|
38
40
|
* * Required.
|
|
41
|
+
*
|
|
42
|
+
* @remarks Logarithmic space
|
|
39
43
|
*/
|
|
40
44
|
hdrCapacityMax: number;
|
|
41
45
|
/**
|
|
@@ -84,6 +88,8 @@ export type GainmapEncodingParameters = {
|
|
|
84
88
|
* * If, for example, the value is 0.5, then for any given pixel, the linear luminance of the displayed HDR rendition must be (at the least) 0.5x the linear luminance of the SDR rendition.
|
|
85
89
|
* * In practice, this value is typically equal to or just less than 1.0.
|
|
86
90
|
* * Always less than or equal to Max content boost.
|
|
91
|
+
*
|
|
92
|
+
* @remarks Non Logarithmic space
|
|
87
93
|
*/
|
|
88
94
|
minContentBoost?: number;
|
|
89
95
|
/**
|
|
@@ -93,6 +99,8 @@ export type GainmapEncodingParameters = {
|
|
|
93
99
|
* * This value is a constant for a particular image. For example, if the value is four, then for any given pixel, the linear luminance of the displayed HDR rendition must be, at the most, 4x the linear luminance of the SDR rendition. In practice, this means that the brighter parts of the scene can be shown up to 4x brighter.
|
|
94
100
|
* * In practice, this value is typically greater than 1.0.
|
|
95
101
|
* * Always greater than or equal to Min content boost.
|
|
102
|
+
*
|
|
103
|
+
* @remarks Non Logarithmic space
|
|
96
104
|
*/
|
|
97
105
|
maxContentBoost: number;
|
|
98
106
|
/**
|
|
@@ -119,6 +127,8 @@ export type GainmapDecodingParameters = {
|
|
|
119
127
|
* @remarks
|
|
120
128
|
* This value can change over time based on device settings and other factors,
|
|
121
129
|
* such as ambient light conditions, or how many bright pixels are on the screen.
|
|
130
|
+
*
|
|
131
|
+
* @remarks Non Logarithmic space
|
|
122
132
|
*/
|
|
123
133
|
maxDisplayBoost: number;
|
|
124
134
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ByteType, ColorSpace, FloatType, HalfFloatType, IntType, Material, ShortType, TextureDataType, UnsignedByteType, UnsignedIntType, WebGLRenderer, WebGLRenderTarget } from 'three';
|
|
1
|
+
import { ByteType, ColorSpace, DataTexture, FloatType, HalfFloatType, IntType, Material, ShortType, TextureDataType, UnsignedByteType, UnsignedIntType, WebGLRenderer, WebGLRenderTarget } from 'three';
|
|
2
2
|
/**
|
|
3
3
|
* @category General
|
|
4
4
|
* @group General
|
|
@@ -43,6 +43,7 @@ export declare class QuadRenderer<TType extends TextureDataType, TMaterial exten
|
|
|
43
43
|
* @returns
|
|
44
44
|
*/
|
|
45
45
|
toArray(): TextureDataTypeToBufferType<TType>;
|
|
46
|
+
toDataTexture(): DataTexture;
|
|
46
47
|
/**
|
|
47
48
|
* If using a disposable renderer, it will dispose it.
|
|
48
49
|
*/
|
package/dist/worker-interface.js
CHANGED
package/dist/worker.js
CHANGED
package/dist/worker.umd.js
CHANGED