@babylonjs/viewer 7.22.5 → 7.23.0-alpha
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/dist/babylon-viewer.esm.js +2 -0
- package/dist/babylon-viewer.esm.js.map +1 -0
- package/dist/babylon-viewer.esm.min.js +2 -0
- package/dist/babylon-viewer.esm.min.js.map +1 -0
- package/dist/chunks/basisTextureLoader-BnIeLUi5.esm.min.js +2 -0
- package/dist/chunks/basisTextureLoader-BnIeLUi5.esm.min.js.map +1 -0
- package/dist/chunks/basisTextureLoader-D5DAa_qR.esm.js +600 -0
- package/dist/chunks/basisTextureLoader-D5DAa_qR.esm.js.map +1 -0
- package/dist/chunks/ddsTextureLoader-D9xNsYAT.esm.min.js +2 -0
- package/dist/chunks/ddsTextureLoader-D9xNsYAT.esm.min.js.map +1 -0
- package/dist/chunks/ddsTextureLoader-DCv39Yn8.esm.js +87 -0
- package/dist/chunks/ddsTextureLoader-DCv39Yn8.esm.js.map +1 -0
- package/dist/chunks/envTextureLoader-Cmuugxf1.esm.min.js +2 -0
- package/dist/chunks/envTextureLoader-Cmuugxf1.esm.min.js.map +1 -0
- package/dist/chunks/envTextureLoader-Dl0xiO1G.esm.js +62 -0
- package/dist/chunks/envTextureLoader-Dl0xiO1G.esm.js.map +1 -0
- package/dist/chunks/exrTextureLoader-C0UEUMfH.esm.js +1682 -0
- package/dist/chunks/exrTextureLoader-C0UEUMfH.esm.js.map +1 -0
- package/dist/chunks/exrTextureLoader-DVZGHvAz.esm.min.js +2 -0
- package/dist/chunks/exrTextureLoader-DVZGHvAz.esm.min.js.map +1 -0
- package/dist/chunks/hdrTextureLoader-BM271mLj.esm.min.js +2 -0
- package/dist/chunks/hdrTextureLoader-BM271mLj.esm.min.js.map +1 -0
- package/dist/chunks/hdrTextureLoader-CrHh5vTV.esm.js +252 -0
- package/dist/chunks/hdrTextureLoader-CrHh5vTV.esm.js.map +1 -0
- package/dist/chunks/helperFunctions-BQ8X1piK.esm.min.js +2 -0
- package/dist/chunks/helperFunctions-BQ8X1piK.esm.min.js.map +1 -0
- package/dist/chunks/helperFunctions-CUX6uz_w.esm.js +108 -0
- package/dist/chunks/helperFunctions-CUX6uz_w.esm.js.map +1 -0
- package/dist/chunks/helperFunctions-ChWwJuKv.esm.min.js +2 -0
- package/dist/chunks/helperFunctions-ChWwJuKv.esm.min.js.map +1 -0
- package/dist/chunks/helperFunctions-DpMCqZKL.esm.js +80 -0
- package/dist/chunks/helperFunctions-DpMCqZKL.esm.js.map +1 -0
- package/dist/chunks/index-DHuuBhpP.esm.js +102146 -0
- package/dist/chunks/index-DHuuBhpP.esm.js.map +1 -0
- package/dist/chunks/index-EA8kJjBu.esm.min.js +56 -0
- package/dist/chunks/index-EA8kJjBu.esm.min.js.map +1 -0
- package/dist/chunks/ktxTextureLoader-BRR5FQro.esm.min.js +2 -0
- package/dist/chunks/ktxTextureLoader-BRR5FQro.esm.min.js.map +1 -0
- package/dist/chunks/ktxTextureLoader-gZQU7w7m.esm.js +813 -0
- package/dist/chunks/ktxTextureLoader-gZQU7w7m.esm.js.map +1 -0
- package/dist/chunks/logDepthDeclaration-B1MaqbwG.esm.min.js +2 -0
- package/dist/chunks/logDepthDeclaration-B1MaqbwG.esm.min.js.map +1 -0
- package/dist/chunks/logDepthDeclaration-B2UkQWK5.esm.min.js +2 -0
- package/dist/chunks/logDepthDeclaration-B2UkQWK5.esm.min.js.map +1 -0
- package/dist/chunks/logDepthDeclaration-COhUDa1N.esm.js +73 -0
- package/dist/chunks/logDepthDeclaration-COhUDa1N.esm.js.map +1 -0
- package/dist/chunks/logDepthDeclaration-CojhsbFY.esm.js +76 -0
- package/dist/chunks/logDepthDeclaration-CojhsbFY.esm.js.map +1 -0
- package/dist/chunks/pass.fragment-BNKAdmAy.esm.min.js +2 -0
- package/dist/chunks/pass.fragment-BNKAdmAy.esm.min.js.map +1 -0
- package/dist/chunks/pass.fragment-CDiei_Sn.esm.js +15 -0
- package/dist/chunks/pass.fragment-CDiei_Sn.esm.js.map +1 -0
- package/dist/chunks/pbr.fragment-BN71FgFx.esm.min.js +2 -0
- package/dist/chunks/pbr.fragment-BN71FgFx.esm.min.js.map +1 -0
- package/dist/chunks/pbr.fragment-BvCEmvwh.esm.js +4530 -0
- package/dist/chunks/pbr.fragment-BvCEmvwh.esm.js.map +1 -0
- package/dist/chunks/pbr.fragment-DU4hy3T_.esm.min.js +2 -0
- package/dist/chunks/pbr.fragment-DU4hy3T_.esm.min.js.map +1 -0
- package/dist/chunks/pbr.fragment-QxF1RFoh.esm.js +4323 -0
- package/dist/chunks/pbr.fragment-QxF1RFoh.esm.js.map +1 -0
- package/dist/chunks/pbr.vertex-62J9fbA6.esm.js +932 -0
- package/dist/chunks/pbr.vertex-62J9fbA6.esm.js.map +1 -0
- package/dist/chunks/pbr.vertex-C8vOdMd6.esm.min.js +2 -0
- package/dist/chunks/pbr.vertex-C8vOdMd6.esm.min.js.map +1 -0
- package/dist/chunks/pbr.vertex-Cp4yABqq.esm.js +809 -0
- package/dist/chunks/pbr.vertex-Cp4yABqq.esm.js.map +1 -0
- package/dist/chunks/pbr.vertex-DPPPQSbX.esm.min.js +2 -0
- package/dist/chunks/pbr.vertex-DPPPQSbX.esm.min.js.map +1 -0
- package/dist/chunks/postprocess.vertex-5WWqPw1s.esm.js +20 -0
- package/dist/chunks/postprocess.vertex-5WWqPw1s.esm.js.map +1 -0
- package/dist/chunks/postprocess.vertex-DzqXlss5.esm.min.js +2 -0
- package/dist/chunks/postprocess.vertex-DzqXlss5.esm.min.js.map +1 -0
- package/dist/chunks/rgbdDecode.fragment-BdggM8VZ.esm.min.js +2 -0
- package/dist/chunks/rgbdDecode.fragment-BdggM8VZ.esm.min.js.map +1 -0
- package/dist/chunks/rgbdDecode.fragment-Bpslxg4R.esm.js +17 -0
- package/dist/chunks/rgbdDecode.fragment-Bpslxg4R.esm.js.map +1 -0
- package/dist/chunks/rgbdDecode.fragment-By7Rc7Xz.esm.js +17 -0
- package/dist/chunks/rgbdDecode.fragment-By7Rc7Xz.esm.js.map +1 -0
- package/dist/chunks/rgbdDecode.fragment-CnUoEV03.esm.min.js +2 -0
- package/dist/chunks/rgbdDecode.fragment-CnUoEV03.esm.min.js.map +1 -0
- package/dist/chunks/rgbdEncode.fragment-BBl79-3e.esm.js +17 -0
- package/dist/chunks/rgbdEncode.fragment-BBl79-3e.esm.js.map +1 -0
- package/dist/chunks/rgbdEncode.fragment-BGkuZmHn.esm.min.js +2 -0
- package/dist/chunks/rgbdEncode.fragment-BGkuZmHn.esm.min.js.map +1 -0
- package/dist/chunks/rgbdEncode.fragment-LUPpF87m.esm.min.js +2 -0
- package/dist/chunks/rgbdEncode.fragment-LUPpF87m.esm.min.js.map +1 -0
- package/dist/chunks/rgbdEncode.fragment-PJDNuVns.esm.js +17 -0
- package/dist/chunks/rgbdEncode.fragment-PJDNuVns.esm.js.map +1 -0
- package/dist/chunks/tgaTextureLoader-CccJYauf.esm.min.js +2 -0
- package/dist/chunks/tgaTextureLoader-CccJYauf.esm.min.js.map +1 -0
- package/dist/chunks/tgaTextureLoader-DdDpL5u3.esm.js +349 -0
- package/dist/chunks/tgaTextureLoader-DdDpL5u3.esm.js.map +1 -0
- package/lib/index.d.ts +237 -0
- package/lib/index.js +869 -0
- package/lib/index.js.map +1 -0
- package/package.json +17 -27
- package/readme.md +35 -21
- package/configuration/configuration.d.ts +0 -107
- package/configuration/configuration.js +0 -16
- package/configuration/configuration.js.map +0 -1
- package/configuration/configurationCompatibility.d.ts +0 -8
- package/configuration/configurationCompatibility.js +0 -66
- package/configuration/configurationCompatibility.js.map +0 -1
- package/configuration/configurationContainer.d.ts +0 -10
- package/configuration/configurationContainer.js +0 -10
- package/configuration/configurationContainer.js.map +0 -1
- package/configuration/globals.d.ts +0 -6
- package/configuration/globals.js +0 -18
- package/configuration/globals.js.map +0 -1
- package/configuration/index.d.ts +0 -2
- package/configuration/index.js +0 -4
- package/configuration/index.js.map +0 -1
- package/configuration/interfaces/cameraConfiguration.d.ts +0 -31
- package/configuration/interfaces/cameraConfiguration.js +0 -2
- package/configuration/interfaces/cameraConfiguration.js.map +0 -1
- package/configuration/interfaces/colorGradingConfiguration.d.ts +0 -81
- package/configuration/interfaces/colorGradingConfiguration.js +0 -2
- package/configuration/interfaces/colorGradingConfiguration.js.map +0 -1
- package/configuration/interfaces/defaultRenderingPipelineConfiguration.d.ts +0 -20
- package/configuration/interfaces/defaultRenderingPipelineConfiguration.js +0 -2
- package/configuration/interfaces/defaultRenderingPipelineConfiguration.js.map +0 -1
- package/configuration/interfaces/environmentMapConfiguration.d.ts +0 -22
- package/configuration/interfaces/environmentMapConfiguration.js +0 -2
- package/configuration/interfaces/environmentMapConfiguration.js.map +0 -1
- package/configuration/interfaces/groundConfiguration.d.ts +0 -24
- package/configuration/interfaces/groundConfiguration.js +0 -2
- package/configuration/interfaces/groundConfiguration.js.map +0 -1
- package/configuration/interfaces/imageProcessingConfiguration.d.ts +0 -45
- package/configuration/interfaces/imageProcessingConfiguration.js +0 -2
- package/configuration/interfaces/imageProcessingConfiguration.js.map +0 -1
- package/configuration/interfaces/index.d.ts +0 -15
- package/configuration/interfaces/index.js +0 -16
- package/configuration/interfaces/index.js.map +0 -1
- package/configuration/interfaces/lightConfiguration.d.ts +0 -60
- package/configuration/interfaces/lightConfiguration.js +0 -2
- package/configuration/interfaces/lightConfiguration.js.map +0 -1
- package/configuration/interfaces/modelAnimationConfiguration.d.ts +0 -26
- package/configuration/interfaces/modelAnimationConfiguration.js +0 -2
- package/configuration/interfaces/modelAnimationConfiguration.js.map +0 -1
- package/configuration/interfaces/modelConfiguration.d.ts +0 -65
- package/configuration/interfaces/modelConfiguration.js +0 -2
- package/configuration/interfaces/modelConfiguration.js.map +0 -1
- package/configuration/interfaces/observersConfiguration.d.ts +0 -5
- package/configuration/interfaces/observersConfiguration.js +0 -2
- package/configuration/interfaces/observersConfiguration.js.map +0 -1
- package/configuration/interfaces/sceneConfiguration.d.ts +0 -48
- package/configuration/interfaces/sceneConfiguration.js +0 -2
- package/configuration/interfaces/sceneConfiguration.js.map +0 -1
- package/configuration/interfaces/sceneOptimizerConfiguration.d.ts +0 -23
- package/configuration/interfaces/sceneOptimizerConfiguration.js +0 -2
- package/configuration/interfaces/sceneOptimizerConfiguration.js.map +0 -1
- package/configuration/interfaces/skyboxConfiguration.d.ts +0 -21
- package/configuration/interfaces/skyboxConfiguration.js +0 -2
- package/configuration/interfaces/skyboxConfiguration.js.map +0 -1
- package/configuration/interfaces/templateConfiguration.d.ts +0 -67
- package/configuration/interfaces/templateConfiguration.js +0 -2
- package/configuration/interfaces/templateConfiguration.js.map +0 -1
- package/configuration/interfaces/vrConfiguration.d.ts +0 -16
- package/configuration/interfaces/vrConfiguration.js +0 -2
- package/configuration/interfaces/vrConfiguration.js.map +0 -1
- package/configuration/loader.d.ts +0 -4
- package/configuration/loader.js +0 -17
- package/configuration/loader.js.map +0 -1
- package/configuration/mappers.d.ts +0 -43
- package/configuration/mappers.js +0 -192
- package/configuration/mappers.js.map +0 -1
- package/configuration/renderOnlyLoader.d.ts +0 -33
- package/configuration/renderOnlyLoader.js +0 -162
- package/configuration/renderOnlyLoader.js.map +0 -1
- package/configuration/types/default.d.ts +0 -6
- package/configuration/types/default.js +0 -121
- package/configuration/types/default.js.map +0 -1
- package/configuration/types/environmentMap.d.ts +0 -5
- package/configuration/types/environmentMap.js +0 -14
- package/configuration/types/environmentMap.js.map +0 -1
- package/configuration/types/extended.d.ts +0 -6
- package/configuration/types/extended.js +0 -317
- package/configuration/types/extended.js.map +0 -1
- package/configuration/types/index.d.ts +0 -14
- package/configuration/types/index.js +0 -51
- package/configuration/types/index.js.map +0 -1
- package/configuration/types/minimal.d.ts +0 -6
- package/configuration/types/minimal.js +0 -43
- package/configuration/types/minimal.js.map +0 -1
- package/configuration/types/renderOnlyDefault.d.ts +0 -30
- package/configuration/types/renderOnlyDefault.js +0 -31
- package/configuration/types/renderOnlyDefault.js.map +0 -1
- package/configuration/types/shadowLight.d.ts +0 -9
- package/configuration/types/shadowLight.js +0 -64
- package/configuration/types/shadowLight.js.map +0 -1
- package/helper/index.d.ts +0 -29
- package/helper/index.js +0 -66
- package/helper/index.js.map +0 -1
- package/index.d.ts +0 -30
- package/index.js +0 -46
- package/index.js.map +0 -1
- package/initializer.d.ts +0 -11
- package/initializer.js +0 -35
- package/initializer.js.map +0 -1
- package/interfaces.d.ts +0 -5
- package/interfaces.js +0 -7
- package/interfaces.js.map +0 -1
- package/labs/environmentSerializer.d.ts +0 -126
- package/labs/environmentSerializer.js +0 -191
- package/labs/environmentSerializer.js.map +0 -1
- package/labs/texture.d.ts +0 -183
- package/labs/texture.js +0 -351
- package/labs/texture.js.map +0 -1
- package/labs/viewerLabs.d.ts +0 -51
- package/labs/viewerLabs.js +0 -134
- package/labs/viewerLabs.js.map +0 -1
- package/loader/modelLoader.d.ts +0 -56
- package/loader/modelLoader.js +0 -199
- package/loader/modelLoader.js.map +0 -1
- package/loader/plugins/applyMaterialConfig.d.ts +0 -12
- package/loader/plugins/applyMaterialConfig.js +0 -16
- package/loader/plugins/applyMaterialConfig.js.map +0 -1
- package/loader/plugins/extendedMaterialLoaderPlugin.d.ts +0 -9
- package/loader/plugins/extendedMaterialLoaderPlugin.js +0 -16
- package/loader/plugins/extendedMaterialLoaderPlugin.js.map +0 -1
- package/loader/plugins/index.d.ts +0 -19
- package/loader/plugins/index.js +0 -44
- package/loader/plugins/index.js.map +0 -1
- package/loader/plugins/loaderPlugin.d.ts +0 -24
- package/loader/plugins/loaderPlugin.js +0 -2
- package/loader/plugins/loaderPlugin.js.map +0 -1
- package/loader/plugins/msftLodLoaderPlugin.d.ts +0 -12
- package/loader/plugins/msftLodLoaderPlugin.js +0 -21
- package/loader/plugins/msftLodLoaderPlugin.js.map +0 -1
- package/loader/plugins/telemetryLoaderPlugin.d.ts +0 -12
- package/loader/plugins/telemetryLoaderPlugin.js +0 -36
- package/loader/plugins/telemetryLoaderPlugin.js.map +0 -1
- package/managers/observablesManager.d.ts +0 -66
- package/managers/observablesManager.js +0 -35
- package/managers/observablesManager.js.map +0 -1
- package/managers/sceneManager.d.ts +0 -245
- package/managers/sceneManager.js +0 -1375
- package/managers/sceneManager.js.map +0 -1
- package/managers/telemetryManager.d.ts +0 -78
- package/managers/telemetryManager.js +0 -117
- package/managers/telemetryManager.js.map +0 -1
- package/model/modelAnimation.d.ts +0 -215
- package/model/modelAnimation.js +0 -237
- package/model/modelAnimation.js.map +0 -1
- package/model/viewerModel.d.ts +0 -233
- package/model/viewerModel.js +0 -673
- package/model/viewerModel.js.map +0 -1
- package/optimizer/custom/extended.d.ts +0 -13
- package/optimizer/custom/extended.js +0 -101
- package/optimizer/custom/extended.js.map +0 -1
- package/optimizer/custom/index.d.ts +0 -9
- package/optimizer/custom/index.js +0 -26
- package/optimizer/custom/index.js.map +0 -1
- package/renderOnlyIndex.d.ts +0 -11
- package/renderOnlyIndex.js +0 -18
- package/renderOnlyIndex.js.map +0 -1
- package/templating/eventManager.d.ts +0 -35
- package/templating/eventManager.js +0 -66
- package/templating/eventManager.js.map +0 -1
- package/templating/plugins/hdButtonPlugin.d.ts +0 -9
- package/templating/plugins/hdButtonPlugin.js +0 -21
- package/templating/plugins/hdButtonPlugin.js.map +0 -1
- package/templating/plugins/printButton.d.ts +0 -9
- package/templating/plugins/printButton.js +0 -40
- package/templating/plugins/printButton.js.map +0 -1
- package/templating/templateManager.d.ts +0 -197
- package/templating/templateManager.js +0 -561
- package/templating/templateManager.js.map +0 -1
- package/templating/viewerTemplatePlugin.d.ts +0 -21
- package/templating/viewerTemplatePlugin.js +0 -69
- package/templating/viewerTemplatePlugin.js.map +0 -1
- package/viewer/defaultViewer.d.ts +0 -130
- package/viewer/defaultViewer.js +0 -675
- package/viewer/defaultViewer.js.map +0 -1
- package/viewer/renderOnlyViewer.d.ts +0 -9
- package/viewer/renderOnlyViewer.js +0 -46
- package/viewer/renderOnlyViewer.js.map +0 -1
- package/viewer/viewer.d.ts +0 -258
- package/viewer/viewer.js +0 -783
- package/viewer/viewer.js.map +0 -1
- package/viewer/viewerManager.d.ts +0 -58
- package/viewer/viewerManager.js +0 -91
- package/viewer/viewerManager.js.map +0 -1
- package/viewer/viewerWithTemplate.d.ts +0 -9
- package/viewer/viewerWithTemplate.js +0 -20
- package/viewer/viewerWithTemplate.js.map +0 -1
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { L as Logger } from './index-DHuuBhpP.esm.js';
|
|
2
|
+
|
|
3
|
+
//private static _TYPE_NO_DATA = 0;
|
|
4
|
+
const _TYPE_INDEXED = 1;
|
|
5
|
+
const _TYPE_RGB = 2;
|
|
6
|
+
const _TYPE_GREY = 3;
|
|
7
|
+
const _TYPE_RLE_INDEXED = 9;
|
|
8
|
+
const _TYPE_RLE_RGB = 10;
|
|
9
|
+
const _TYPE_RLE_GREY = 11;
|
|
10
|
+
const _ORIGIN_MASK = 0x30;
|
|
11
|
+
const _ORIGIN_SHIFT = 0x04;
|
|
12
|
+
const _ORIGIN_BL = 0x00;
|
|
13
|
+
const _ORIGIN_BR = 0x01;
|
|
14
|
+
const _ORIGIN_UL = 0x02;
|
|
15
|
+
const _ORIGIN_UR = 0x03;
|
|
16
|
+
/**
|
|
17
|
+
* Gets the header of a TGA file
|
|
18
|
+
* @param data defines the TGA data
|
|
19
|
+
* @returns the header
|
|
20
|
+
*/
|
|
21
|
+
function GetTGAHeader(data) {
|
|
22
|
+
let offset = 0;
|
|
23
|
+
const header = {
|
|
24
|
+
id_length: data[offset++],
|
|
25
|
+
colormap_type: data[offset++],
|
|
26
|
+
image_type: data[offset++],
|
|
27
|
+
colormap_index: data[offset++] | (data[offset++] << 8),
|
|
28
|
+
colormap_length: data[offset++] | (data[offset++] << 8),
|
|
29
|
+
colormap_size: data[offset++],
|
|
30
|
+
origin: [data[offset++] | (data[offset++] << 8), data[offset++] | (data[offset++] << 8)],
|
|
31
|
+
width: data[offset++] | (data[offset++] << 8),
|
|
32
|
+
height: data[offset++] | (data[offset++] << 8),
|
|
33
|
+
pixel_size: data[offset++],
|
|
34
|
+
flags: data[offset++],
|
|
35
|
+
};
|
|
36
|
+
return header;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Uploads TGA content to a Babylon Texture
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
function UploadContent(texture, data) {
|
|
43
|
+
// Not enough data to contain header ?
|
|
44
|
+
if (data.length < 19) {
|
|
45
|
+
Logger.Error("Unable to load TGA file - Not enough data to contain header");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// Read Header
|
|
49
|
+
let offset = 18;
|
|
50
|
+
const header = GetTGAHeader(data);
|
|
51
|
+
// Assume it's a valid Targa file.
|
|
52
|
+
if (header.id_length + offset > data.length) {
|
|
53
|
+
Logger.Error("Unable to load TGA file - Not enough data");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
// Skip not needed data
|
|
57
|
+
offset += header.id_length;
|
|
58
|
+
let use_rle = false;
|
|
59
|
+
let use_pal = false;
|
|
60
|
+
let use_grey = false;
|
|
61
|
+
// Get some informations.
|
|
62
|
+
switch (header.image_type) {
|
|
63
|
+
case _TYPE_RLE_INDEXED:
|
|
64
|
+
use_rle = true;
|
|
65
|
+
// eslint-disable-next-line no-fallthrough
|
|
66
|
+
case _TYPE_INDEXED:
|
|
67
|
+
use_pal = true;
|
|
68
|
+
break;
|
|
69
|
+
case _TYPE_RLE_RGB:
|
|
70
|
+
use_rle = true;
|
|
71
|
+
// eslint-disable-next-line no-fallthrough
|
|
72
|
+
case _TYPE_RGB:
|
|
73
|
+
// use_rgb = true;
|
|
74
|
+
break;
|
|
75
|
+
case _TYPE_RLE_GREY:
|
|
76
|
+
use_rle = true;
|
|
77
|
+
// eslint-disable-next-line no-fallthrough
|
|
78
|
+
case _TYPE_GREY:
|
|
79
|
+
use_grey = true;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
let pixel_data;
|
|
83
|
+
// var numAlphaBits = header.flags & 0xf;
|
|
84
|
+
const pixel_size = header.pixel_size >> 3;
|
|
85
|
+
const pixel_total = header.width * header.height * pixel_size;
|
|
86
|
+
// Read palettes
|
|
87
|
+
let palettes;
|
|
88
|
+
if (use_pal) {
|
|
89
|
+
palettes = data.subarray(offset, (offset += header.colormap_length * (header.colormap_size >> 3)));
|
|
90
|
+
}
|
|
91
|
+
// Read LRE
|
|
92
|
+
if (use_rle) {
|
|
93
|
+
pixel_data = new Uint8Array(pixel_total);
|
|
94
|
+
let c, count, i;
|
|
95
|
+
let localOffset = 0;
|
|
96
|
+
const pixels = new Uint8Array(pixel_size);
|
|
97
|
+
while (offset < pixel_total && localOffset < pixel_total) {
|
|
98
|
+
c = data[offset++];
|
|
99
|
+
count = (c & 0x7f) + 1;
|
|
100
|
+
// RLE pixels
|
|
101
|
+
if (c & 0x80) {
|
|
102
|
+
// Bind pixel tmp array
|
|
103
|
+
for (i = 0; i < pixel_size; ++i) {
|
|
104
|
+
pixels[i] = data[offset++];
|
|
105
|
+
}
|
|
106
|
+
// Copy pixel array
|
|
107
|
+
for (i = 0; i < count; ++i) {
|
|
108
|
+
pixel_data.set(pixels, localOffset + i * pixel_size);
|
|
109
|
+
}
|
|
110
|
+
localOffset += pixel_size * count;
|
|
111
|
+
}
|
|
112
|
+
// Raw pixels
|
|
113
|
+
else {
|
|
114
|
+
count *= pixel_size;
|
|
115
|
+
for (i = 0; i < count; ++i) {
|
|
116
|
+
pixel_data[localOffset + i] = data[offset++];
|
|
117
|
+
}
|
|
118
|
+
localOffset += count;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// RAW Pixels
|
|
123
|
+
else {
|
|
124
|
+
pixel_data = data.subarray(offset, (offset += use_pal ? header.width * header.height : pixel_total));
|
|
125
|
+
}
|
|
126
|
+
// Load to texture
|
|
127
|
+
let x_start, y_start, x_step, y_step, y_end, x_end;
|
|
128
|
+
switch ((header.flags & _ORIGIN_MASK) >> _ORIGIN_SHIFT) {
|
|
129
|
+
default:
|
|
130
|
+
case _ORIGIN_UL:
|
|
131
|
+
x_start = 0;
|
|
132
|
+
x_step = 1;
|
|
133
|
+
x_end = header.width;
|
|
134
|
+
y_start = 0;
|
|
135
|
+
y_step = 1;
|
|
136
|
+
y_end = header.height;
|
|
137
|
+
break;
|
|
138
|
+
case _ORIGIN_BL:
|
|
139
|
+
x_start = 0;
|
|
140
|
+
x_step = 1;
|
|
141
|
+
x_end = header.width;
|
|
142
|
+
y_start = header.height - 1;
|
|
143
|
+
y_step = -1;
|
|
144
|
+
y_end = -1;
|
|
145
|
+
break;
|
|
146
|
+
case _ORIGIN_UR:
|
|
147
|
+
x_start = header.width - 1;
|
|
148
|
+
x_step = -1;
|
|
149
|
+
x_end = -1;
|
|
150
|
+
y_start = 0;
|
|
151
|
+
y_step = 1;
|
|
152
|
+
y_end = header.height;
|
|
153
|
+
break;
|
|
154
|
+
case _ORIGIN_BR:
|
|
155
|
+
x_start = header.width - 1;
|
|
156
|
+
x_step = -1;
|
|
157
|
+
x_end = -1;
|
|
158
|
+
y_start = header.height - 1;
|
|
159
|
+
y_step = -1;
|
|
160
|
+
y_end = -1;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
// Load the specify method
|
|
164
|
+
const func = "_getImageData" + (use_grey ? "Grey" : "") + header.pixel_size + "bits";
|
|
165
|
+
const imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
|
|
166
|
+
const engine = texture.getEngine();
|
|
167
|
+
engine._uploadDataToTextureDirectly(texture, imageData);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* @internal
|
|
171
|
+
*/
|
|
172
|
+
function _getImageData8bits(header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
|
|
173
|
+
const image = pixel_data, colormap = palettes;
|
|
174
|
+
const width = header.width, height = header.height;
|
|
175
|
+
let color, i = 0, x, y;
|
|
176
|
+
const imageData = new Uint8Array(width * height * 4);
|
|
177
|
+
for (y = y_start; y !== y_end; y += y_step) {
|
|
178
|
+
for (x = x_start; x !== x_end; x += x_step, i++) {
|
|
179
|
+
color = image[i];
|
|
180
|
+
imageData[(x + width * y) * 4 + 3] = 255;
|
|
181
|
+
imageData[(x + width * y) * 4 + 2] = colormap[color * 3 + 0];
|
|
182
|
+
imageData[(x + width * y) * 4 + 1] = colormap[color * 3 + 1];
|
|
183
|
+
imageData[(x + width * y) * 4 + 0] = colormap[color * 3 + 2];
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return imageData;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* @internal
|
|
190
|
+
*/
|
|
191
|
+
function _getImageData16bits(header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
|
|
192
|
+
const image = pixel_data;
|
|
193
|
+
const width = header.width, height = header.height;
|
|
194
|
+
let color, i = 0, x, y;
|
|
195
|
+
const imageData = new Uint8Array(width * height * 4);
|
|
196
|
+
for (y = y_start; y !== y_end; y += y_step) {
|
|
197
|
+
for (x = x_start; x !== x_end; x += x_step, i += 2) {
|
|
198
|
+
color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
|
|
199
|
+
const r = ((((color & 0x7c00) >> 10) * 255) / 0x1f) | 0;
|
|
200
|
+
const g = ((((color & 0x03e0) >> 5) * 255) / 0x1f) | 0;
|
|
201
|
+
const b = (((color & 0x001f) * 255) / 0x1f) | 0;
|
|
202
|
+
imageData[(x + width * y) * 4 + 0] = r;
|
|
203
|
+
imageData[(x + width * y) * 4 + 1] = g;
|
|
204
|
+
imageData[(x + width * y) * 4 + 2] = b;
|
|
205
|
+
imageData[(x + width * y) * 4 + 3] = color & 0x8000 ? 0 : 255;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return imageData;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* @internal
|
|
212
|
+
*/
|
|
213
|
+
function _getImageData24bits(header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
|
|
214
|
+
const image = pixel_data;
|
|
215
|
+
const width = header.width, height = header.height;
|
|
216
|
+
let i = 0, x, y;
|
|
217
|
+
const imageData = new Uint8Array(width * height * 4);
|
|
218
|
+
for (y = y_start; y !== y_end; y += y_step) {
|
|
219
|
+
for (x = x_start; x !== x_end; x += x_step, i += 3) {
|
|
220
|
+
imageData[(x + width * y) * 4 + 3] = 255;
|
|
221
|
+
imageData[(x + width * y) * 4 + 2] = image[i + 0];
|
|
222
|
+
imageData[(x + width * y) * 4 + 1] = image[i + 1];
|
|
223
|
+
imageData[(x + width * y) * 4 + 0] = image[i + 2];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return imageData;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* @internal
|
|
230
|
+
*/
|
|
231
|
+
function _getImageData32bits(header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
|
|
232
|
+
const image = pixel_data;
|
|
233
|
+
const width = header.width, height = header.height;
|
|
234
|
+
let i = 0, x, y;
|
|
235
|
+
const imageData = new Uint8Array(width * height * 4);
|
|
236
|
+
for (y = y_start; y !== y_end; y += y_step) {
|
|
237
|
+
for (x = x_start; x !== x_end; x += x_step, i += 4) {
|
|
238
|
+
imageData[(x + width * y) * 4 + 2] = image[i + 0];
|
|
239
|
+
imageData[(x + width * y) * 4 + 1] = image[i + 1];
|
|
240
|
+
imageData[(x + width * y) * 4 + 0] = image[i + 2];
|
|
241
|
+
imageData[(x + width * y) * 4 + 3] = image[i + 3];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return imageData;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* @internal
|
|
248
|
+
*/
|
|
249
|
+
function _getImageDataGrey8bits(header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
|
|
250
|
+
const image = pixel_data;
|
|
251
|
+
const width = header.width, height = header.height;
|
|
252
|
+
let color, i = 0, x, y;
|
|
253
|
+
const imageData = new Uint8Array(width * height * 4);
|
|
254
|
+
for (y = y_start; y !== y_end; y += y_step) {
|
|
255
|
+
for (x = x_start; x !== x_end; x += x_step, i++) {
|
|
256
|
+
color = image[i];
|
|
257
|
+
imageData[(x + width * y) * 4 + 0] = color;
|
|
258
|
+
imageData[(x + width * y) * 4 + 1] = color;
|
|
259
|
+
imageData[(x + width * y) * 4 + 2] = color;
|
|
260
|
+
imageData[(x + width * y) * 4 + 3] = 255;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return imageData;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* @internal
|
|
267
|
+
*/
|
|
268
|
+
function _getImageDataGrey16bits(header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
|
|
269
|
+
const image = pixel_data;
|
|
270
|
+
const width = header.width, height = header.height;
|
|
271
|
+
let i = 0, x, y;
|
|
272
|
+
const imageData = new Uint8Array(width * height * 4);
|
|
273
|
+
for (y = y_start; y !== y_end; y += y_step) {
|
|
274
|
+
for (x = x_start; x !== x_end; x += x_step, i += 2) {
|
|
275
|
+
imageData[(x + width * y) * 4 + 0] = image[i + 0];
|
|
276
|
+
imageData[(x + width * y) * 4 + 1] = image[i + 0];
|
|
277
|
+
imageData[(x + width * y) * 4 + 2] = image[i + 0];
|
|
278
|
+
imageData[(x + width * y) * 4 + 3] = image[i + 1];
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return imageData;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Based on jsTGALoader - Javascript loader for TGA file
|
|
285
|
+
* By Vincent Thibault
|
|
286
|
+
* @see http://blog.robrowser.com/javascript-tga-loader.html
|
|
287
|
+
*/
|
|
288
|
+
const TGATools = {
|
|
289
|
+
/**
|
|
290
|
+
* Gets the header of a TGA file
|
|
291
|
+
* @param data defines the TGA data
|
|
292
|
+
* @returns the header
|
|
293
|
+
*/
|
|
294
|
+
GetTGAHeader,
|
|
295
|
+
/**
|
|
296
|
+
* Uploads TGA content to a Babylon Texture
|
|
297
|
+
* @internal
|
|
298
|
+
*/
|
|
299
|
+
UploadContent,
|
|
300
|
+
/** @internal */
|
|
301
|
+
_getImageData8bits,
|
|
302
|
+
/** @internal */
|
|
303
|
+
_getImageData16bits,
|
|
304
|
+
/** @internal */
|
|
305
|
+
_getImageData24bits,
|
|
306
|
+
/** @internal */
|
|
307
|
+
_getImageData32bits,
|
|
308
|
+
/** @internal */
|
|
309
|
+
_getImageDataGrey8bits,
|
|
310
|
+
/** @internal */
|
|
311
|
+
_getImageDataGrey16bits,
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Implementation of the TGA Texture Loader.
|
|
316
|
+
* @internal
|
|
317
|
+
*/
|
|
318
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
319
|
+
class _TGATextureLoader {
|
|
320
|
+
constructor() {
|
|
321
|
+
/**
|
|
322
|
+
* Defines whether the loader supports cascade loading the different faces.
|
|
323
|
+
*/
|
|
324
|
+
this.supportCascades = false;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Uploads the cube texture data to the WebGL texture. It has already been bound.
|
|
328
|
+
*/
|
|
329
|
+
loadCubeData() {
|
|
330
|
+
// eslint-disable-next-line no-throw-literal
|
|
331
|
+
throw ".env not supported in Cube.";
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
|
|
335
|
+
* @param data contains the texture data
|
|
336
|
+
* @param texture defines the BabylonJS internal texture
|
|
337
|
+
* @param callback defines the method to call once ready to upload
|
|
338
|
+
*/
|
|
339
|
+
loadData(data, texture, callback) {
|
|
340
|
+
const bytes = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
341
|
+
const header = GetTGAHeader(bytes);
|
|
342
|
+
callback(header.width, header.height, texture.generateMipMaps, false, () => {
|
|
343
|
+
UploadContent(texture, bytes);
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export { _TGATextureLoader };
|
|
349
|
+
//# sourceMappingURL=tgaTextureLoader-DdDpL5u3.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tgaTextureLoader-DdDpL5u3.esm.js","sources":["../../../../../dev/core/dist/Misc/tga.js","../../../../../dev/core/dist/Materials/Textures/Loaders/tgaTextureLoader.js"],"sourcesContent":["import { Logger } from \"../Misc/logger\";\n//private static _TYPE_NO_DATA = 0;\nconst _TYPE_INDEXED = 1;\nconst _TYPE_RGB = 2;\nconst _TYPE_GREY = 3;\nconst _TYPE_RLE_INDEXED = 9;\nconst _TYPE_RLE_RGB = 10;\nconst _TYPE_RLE_GREY = 11;\nconst _ORIGIN_MASK = 0x30;\nconst _ORIGIN_SHIFT = 0x04;\nconst _ORIGIN_BL = 0x00;\nconst _ORIGIN_BR = 0x01;\nconst _ORIGIN_UL = 0x02;\nconst _ORIGIN_UR = 0x03;\n/**\n * Gets the header of a TGA file\n * @param data defines the TGA data\n * @returns the header\n */\nexport function GetTGAHeader(data) {\n let offset = 0;\n const header = {\n id_length: data[offset++],\n colormap_type: data[offset++],\n image_type: data[offset++],\n colormap_index: data[offset++] | (data[offset++] << 8),\n colormap_length: data[offset++] | (data[offset++] << 8),\n colormap_size: data[offset++],\n origin: [data[offset++] | (data[offset++] << 8), data[offset++] | (data[offset++] << 8)],\n width: data[offset++] | (data[offset++] << 8),\n height: data[offset++] | (data[offset++] << 8),\n pixel_size: data[offset++],\n flags: data[offset++],\n };\n return header;\n}\n/**\n * Uploads TGA content to a Babylon Texture\n * @internal\n */\nexport function UploadContent(texture, data) {\n // Not enough data to contain header ?\n if (data.length < 19) {\n Logger.Error(\"Unable to load TGA file - Not enough data to contain header\");\n return;\n }\n // Read Header\n let offset = 18;\n const header = GetTGAHeader(data);\n // Assume it's a valid Targa file.\n if (header.id_length + offset > data.length) {\n Logger.Error(\"Unable to load TGA file - Not enough data\");\n return;\n }\n // Skip not needed data\n offset += header.id_length;\n let use_rle = false;\n let use_pal = false;\n let use_grey = false;\n // Get some informations.\n switch (header.image_type) {\n case _TYPE_RLE_INDEXED:\n use_rle = true;\n // eslint-disable-next-line no-fallthrough\n case _TYPE_INDEXED:\n use_pal = true;\n break;\n case _TYPE_RLE_RGB:\n use_rle = true;\n // eslint-disable-next-line no-fallthrough\n case _TYPE_RGB:\n // use_rgb = true;\n break;\n case _TYPE_RLE_GREY:\n use_rle = true;\n // eslint-disable-next-line no-fallthrough\n case _TYPE_GREY:\n use_grey = true;\n break;\n }\n let pixel_data;\n // var numAlphaBits = header.flags & 0xf;\n const pixel_size = header.pixel_size >> 3;\n const pixel_total = header.width * header.height * pixel_size;\n // Read palettes\n let palettes;\n if (use_pal) {\n palettes = data.subarray(offset, (offset += header.colormap_length * (header.colormap_size >> 3)));\n }\n // Read LRE\n if (use_rle) {\n pixel_data = new Uint8Array(pixel_total);\n let c, count, i;\n let localOffset = 0;\n const pixels = new Uint8Array(pixel_size);\n while (offset < pixel_total && localOffset < pixel_total) {\n c = data[offset++];\n count = (c & 0x7f) + 1;\n // RLE pixels\n if (c & 0x80) {\n // Bind pixel tmp array\n for (i = 0; i < pixel_size; ++i) {\n pixels[i] = data[offset++];\n }\n // Copy pixel array\n for (i = 0; i < count; ++i) {\n pixel_data.set(pixels, localOffset + i * pixel_size);\n }\n localOffset += pixel_size * count;\n }\n // Raw pixels\n else {\n count *= pixel_size;\n for (i = 0; i < count; ++i) {\n pixel_data[localOffset + i] = data[offset++];\n }\n localOffset += count;\n }\n }\n }\n // RAW Pixels\n else {\n pixel_data = data.subarray(offset, (offset += use_pal ? header.width * header.height : pixel_total));\n }\n // Load to texture\n let x_start, y_start, x_step, y_step, y_end, x_end;\n switch ((header.flags & _ORIGIN_MASK) >> _ORIGIN_SHIFT) {\n default:\n case _ORIGIN_UL:\n x_start = 0;\n x_step = 1;\n x_end = header.width;\n y_start = 0;\n y_step = 1;\n y_end = header.height;\n break;\n case _ORIGIN_BL:\n x_start = 0;\n x_step = 1;\n x_end = header.width;\n y_start = header.height - 1;\n y_step = -1;\n y_end = -1;\n break;\n case _ORIGIN_UR:\n x_start = header.width - 1;\n x_step = -1;\n x_end = -1;\n y_start = 0;\n y_step = 1;\n y_end = header.height;\n break;\n case _ORIGIN_BR:\n x_start = header.width - 1;\n x_step = -1;\n x_end = -1;\n y_start = header.height - 1;\n y_step = -1;\n y_end = -1;\n break;\n }\n // Load the specify method\n const func = \"_getImageData\" + (use_grey ? \"Grey\" : \"\") + header.pixel_size + \"bits\";\n const imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);\n const engine = texture.getEngine();\n engine._uploadDataToTextureDirectly(texture, imageData);\n}\n/**\n * @internal\n */\nfunction _getImageData8bits(header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {\n const image = pixel_data, colormap = palettes;\n const width = header.width, height = header.height;\n let color, i = 0, x, y;\n const imageData = new Uint8Array(width * height * 4);\n for (y = y_start; y !== y_end; y += y_step) {\n for (x = x_start; x !== x_end; x += x_step, i++) {\n color = image[i];\n imageData[(x + width * y) * 4 + 3] = 255;\n imageData[(x + width * y) * 4 + 2] = colormap[color * 3 + 0];\n imageData[(x + width * y) * 4 + 1] = colormap[color * 3 + 1];\n imageData[(x + width * y) * 4 + 0] = colormap[color * 3 + 2];\n }\n }\n return imageData;\n}\n/**\n * @internal\n */\nfunction _getImageData16bits(header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {\n const image = pixel_data;\n const width = header.width, height = header.height;\n let color, i = 0, x, y;\n const imageData = new Uint8Array(width * height * 4);\n for (y = y_start; y !== y_end; y += y_step) {\n for (x = x_start; x !== x_end; x += x_step, i += 2) {\n color = image[i + 0] + (image[i + 1] << 8); // Inversed ?\n const r = ((((color & 0x7c00) >> 10) * 255) / 0x1f) | 0;\n const g = ((((color & 0x03e0) >> 5) * 255) / 0x1f) | 0;\n const b = (((color & 0x001f) * 255) / 0x1f) | 0;\n imageData[(x + width * y) * 4 + 0] = r;\n imageData[(x + width * y) * 4 + 1] = g;\n imageData[(x + width * y) * 4 + 2] = b;\n imageData[(x + width * y) * 4 + 3] = color & 0x8000 ? 0 : 255;\n }\n }\n return imageData;\n}\n/**\n * @internal\n */\nfunction _getImageData24bits(header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {\n const image = pixel_data;\n const width = header.width, height = header.height;\n let i = 0, x, y;\n const imageData = new Uint8Array(width * height * 4);\n for (y = y_start; y !== y_end; y += y_step) {\n for (x = x_start; x !== x_end; x += x_step, i += 3) {\n imageData[(x + width * y) * 4 + 3] = 255;\n imageData[(x + width * y) * 4 + 2] = image[i + 0];\n imageData[(x + width * y) * 4 + 1] = image[i + 1];\n imageData[(x + width * y) * 4 + 0] = image[i + 2];\n }\n }\n return imageData;\n}\n/**\n * @internal\n */\nfunction _getImageData32bits(header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {\n const image = pixel_data;\n const width = header.width, height = header.height;\n let i = 0, x, y;\n const imageData = new Uint8Array(width * height * 4);\n for (y = y_start; y !== y_end; y += y_step) {\n for (x = x_start; x !== x_end; x += x_step, i += 4) {\n imageData[(x + width * y) * 4 + 2] = image[i + 0];\n imageData[(x + width * y) * 4 + 1] = image[i + 1];\n imageData[(x + width * y) * 4 + 0] = image[i + 2];\n imageData[(x + width * y) * 4 + 3] = image[i + 3];\n }\n }\n return imageData;\n}\n/**\n * @internal\n */\nfunction _getImageDataGrey8bits(header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {\n const image = pixel_data;\n const width = header.width, height = header.height;\n let color, i = 0, x, y;\n const imageData = new Uint8Array(width * height * 4);\n for (y = y_start; y !== y_end; y += y_step) {\n for (x = x_start; x !== x_end; x += x_step, i++) {\n color = image[i];\n imageData[(x + width * y) * 4 + 0] = color;\n imageData[(x + width * y) * 4 + 1] = color;\n imageData[(x + width * y) * 4 + 2] = color;\n imageData[(x + width * y) * 4 + 3] = 255;\n }\n }\n return imageData;\n}\n/**\n * @internal\n */\nfunction _getImageDataGrey16bits(header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {\n const image = pixel_data;\n const width = header.width, height = header.height;\n let i = 0, x, y;\n const imageData = new Uint8Array(width * height * 4);\n for (y = y_start; y !== y_end; y += y_step) {\n for (x = x_start; x !== x_end; x += x_step, i += 2) {\n imageData[(x + width * y) * 4 + 0] = image[i + 0];\n imageData[(x + width * y) * 4 + 1] = image[i + 0];\n imageData[(x + width * y) * 4 + 2] = image[i + 0];\n imageData[(x + width * y) * 4 + 3] = image[i + 1];\n }\n }\n return imageData;\n}\n/**\n * Based on jsTGALoader - Javascript loader for TGA file\n * By Vincent Thibault\n * @see http://blog.robrowser.com/javascript-tga-loader.html\n */\nexport const TGATools = {\n /**\n * Gets the header of a TGA file\n * @param data defines the TGA data\n * @returns the header\n */\n GetTGAHeader,\n /**\n * Uploads TGA content to a Babylon Texture\n * @internal\n */\n UploadContent,\n /** @internal */\n _getImageData8bits,\n /** @internal */\n _getImageData16bits,\n /** @internal */\n _getImageData24bits,\n /** @internal */\n _getImageData32bits,\n /** @internal */\n _getImageDataGrey8bits,\n /** @internal */\n _getImageDataGrey16bits,\n};\n//# sourceMappingURL=tga.js.map","import { GetTGAHeader, UploadContent } from \"../../../Misc/tga\";\n/**\n * Implementation of the TGA Texture Loader.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class _TGATextureLoader {\n constructor() {\n /**\n * Defines whether the loader supports cascade loading the different faces.\n */\n this.supportCascades = false;\n }\n /**\n * Uploads the cube texture data to the WebGL texture. It has already been bound.\n */\n loadCubeData() {\n // eslint-disable-next-line no-throw-literal\n throw \".env not supported in Cube.\";\n }\n /**\n * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.\n * @param data contains the texture data\n * @param texture defines the BabylonJS internal texture\n * @param callback defines the method to call once ready to upload\n */\n loadData(data, texture, callback) {\n const bytes = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n const header = GetTGAHeader(bytes);\n callback(header.width, header.height, texture.generateMipMaps, false, () => {\n UploadContent(texture, bytes);\n });\n }\n}\n//# sourceMappingURL=tgaTextureLoader.js.map"],"names":[],"mappings":";;AACA;AACA,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB,MAAM,UAAU,GAAG,CAAC,CAAC;AACrB,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB;AACA;AACA;AACA;AACA;AACO,SAAS,YAAY,CAAC,IAAI,EAAE;AACnC,IAAI,IAAI,MAAM,GAAG,CAAC,CAAC;AACnB,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;AACjC,QAAQ,aAAa,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;AACrC,QAAQ,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;AAClC,QAAQ,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;AAC9D,QAAQ,eAAe,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;AAC/D,QAAQ,aAAa,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC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O,MAAM,QAAQ,GAAG;AACxB;AACA;AACA;AACA;AACA;AACA,IAAI,YAAY;AAChB;AACA;AACA;AACA;AACA,IAAI,aAAa;AACjB;AACA,IAAI,kBAAkB;AACtB;AACA,IAAI,mBAAmB;AACvB;AACA,IAAI,mBAAmB;AACvB;AACA,IAAI,mBAAmB;AACvB;AACA,IAAI,sBAAsB;AAC1B;AACA,IAAI,uBAAuB;AAC3B,CAAC;;ACrTD;AACA;AACA;AACA;AACA;AACO,MAAM,iBAAiB,CAAC;AAC/B,IAAI,WAAW,GAAG;AAClB;AACA;AACA;AACA,QAAQ,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;AACrC,KAAK;AACL;AACA;AACA;AACA,IAAI,YAAY,GAAG;AACnB;AACA,QAAQ,MAAM,6BAA6B,CAAC;AAC5C,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE;AACtC,QAAQ,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AACpF,QAAQ,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;AAC3C,QAAQ,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM;AACpF,YAAY,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC1C,SAAS,CAAC,CAAC;AACX,KAAK;AACL;;;;"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { Nullable, AssetContainer, IDisposable, AbstractEngine, LoadAssetContainerOptions } from '@babylonjs/core/index.js';
|
|
2
|
+
import { Color4 } from '@babylonjs/core/Maths/math.color.js';
|
|
3
|
+
import { Observable } from '@babylonjs/core/Misc/observable.js';
|
|
4
|
+
import { Scene } from '@babylonjs/core/scene.js';
|
|
5
|
+
import * as lit_html from 'lit-html';
|
|
6
|
+
import * as lit from 'lit';
|
|
7
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
8
|
+
import { EngineOptions } from '@babylonjs/core/Engines.js';
|
|
9
|
+
|
|
10
|
+
declare const defaultViewerOptions: {
|
|
11
|
+
readonly backgroundColor: Color4;
|
|
12
|
+
};
|
|
13
|
+
type ViewerDetails = {
|
|
14
|
+
/**
|
|
15
|
+
* Provides access to the Scene managed by the Viewer.
|
|
16
|
+
*/
|
|
17
|
+
scene: Scene;
|
|
18
|
+
/**
|
|
19
|
+
* Provides access to the currently loaded model.
|
|
20
|
+
*/
|
|
21
|
+
model: Nullable<AssetContainer>;
|
|
22
|
+
};
|
|
23
|
+
type ViewerOptions = Partial<typeof defaultViewerOptions & Readonly<{
|
|
24
|
+
/**
|
|
25
|
+
* Called once when the viewer is initialized and provides viewer details that can be used for advanced customization.
|
|
26
|
+
*/
|
|
27
|
+
onInitialized: (details: Readonly<ViewerDetails>) => void;
|
|
28
|
+
}>>;
|
|
29
|
+
/**
|
|
30
|
+
* Provides an experience for viewing a single 3D model.
|
|
31
|
+
* @remarks
|
|
32
|
+
* The Viewer is not tied to a specific UI framework and can be used with Babylon.js in a browser or with Babylon Native.
|
|
33
|
+
* Includes (or will include) support for common model viewing requirements such as:
|
|
34
|
+
* - Loading different model formats.
|
|
35
|
+
* - Setting up a camera and providing default behaviors like auto orbit and pose interpolation.
|
|
36
|
+
* - Framing the loaded model in the camera's view.
|
|
37
|
+
* - Setting up the environment, lighting, and tone mapping.
|
|
38
|
+
* - Enumerating and playing (or auto playing) animations.
|
|
39
|
+
* - Enumerating and switching between material variants.
|
|
40
|
+
* - Full screen and XR modes.
|
|
41
|
+
*/
|
|
42
|
+
declare class Viewer implements IDisposable {
|
|
43
|
+
private readonly _engine;
|
|
44
|
+
/**
|
|
45
|
+
* Fired when a model is loaded into the viewer.
|
|
46
|
+
*/
|
|
47
|
+
readonly onModelLoaded: Observable<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Fired when an error occurs while loading a model.
|
|
50
|
+
*/
|
|
51
|
+
readonly onModelError: Observable<unknown>;
|
|
52
|
+
/**
|
|
53
|
+
* Fired when the selected animation changes.
|
|
54
|
+
*/
|
|
55
|
+
readonly onSelectedAnimationChanged: Observable<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Fired when the animation speed changes.
|
|
58
|
+
*/
|
|
59
|
+
readonly onAnimationSpeedChanged: Observable<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Fired when the selected animation is playing or paused.
|
|
62
|
+
*/
|
|
63
|
+
readonly onIsAnimationPlayingChanged: Observable<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Fired when the current point on the selected animation timeline changes.
|
|
66
|
+
*/
|
|
67
|
+
readonly onAnimationProgressChanged: Observable<void>;
|
|
68
|
+
private readonly _details;
|
|
69
|
+
private readonly _camera;
|
|
70
|
+
private readonly _autoRotationBehavior;
|
|
71
|
+
private readonly _renderLoopController;
|
|
72
|
+
private _skybox;
|
|
73
|
+
private _isDisposed;
|
|
74
|
+
private readonly _loadModelLock;
|
|
75
|
+
private _loadModelAbortController;
|
|
76
|
+
private readonly _loadEnvironmentLock;
|
|
77
|
+
private _environment;
|
|
78
|
+
private _loadEnvironmentAbortController;
|
|
79
|
+
private _selectedAnimation;
|
|
80
|
+
private _activeAnimationObservers;
|
|
81
|
+
private _animationSpeed;
|
|
82
|
+
constructor(_engine: AbstractEngine, options?: ViewerOptions);
|
|
83
|
+
/**
|
|
84
|
+
* The list of animation names for the currently loaded model.
|
|
85
|
+
*/
|
|
86
|
+
get animations(): readonly string[];
|
|
87
|
+
/**
|
|
88
|
+
* The currently selected animation index.
|
|
89
|
+
*/
|
|
90
|
+
get selectedAnimation(): number;
|
|
91
|
+
set selectedAnimation(value: number);
|
|
92
|
+
/**
|
|
93
|
+
* True if an animation is currently playing.
|
|
94
|
+
*/
|
|
95
|
+
get isAnimationPlaying(): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* The speed scale at which animations are played.
|
|
98
|
+
*/
|
|
99
|
+
get animationSpeed(): number;
|
|
100
|
+
set animationSpeed(value: number);
|
|
101
|
+
/**
|
|
102
|
+
* The current point on the selected animation timeline, normalized between 0 and 1.
|
|
103
|
+
*/
|
|
104
|
+
get animationProgress(): number;
|
|
105
|
+
set animationProgress(value: number);
|
|
106
|
+
private get _activeAnimation();
|
|
107
|
+
/**
|
|
108
|
+
* Loads a 3D model from the specified URL.
|
|
109
|
+
* @remarks
|
|
110
|
+
* If a model is already loaded, it will be unloaded before loading the new model.
|
|
111
|
+
* @param source A url or File or ArrayBufferView that points to the model to load.
|
|
112
|
+
* @param options The options to use when loading the model.
|
|
113
|
+
* @param abortSignal An optional signal that can be used to abort the loading process.
|
|
114
|
+
*/
|
|
115
|
+
loadModelAsync(source: string | File | ArrayBufferView, options?: LoadAssetContainerOptions, abortSignal?: AbortSignal): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Loads an environment texture from the specified url and sets up a corresponding skybox.
|
|
118
|
+
* @remarks
|
|
119
|
+
* If no url is provided, a default hemispheric light will be created.
|
|
120
|
+
* If an environment is already loaded, it will be unloaded before loading the new environment.
|
|
121
|
+
* @param url The url of the environment texture to load.
|
|
122
|
+
* @param options The options to use when loading the environment.
|
|
123
|
+
* @param abortSignal An optional signal that can be used to abort the loading process.
|
|
124
|
+
*/
|
|
125
|
+
loadEnvironmentAsync(url: Nullable<string | undefined>, options?: {}, abortSignal?: AbortSignal): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Toggles the play/pause animation state if there is a selected animation.
|
|
128
|
+
*/
|
|
129
|
+
toggleAnimation(): void;
|
|
130
|
+
/**
|
|
131
|
+
* Plays the selected animation if there is one.
|
|
132
|
+
*/
|
|
133
|
+
playAnimation(): void;
|
|
134
|
+
/**
|
|
135
|
+
* Pauses the selected animation if there is one.
|
|
136
|
+
*/
|
|
137
|
+
pauseAnimation(): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Disposes of the resources held by the Viewer.
|
|
140
|
+
*/
|
|
141
|
+
dispose(): void;
|
|
142
|
+
private _updateCamera;
|
|
143
|
+
private _applyAnimationSpeed;
|
|
144
|
+
/**
|
|
145
|
+
* Check for disposed or aborted state (basically everything that can interrupt an async operation).
|
|
146
|
+
* @param abortSignals A set of optional AbortSignals to also check.
|
|
147
|
+
*/
|
|
148
|
+
private _throwIfDisposedOrAborted;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
interface HTML3DElementEventMap extends HTMLElementEventMap {
|
|
152
|
+
modelchange: Event;
|
|
153
|
+
modelerror: Event;
|
|
154
|
+
selectedanimationchange: Event;
|
|
155
|
+
animationspeedchange: Event;
|
|
156
|
+
animationplayingchange: Event;
|
|
157
|
+
animationprogresschange: Event;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Represents a custom element that displays a 3D model using the Babylon.js Viewer.
|
|
161
|
+
*/
|
|
162
|
+
declare class HTML3DElement extends LitElement {
|
|
163
|
+
/**
|
|
164
|
+
* Gets the underlying Viewer object. It will be undefined when the element is not connected to the DOM.
|
|
165
|
+
*/
|
|
166
|
+
viewer?: Viewer;
|
|
167
|
+
static styles: lit.CSSResult;
|
|
168
|
+
/**
|
|
169
|
+
* The model URL.
|
|
170
|
+
*/
|
|
171
|
+
src: string;
|
|
172
|
+
/**
|
|
173
|
+
* The environment URL.
|
|
174
|
+
*/
|
|
175
|
+
env: string;
|
|
176
|
+
/**
|
|
177
|
+
* The list of animation names for the currently loaded model.
|
|
178
|
+
*/
|
|
179
|
+
get animations(): readonly string[];
|
|
180
|
+
/**
|
|
181
|
+
* The currently selected animation index.
|
|
182
|
+
*/
|
|
183
|
+
get selectedAnimation(): number;
|
|
184
|
+
/**
|
|
185
|
+
* True if an animation is currently playing.
|
|
186
|
+
*/
|
|
187
|
+
get isAnimationPlaying(): boolean;
|
|
188
|
+
/**
|
|
189
|
+
* The speed scale at which animations are played.
|
|
190
|
+
*/
|
|
191
|
+
animationSpeed: number;
|
|
192
|
+
/**
|
|
193
|
+
* The current point on the selected animation timeline, normalized between 0 and 1.
|
|
194
|
+
*/
|
|
195
|
+
animationProgress: number;
|
|
196
|
+
private _animations;
|
|
197
|
+
private _selectedAnimation;
|
|
198
|
+
private _isAnimationPlaying;
|
|
199
|
+
private _canvas;
|
|
200
|
+
/**
|
|
201
|
+
* Toggles the play/pause animation state if there is a selected animation.
|
|
202
|
+
*/
|
|
203
|
+
toggleAnimation(): void;
|
|
204
|
+
connectedCallback(): void;
|
|
205
|
+
firstUpdated(_changedProperties: PropertyValues): void;
|
|
206
|
+
disconnectedCallback(): void;
|
|
207
|
+
update(changedProperties: PropertyValues): void;
|
|
208
|
+
render(): lit_html.TemplateResult<1>;
|
|
209
|
+
addEventListener<K extends keyof HTML3DElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTML3DElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
210
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
211
|
+
private _dispatchCustomEvent;
|
|
212
|
+
private _onSelectedAnimationChanged;
|
|
213
|
+
private _onAnimationSpeedChanged;
|
|
214
|
+
private _onProgressChanged;
|
|
215
|
+
private _onProgressPointerDown;
|
|
216
|
+
private _setupViewer;
|
|
217
|
+
private _tearDownViewer;
|
|
218
|
+
private _updateAnimationSpeed;
|
|
219
|
+
private _updateSelectedAnimation;
|
|
220
|
+
private _updateModel;
|
|
221
|
+
private _updateEnv;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
type CanvasViewerOptions = ViewerOptions & ({
|
|
225
|
+
engine: "WebGL";
|
|
226
|
+
} & EngineOptions);
|
|
227
|
+
/**
|
|
228
|
+
* Creates a Viewer instance that is bound to an HTML canvas.
|
|
229
|
+
* @remarks
|
|
230
|
+
* This function can be shared across multiple UI integrations (e.g. Web Components, React, etc.).
|
|
231
|
+
* @param canvas The canvas element to bind the Viewer to.
|
|
232
|
+
* @param options The options to use when creating the Viewer and binding it to the specified canvas.
|
|
233
|
+
* @returns A Viewer instance that is bound to the specified canvas.
|
|
234
|
+
*/
|
|
235
|
+
declare function createViewerForCanvas(canvas: HTMLCanvasElement, options?: CanvasViewerOptions): Viewer;
|
|
236
|
+
|
|
237
|
+
export { HTML3DElement, Viewer, type ViewerDetails, type ViewerOptions, createViewerForCanvas };
|