@monogrid/gainmap-js 2.0.5 → 2.0.7
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 +16 -0
- package/README.md +10 -2
- package/dist/{QuadRenderer-bEJB0XFk.js → QuadRenderer-QXcVmgNm.js} +61 -5
- package/dist/{_commonjsHelpers-bdHH9bEd.js → _commonjsHelpers-ftl_lJMx.js} +1 -1
- package/dist/{compress-aBsBfoFB.js → compress-MvOX-rlz.js} +2 -2
- package/dist/core/QuadRenderer.d.ts +38 -1
- package/dist/decode/decode.d.ts +3 -0
- package/dist/decode/errors/GainMapNotFoundError.d.ts +2 -0
- package/dist/decode/errors/XMPMetadataNotFoundError.d.ts +2 -0
- package/dist/decode/loaders/GainMapLoader.d.ts +5 -1
- package/dist/decode/loaders/HDRJPGLoader.d.ts +9 -5
- package/dist/decode/loaders/LoaderBase.d.ts +12 -9
- package/dist/decode/utils/get-html-image-from-blob.d.ts +7 -0
- package/dist/decode.js +130 -55
- package/dist/decode.umd.js +187 -56
- package/dist/encode/encode.d.ts +4 -1
- package/dist/encode.js +31 -14
- package/dist/encode.umd.js +88 -15
- package/dist/libultrahdr.js +5 -3
- package/dist/libultrahdr.umd.js +5 -3
- package/dist/worker-interface.js +2 -2
- package/dist/worker-interface.umd.js +1 -1
- package/dist/worker.js +7 -4
- package/dist/worker.umd.js +6 -3
- package/package.json +23 -18
package/dist/decode.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v2.0.
|
|
2
|
+
* @monogrid/gainmap-js v2.0.6
|
|
3
3
|
* With ❤️, by MONOGRID <hello@mono-grid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Q as QuadRenderer } from './QuadRenderer-
|
|
7
|
-
import { ShaderMaterial, Vector3, NoBlending, SRGBColorSpace,
|
|
6
|
+
import { Q as QuadRenderer } from './QuadRenderer-QXcVmgNm.js';
|
|
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 */ `
|
|
10
10
|
varying vec2 vUv;
|
|
@@ -196,6 +196,9 @@ class GainMapDecoderMaterial extends ShaderMaterial {
|
|
|
196
196
|
* scene.add(mesh)
|
|
197
197
|
* renderer.render(scene, new PerspectiveCamera())
|
|
198
198
|
*
|
|
199
|
+
* // result must be manually disposed
|
|
200
|
+
* // when you are done using it
|
|
201
|
+
* result.dispose()
|
|
199
202
|
*
|
|
200
203
|
* @param params
|
|
201
204
|
* @returns
|
|
@@ -208,26 +211,35 @@ const decode = (params) => {
|
|
|
208
211
|
sdr.colorSpace = SRGBColorSpace;
|
|
209
212
|
}
|
|
210
213
|
sdr.needsUpdate = true;
|
|
211
|
-
if (gainMap.colorSpace !==
|
|
212
|
-
console.warn('Gainmap Colorspace needs to be *
|
|
213
|
-
gainMap.colorSpace =
|
|
214
|
+
if (gainMap.colorSpace !== LinearSRGBColorSpace) {
|
|
215
|
+
console.warn('Gainmap Colorspace needs to be *LinearSRGBColorSpace*');
|
|
216
|
+
gainMap.colorSpace = LinearSRGBColorSpace;
|
|
214
217
|
}
|
|
215
218
|
gainMap.needsUpdate = true;
|
|
216
|
-
const material = new GainMapDecoderMaterial(
|
|
217
|
-
|
|
219
|
+
const material = new GainMapDecoderMaterial({
|
|
220
|
+
...params,
|
|
221
|
+
sdr,
|
|
222
|
+
gainMap
|
|
223
|
+
});
|
|
218
224
|
// TODO: three types are generic, eslint complains here, see how we can solve
|
|
219
225
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
220
|
-
const quadRenderer = new QuadRenderer(sdr.image.width, sdr.image.height, HalfFloatType,
|
|
226
|
+
const quadRenderer = new QuadRenderer(sdr.image.width, sdr.image.height, HalfFloatType, LinearSRGBColorSpace, material, renderer);
|
|
221
227
|
try {
|
|
222
228
|
quadRenderer.render();
|
|
223
229
|
}
|
|
224
230
|
catch (e) {
|
|
225
|
-
quadRenderer.
|
|
231
|
+
quadRenderer.disposeOnDemandRenderer();
|
|
226
232
|
throw e;
|
|
227
233
|
}
|
|
228
234
|
return quadRenderer;
|
|
229
235
|
};
|
|
230
236
|
|
|
237
|
+
class GainMapNotFoundError extends Error {
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
class XMPMetadataNotFoundError extends Error {
|
|
241
|
+
}
|
|
242
|
+
|
|
231
243
|
const getAttribute = (description, name, defaultValue) => {
|
|
232
244
|
var _a;
|
|
233
245
|
let returnValue;
|
|
@@ -263,7 +275,7 @@ const getAttribute = (description, name, defaultValue) => {
|
|
|
263
275
|
const extractXMP = (input) => {
|
|
264
276
|
var _a, _b;
|
|
265
277
|
let str;
|
|
266
|
-
// support node test
|
|
278
|
+
// support node test environment
|
|
267
279
|
if (typeof TextDecoder !== 'undefined')
|
|
268
280
|
str = new TextDecoder().decode(input);
|
|
269
281
|
else
|
|
@@ -330,7 +342,7 @@ class MPFExtractor {
|
|
|
330
342
|
// If you're executing this line on a big endian machine, it'll be reversed.
|
|
331
343
|
// bigEnd further down though, refers to the endianness of the image itself.
|
|
332
344
|
if (dataView.getUint16(0) !== 0xffd8) {
|
|
333
|
-
reject('Not a valid jpeg');
|
|
345
|
+
reject(new Error('Not a valid jpeg'));
|
|
334
346
|
return;
|
|
335
347
|
}
|
|
336
348
|
const length = dataView.byteLength;
|
|
@@ -339,11 +351,11 @@ class MPFExtractor {
|
|
|
339
351
|
let marker; // APP# marker
|
|
340
352
|
while (offset < length) {
|
|
341
353
|
if (++loops > 250) {
|
|
342
|
-
reject(`Found no marker after ${loops} loops 😵`);
|
|
354
|
+
reject(new Error(`Found no marker after ${loops} loops 😵`));
|
|
343
355
|
return;
|
|
344
356
|
}
|
|
345
357
|
if (dataView.getUint8(offset) !== 0xff) {
|
|
346
|
-
reject(`Not a valid marker at offset 0x${offset.toString(16)}, found: 0x${dataView.getUint8(offset).toString(16)}`);
|
|
358
|
+
reject(new Error(`Not a valid marker at offset 0x${offset.toString(16)}, found: 0x${dataView.getUint8(offset).toString(16)}`));
|
|
347
359
|
return;
|
|
348
360
|
}
|
|
349
361
|
marker = dataView.getUint8(offset + 1);
|
|
@@ -383,18 +395,18 @@ class MPFExtractor {
|
|
|
383
395
|
bigEnd = true;
|
|
384
396
|
}
|
|
385
397
|
else {
|
|
386
|
-
reject('No valid endianness marker found in TIFF header');
|
|
398
|
+
reject(new Error('No valid endianness marker found in TIFF header'));
|
|
387
399
|
return;
|
|
388
400
|
}
|
|
389
401
|
if (dataView.getUint16(tiffOffset + 2, !bigEnd) !== 0x002a) {
|
|
390
|
-
reject('Not valid TIFF data! (no 0x002A marker)');
|
|
402
|
+
reject(new Error('Not valid TIFF data! (no 0x002A marker)'));
|
|
391
403
|
return;
|
|
392
404
|
}
|
|
393
405
|
// 32 bit number stating the offset from the start of the 8 Byte MP Header
|
|
394
406
|
// to MP Index IFD Least possible value is thus 8 (means 0 offset)
|
|
395
407
|
const firstIFDOffset = dataView.getUint32(tiffOffset + 4, !bigEnd);
|
|
396
408
|
if (firstIFDOffset < 0x00000008) {
|
|
397
|
-
reject('Not valid TIFF data! (First offset less than 8)');
|
|
409
|
+
reject(new Error('Not valid TIFF data! (First offset less than 8)'));
|
|
398
410
|
return;
|
|
399
411
|
}
|
|
400
412
|
// Move ahead to MP Index IFD
|
|
@@ -490,11 +502,11 @@ class MPFExtractor {
|
|
|
490
502
|
const extractGainmapFromJPEG = async (jpegFile) => {
|
|
491
503
|
const metadata = extractXMP(jpegFile);
|
|
492
504
|
if (!metadata)
|
|
493
|
-
throw new
|
|
505
|
+
throw new XMPMetadataNotFoundError('Gain map XMP metadata not found');
|
|
494
506
|
const mpfExtractor = new MPFExtractor({ extractFII: true, extractNonFII: true });
|
|
495
507
|
const images = await mpfExtractor.extract(jpegFile);
|
|
496
508
|
if (images.length !== 2)
|
|
497
|
-
throw new
|
|
509
|
+
throw new GainMapNotFoundError('Gain map recovery image not found');
|
|
498
510
|
return {
|
|
499
511
|
sdr: new Uint8Array(await images[0].arrayBuffer()),
|
|
500
512
|
gainMap: new Uint8Array(await images[1].arrayBuffer()),
|
|
@@ -508,7 +520,7 @@ const extractGainmapFromJPEG = async (jpegFile) => {
|
|
|
508
520
|
* @param blob
|
|
509
521
|
* @returns
|
|
510
522
|
*/
|
|
511
|
-
const
|
|
523
|
+
const getHTMLImageFromBlob = (blob) => {
|
|
512
524
|
return new Promise((resolve, reject) => {
|
|
513
525
|
const img = document.createElement('img');
|
|
514
526
|
img.onload = () => { resolve(img); };
|
|
@@ -516,6 +528,7 @@ const getImage = (blob) => {
|
|
|
516
528
|
img.src = URL.createObjectURL(blob);
|
|
517
529
|
});
|
|
518
530
|
};
|
|
531
|
+
|
|
519
532
|
class LoaderBase extends Loader {
|
|
520
533
|
/**
|
|
521
534
|
*
|
|
@@ -524,7 +537,8 @@ class LoaderBase extends Loader {
|
|
|
524
537
|
*/
|
|
525
538
|
constructor(renderer, manager) {
|
|
526
539
|
super(manager);
|
|
527
|
-
this.
|
|
540
|
+
this._renderer = renderer;
|
|
541
|
+
this._internalLoadingManager = new LoadingManager();
|
|
528
542
|
}
|
|
529
543
|
/**
|
|
530
544
|
* @private
|
|
@@ -544,26 +558,26 @@ class LoaderBase extends Loader {
|
|
|
544
558
|
gainMap: new Texture(),
|
|
545
559
|
sdr: new Texture()
|
|
546
560
|
});
|
|
547
|
-
return new QuadRenderer(16, 16, HalfFloatType,
|
|
561
|
+
return new QuadRenderer(16, 16, HalfFloatType, LinearSRGBColorSpace, material, this._renderer);
|
|
548
562
|
}
|
|
549
563
|
/**
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
const gainMapBlob = new Blob([gainMapBuffer], { type: 'image/jpeg' });
|
|
564
|
+
* @private
|
|
565
|
+
* @param quadRenderer
|
|
566
|
+
* @param metadata
|
|
567
|
+
* @param sdrBuffer
|
|
568
|
+
* @param gainMapBuffer
|
|
569
|
+
*/
|
|
570
|
+
async render(quadRenderer, metadata, sdrBuffer, gainMapBuffer) {
|
|
571
|
+
// this is optional, will render a black gain-map if not present
|
|
572
|
+
const gainMapBlob = gainMapBuffer ? new Blob([gainMapBuffer], { type: 'image/jpeg' }) : undefined;
|
|
559
573
|
const sdrBlob = new Blob([sdrBuffer], { type: 'image/jpeg' });
|
|
560
574
|
let sdrImage;
|
|
561
575
|
let gainMapImage;
|
|
562
576
|
let needsFlip = false;
|
|
563
577
|
if (typeof createImageBitmap === 'undefined') {
|
|
564
578
|
const res = await Promise.all([
|
|
565
|
-
|
|
566
|
-
|
|
579
|
+
gainMapBlob ? getHTMLImageFromBlob(gainMapBlob) : Promise.resolve(undefined),
|
|
580
|
+
getHTMLImageFromBlob(sdrBlob)
|
|
567
581
|
]);
|
|
568
582
|
gainMapImage = res[0];
|
|
569
583
|
sdrImage = res[1];
|
|
@@ -571,13 +585,13 @@ class LoaderBase extends Loader {
|
|
|
571
585
|
}
|
|
572
586
|
else {
|
|
573
587
|
const res = await Promise.all([
|
|
574
|
-
createImageBitmap(gainMapBlob, { imageOrientation: 'flipY' }),
|
|
588
|
+
gainMapBlob ? createImageBitmap(gainMapBlob, { imageOrientation: 'flipY' }) : Promise.resolve(undefined),
|
|
575
589
|
createImageBitmap(sdrBlob, { imageOrientation: 'flipY' })
|
|
576
590
|
]);
|
|
577
591
|
gainMapImage = res[0];
|
|
578
592
|
sdrImage = res[1];
|
|
579
593
|
}
|
|
580
|
-
const gainMap = new Texture(gainMapImage, UVMapping, ClampToEdgeWrapping, ClampToEdgeWrapping, LinearFilter, LinearMipMapLinearFilter, RGBAFormat, UnsignedByteType, 1,
|
|
594
|
+
const gainMap = new Texture(gainMapImage || new ImageData(2, 2), UVMapping, ClampToEdgeWrapping, ClampToEdgeWrapping, LinearFilter, LinearMipMapLinearFilter, RGBAFormat, UnsignedByteType, 1, LinearSRGBColorSpace);
|
|
581
595
|
gainMap.flipY = needsFlip;
|
|
582
596
|
gainMap.needsUpdate = true;
|
|
583
597
|
const sdr = new Texture(sdrImage, UVMapping, ClampToEdgeWrapping, ClampToEdgeWrapping, LinearFilter, LinearMipMapLinearFilter, RGBAFormat, UnsignedByteType, 1, SRGBColorSpace);
|
|
@@ -623,7 +637,7 @@ class LoaderBase extends Loader {
|
|
|
623
637
|
*
|
|
624
638
|
* const loader = new GainMapLoader(renderer)
|
|
625
639
|
*
|
|
626
|
-
* const result = loader.
|
|
640
|
+
* const result = await loader.loadAsync(['sdr.jpeg', 'gainmap.jpeg', 'metadata.json'])
|
|
627
641
|
* // `result` can be used to populate a Texture
|
|
628
642
|
*
|
|
629
643
|
* const scene = new Scene()
|
|
@@ -643,6 +657,10 @@ class LoaderBase extends Loader {
|
|
|
643
657
|
* scene.background.mapping = EquirectangularReflectionMapping
|
|
644
658
|
* scene.background.minFilter = LinearFilter
|
|
645
659
|
*
|
|
660
|
+
* // result must be manually disposed
|
|
661
|
+
* // when you are done using it
|
|
662
|
+
* result.dispose()
|
|
663
|
+
*
|
|
646
664
|
*/
|
|
647
665
|
class GainMapLoader extends LoaderBase {
|
|
648
666
|
/**
|
|
@@ -666,10 +684,13 @@ class GainMapLoader extends LoaderBase {
|
|
|
666
684
|
let metadata;
|
|
667
685
|
const loadCheck = async () => {
|
|
668
686
|
if (sdr && gainMap && metadata) {
|
|
669
|
-
await this.render(quadRenderer,
|
|
687
|
+
await this.render(quadRenderer, metadata, sdr, gainMap);
|
|
670
688
|
if (typeof onLoad === 'function')
|
|
671
689
|
onLoad(quadRenderer);
|
|
672
|
-
|
|
690
|
+
this.manager.itemEnd(sdrUrl);
|
|
691
|
+
this.manager.itemEnd(gainMapUrl);
|
|
692
|
+
this.manager.itemEnd(metadataUrl);
|
|
693
|
+
quadRenderer.disposeOnDemandRenderer();
|
|
673
694
|
}
|
|
674
695
|
};
|
|
675
696
|
let sdrLengthComputable = true;
|
|
@@ -689,7 +710,10 @@ class GainMapLoader extends LoaderBase {
|
|
|
689
710
|
onProgress(new ProgressEvent('progress', { lengthComputable, loaded, total }));
|
|
690
711
|
}
|
|
691
712
|
};
|
|
692
|
-
|
|
713
|
+
this.manager.itemStart(sdrUrl);
|
|
714
|
+
this.manager.itemStart(gainMapUrl);
|
|
715
|
+
this.manager.itemStart(metadataUrl);
|
|
716
|
+
const sdrLoader = new FileLoader(this._internalLoadingManager);
|
|
693
717
|
sdrLoader.setResponseType('arraybuffer');
|
|
694
718
|
sdrLoader.setRequestHeader(this.requestHeader);
|
|
695
719
|
sdrLoader.setPath(this.path);
|
|
@@ -704,8 +728,12 @@ class GainMapLoader extends LoaderBase {
|
|
|
704
728
|
sdrLoaded = e.loaded;
|
|
705
729
|
sdrTotal = e.total;
|
|
706
730
|
progressHandler();
|
|
707
|
-
},
|
|
708
|
-
|
|
731
|
+
}, (error) => {
|
|
732
|
+
this.manager.itemError(sdrUrl);
|
|
733
|
+
if (typeof onError === 'function')
|
|
734
|
+
onError(error);
|
|
735
|
+
});
|
|
736
|
+
const gainMapLoader = new FileLoader(this._internalLoadingManager);
|
|
709
737
|
gainMapLoader.setResponseType('arraybuffer');
|
|
710
738
|
gainMapLoader.setRequestHeader(this.requestHeader);
|
|
711
739
|
gainMapLoader.setPath(this.path);
|
|
@@ -720,8 +748,12 @@ class GainMapLoader extends LoaderBase {
|
|
|
720
748
|
gainMapLoaded = e.loaded;
|
|
721
749
|
gainMapTotal = e.total;
|
|
722
750
|
progressHandler();
|
|
723
|
-
},
|
|
724
|
-
|
|
751
|
+
}, (error) => {
|
|
752
|
+
this.manager.itemError(gainMapUrl);
|
|
753
|
+
if (typeof onError === 'function')
|
|
754
|
+
onError(error);
|
|
755
|
+
});
|
|
756
|
+
const metadataLoader = new FileLoader(this._internalLoadingManager);
|
|
725
757
|
// metadataLoader.setResponseType('json')
|
|
726
758
|
metadataLoader.setRequestHeader(this.requestHeader);
|
|
727
759
|
metadataLoader.setPath(this.path);
|
|
@@ -738,7 +770,11 @@ class GainMapLoader extends LoaderBase {
|
|
|
738
770
|
metadataLoaded = e.loaded;
|
|
739
771
|
metadataTotal = e.total;
|
|
740
772
|
progressHandler();
|
|
741
|
-
},
|
|
773
|
+
}, (error) => {
|
|
774
|
+
this.manager.itemError(metadataUrl);
|
|
775
|
+
if (typeof onError === 'function')
|
|
776
|
+
onError(error);
|
|
777
|
+
});
|
|
742
778
|
return quadRenderer;
|
|
743
779
|
}
|
|
744
780
|
}
|
|
@@ -750,7 +786,7 @@ class GainMapLoader extends LoaderBase {
|
|
|
750
786
|
* @group Loaders
|
|
751
787
|
*
|
|
752
788
|
* @example
|
|
753
|
-
* import {
|
|
789
|
+
* import { HDRJPGLoader } from '@monogrid/gainmap-js'
|
|
754
790
|
* import {
|
|
755
791
|
* EquirectangularReflectionMapping,
|
|
756
792
|
* LinearFilter,
|
|
@@ -764,9 +800,9 @@ class GainMapLoader extends LoaderBase {
|
|
|
764
800
|
*
|
|
765
801
|
* const renderer = new WebGLRenderer()
|
|
766
802
|
*
|
|
767
|
-
* const loader = new
|
|
803
|
+
* const loader = new HDRJPGLoader(renderer)
|
|
768
804
|
*
|
|
769
|
-
* const result = loader.
|
|
805
|
+
* const result = await loader.loadAsync('gainmap.jpeg')
|
|
770
806
|
* // `result` can be used to populate a Texture
|
|
771
807
|
*
|
|
772
808
|
* const scene = new Scene()
|
|
@@ -785,12 +821,16 @@ class GainMapLoader extends LoaderBase {
|
|
|
785
821
|
* scene.background = result.toDataTexture()
|
|
786
822
|
* scene.background.mapping = EquirectangularReflectionMapping
|
|
787
823
|
* scene.background.minFilter = LinearFilter
|
|
788
|
-
|
|
824
|
+
*
|
|
825
|
+
* // result must be manually disposed
|
|
826
|
+
* // when you are done using it
|
|
827
|
+
* result.dispose()
|
|
789
828
|
*
|
|
790
829
|
*/
|
|
791
830
|
class HDRJPGLoader extends LoaderBase {
|
|
792
831
|
/**
|
|
793
|
-
* Loads a
|
|
832
|
+
* Loads a JPEG containing gain map metadata
|
|
833
|
+
* Renders a normal SDR image if gainmap data is not found
|
|
794
834
|
*
|
|
795
835
|
* @param url An array in the form of [sdr.jpg, gainmap.jpg, metadata.json]
|
|
796
836
|
* @param onLoad Load complete callback, will receive the result
|
|
@@ -800,20 +840,55 @@ class HDRJPGLoader extends LoaderBase {
|
|
|
800
840
|
*/
|
|
801
841
|
load(url, onLoad, onProgress, onError) {
|
|
802
842
|
const quadRenderer = this.prepareQuadRenderer();
|
|
803
|
-
const loader = new FileLoader(this.
|
|
843
|
+
const loader = new FileLoader(this._internalLoadingManager);
|
|
804
844
|
loader.setResponseType('arraybuffer');
|
|
805
845
|
loader.setRequestHeader(this.requestHeader);
|
|
806
846
|
loader.setPath(this.path);
|
|
807
847
|
loader.setWithCredentials(this.withCredentials);
|
|
848
|
+
this.manager.itemStart(url);
|
|
808
849
|
loader.load(url, async (jpeg) => {
|
|
809
850
|
if (typeof jpeg === 'string')
|
|
810
|
-
throw new Error('Invalid buffer');
|
|
811
|
-
const
|
|
812
|
-
|
|
851
|
+
throw new Error('Invalid buffer, received [string], was expecting [ArrayBuffer]');
|
|
852
|
+
const jpegBuffer = new Uint8Array(jpeg);
|
|
853
|
+
let sdrJPEG;
|
|
854
|
+
let gainMapJPEG;
|
|
855
|
+
let metadata;
|
|
856
|
+
try {
|
|
857
|
+
const extractionResult = await extractGainmapFromJPEG(jpegBuffer);
|
|
858
|
+
// gain map is successfully reconstructed
|
|
859
|
+
sdrJPEG = extractionResult.sdr;
|
|
860
|
+
gainMapJPEG = extractionResult.gainMap;
|
|
861
|
+
metadata = extractionResult.metadata;
|
|
862
|
+
}
|
|
863
|
+
catch (e) {
|
|
864
|
+
// render the SDR version if this is not a gainmap
|
|
865
|
+
if (e instanceof XMPMetadataNotFoundError || e instanceof GainMapNotFoundError) {
|
|
866
|
+
console.warn(`Failure to reconstruct an HDR image from ${url}: Gain map metadata not found in the file, HDRJPGLoader will render the SDR jpeg`);
|
|
867
|
+
metadata = {
|
|
868
|
+
gainMapMin: [0, 0, 0],
|
|
869
|
+
gainMapMax: [1, 1, 1],
|
|
870
|
+
gamma: [1, 1, 1],
|
|
871
|
+
hdrCapacityMin: 0,
|
|
872
|
+
hdrCapacityMax: 1,
|
|
873
|
+
offsetHdr: [0, 0, 0],
|
|
874
|
+
offsetSdr: [0, 0, 0]
|
|
875
|
+
};
|
|
876
|
+
sdrJPEG = jpegBuffer;
|
|
877
|
+
}
|
|
878
|
+
else {
|
|
879
|
+
throw e;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
await this.render(quadRenderer, metadata, sdrJPEG, gainMapJPEG);
|
|
813
883
|
if (typeof onLoad === 'function')
|
|
814
884
|
onLoad(quadRenderer);
|
|
815
|
-
|
|
816
|
-
|
|
885
|
+
this.manager.itemEnd(url);
|
|
886
|
+
quadRenderer.disposeOnDemandRenderer();
|
|
887
|
+
}, onProgress, (error) => {
|
|
888
|
+
this.manager.itemError(url);
|
|
889
|
+
if (typeof onError === 'function')
|
|
890
|
+
onError(error);
|
|
891
|
+
});
|
|
817
892
|
return quadRenderer;
|
|
818
893
|
}
|
|
819
894
|
}
|