@graphty/graphty-element 1.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/README.md +9 -0
- package/dist/basisTextureLoader-BqIvxvNl.js +312 -0
- package/dist/basisTextureLoader-BqIvxvNl.js.map +1 -0
- package/dist/custom-elements.json +1 -0
- package/dist/dds-BlAaKjyJ.js +357 -0
- package/dist/dds-BlAaKjyJ.js.map +1 -0
- package/dist/ddsTextureLoader-D7Jh83wc.js +44 -0
- package/dist/ddsTextureLoader-D7Jh83wc.js.map +1 -0
- package/dist/default.fragment-BNc4beoN.js +452 -0
- package/dist/default.fragment-BNc4beoN.js.map +1 -0
- package/dist/default.fragment-CSeCDRwv.js +512 -0
- package/dist/default.fragment-CSeCDRwv.js.map +1 -0
- package/dist/default.vertex-9pBFrn06.js +202 -0
- package/dist/default.vertex-9pBFrn06.js.map +1 -0
- package/dist/default.vertex-DDjK1DRv.js +185 -0
- package/dist/default.vertex-DDjK1DRv.js.map +1 -0
- package/dist/defaultUboDeclaration-CG47IDRY.js +9 -0
- package/dist/defaultUboDeclaration-CG47IDRY.js.map +1 -0
- package/dist/defaultUboDeclaration-Ct5CiQ-w.js +11 -0
- package/dist/defaultUboDeclaration-Ct5CiQ-w.js.map +1 -0
- package/dist/dumpTools-DA1xMSIZ.js +103 -0
- package/dist/dumpTools-DA1xMSIZ.js.map +1 -0
- package/dist/envTextureLoader-DdCLpySN.js +238 -0
- package/dist/envTextureLoader-DdCLpySN.js.map +1 -0
- package/dist/exrTextureLoader-CnJSRQ9w.js +741 -0
- package/dist/exrTextureLoader-CnJSRQ9w.js.map +1 -0
- package/dist/graphty.js +12 -0
- package/dist/graphty.js.map +1 -0
- package/dist/graphty.umd.cjs +12657 -0
- package/dist/graphty.umd.cjs.map +1 -0
- package/dist/greasedLine.fragment-BZnGGe-r.js +30 -0
- package/dist/greasedLine.fragment-BZnGGe-r.js.map +1 -0
- package/dist/greasedLine.fragment-DixuqXus.js +12 -0
- package/dist/greasedLine.fragment-DixuqXus.js.map +1 -0
- package/dist/greasedLine.vertex-BhhwFKPy.js +33 -0
- package/dist/greasedLine.vertex-BhhwFKPy.js.map +1 -0
- package/dist/greasedLine.vertex-DIhgGSOi.js +49 -0
- package/dist/greasedLine.vertex-DIhgGSOi.js.map +1 -0
- package/dist/harmonicsFunctions-B9jTNKTF.js +197 -0
- package/dist/harmonicsFunctions-B9jTNKTF.js.map +1 -0
- package/dist/harmonicsFunctions-D9ZL5yLA.js +194 -0
- package/dist/harmonicsFunctions-D9ZL5yLA.js.map +1 -0
- package/dist/hdrTextureLoader-DreWCvHD.js +112 -0
- package/dist/hdrTextureLoader-DreWCvHD.js.map +1 -0
- package/dist/helperFunctions-Dh1WD8YN.js +106 -0
- package/dist/helperFunctions-Dh1WD8YN.js.map +1 -0
- package/dist/helperFunctions-ZBnqb-in.js +79 -0
- package/dist/helperFunctions-ZBnqb-in.js.map +1 -0
- package/dist/iesTextureLoader-JdfAyRK-.js +94 -0
- package/dist/iesTextureLoader-JdfAyRK-.js.map +1 -0
- package/dist/index-ChGTkj2q.js +62191 -0
- package/dist/index-ChGTkj2q.js.map +1 -0
- package/dist/instancesVertex-BrWNnWxF.js +46 -0
- package/dist/instancesVertex-BrWNnWxF.js.map +1 -0
- package/dist/instancesVertex-evcSIvCA.js +55 -0
- package/dist/instancesVertex-evcSIvCA.js.map +1 -0
- package/dist/ktxTextureLoader-Dg1h0a-4.js +520 -0
- package/dist/ktxTextureLoader-Dg1h0a-4.js.map +1 -0
- package/dist/logDepthDeclaration-BHUUDd5l.js +12 -0
- package/dist/logDepthDeclaration-BHUUDd5l.js.map +1 -0
- package/dist/logDepthDeclaration-Bou5AJOP.js +28 -0
- package/dist/logDepthDeclaration-Bou5AJOP.js.map +1 -0
- package/dist/logDepthVertex-CCFGLExi.js +496 -0
- package/dist/logDepthVertex-CCFGLExi.js.map +1 -0
- package/dist/logDepthVertex-r_niddz9.js +496 -0
- package/dist/logDepthVertex-r_niddz9.js.map +1 -0
- package/dist/mesh.vertexData.functions-Bc9lJlrU.js +75 -0
- package/dist/mesh.vertexData.functions-Bc9lJlrU.js.map +1 -0
- package/dist/meshUboDeclaration-Dg__Mhmj.js +18 -0
- package/dist/meshUboDeclaration-Dg__Mhmj.js.map +1 -0
- package/dist/oitFragment-Bn29Ggvj.js +1191 -0
- package/dist/oitFragment-Bn29Ggvj.js.map +1 -0
- package/dist/oitFragment-D6JBEGk0.js +1328 -0
- package/dist/oitFragment-D6JBEGk0.js.map +1 -0
- package/dist/pass.fragment-C9O4ZLJL.js +11 -0
- package/dist/pass.fragment-C9O4ZLJL.js.map +1 -0
- package/dist/pass.fragment-Cf0ob1Y3.js +11 -0
- package/dist/pass.fragment-Cf0ob1Y3.js.map +1 -0
- package/dist/passCube.fragment-Mg8Qj5T9.js +30 -0
- package/dist/passCube.fragment-Mg8Qj5T9.js.map +1 -0
- package/dist/passCube.fragment-uM4B7TOI.js +30 -0
- package/dist/passCube.fragment-uM4B7TOI.js.map +1 -0
- package/dist/pbr.fragment-C8Lm3cwF.js +3176 -0
- package/dist/pbr.fragment-C8Lm3cwF.js.map +1 -0
- package/dist/pbr.fragment-siOdCYqI.js +3219 -0
- package/dist/pbr.fragment-siOdCYqI.js.map +1 -0
- package/dist/pbr.vertex-Bw_TrGQv.js +229 -0
- package/dist/pbr.vertex-Bw_TrGQv.js.map +1 -0
- package/dist/pbr.vertex-CmEPCcBW.js +365 -0
- package/dist/pbr.vertex-CmEPCcBW.js.map +1 -0
- package/dist/postprocess.vertex-B086G8mM.js +16 -0
- package/dist/postprocess.vertex-B086G8mM.js.map +1 -0
- package/dist/rgbdDecode.fragment-bNaGtQ-x.js +9 -0
- package/dist/rgbdDecode.fragment-bNaGtQ-x.js.map +1 -0
- package/dist/rgbdDecode.fragment-koAcppx0.js +9 -0
- package/dist/rgbdDecode.fragment-koAcppx0.js.map +1 -0
- package/dist/rgbdEncode.fragment-BDHL2P_i.js +9 -0
- package/dist/rgbdEncode.fragment-BDHL2P_i.js.map +1 -0
- package/dist/rgbdEncode.fragment-Dw0FS9aH.js +9 -0
- package/dist/rgbdEncode.fragment-Dw0FS9aH.js.map +1 -0
- package/dist/tgaTextureLoader-DIfkfgQh.js +199 -0
- package/dist/tgaTextureLoader-DIfkfgQh.js.map +1 -0
- package/package.json +124 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { S as e } from "./index-ChGTkj2q.js";
|
|
2
|
+
const d = "instancesDeclaration", r = `#ifdef INSTANCES
|
|
3
|
+
attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;
|
|
4
|
+
#ifdef INSTANCESCOLOR
|
|
5
|
+
attribute vec4 instanceColor;
|
|
6
|
+
#endif
|
|
7
|
+
#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)
|
|
8
|
+
uniform mat4 world;
|
|
9
|
+
#endif
|
|
10
|
+
#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)
|
|
11
|
+
attribute vec4 previousWorld0;attribute vec4 previousWorld1;attribute vec4 previousWorld2;attribute vec4 previousWorld3;
|
|
12
|
+
#ifdef THIN_INSTANCES
|
|
13
|
+
uniform mat4 previousWorld;
|
|
14
|
+
#endif
|
|
15
|
+
#endif
|
|
16
|
+
#else
|
|
17
|
+
#if !defined(WORLD_UBO)
|
|
18
|
+
uniform mat4 world;
|
|
19
|
+
#endif
|
|
20
|
+
#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)
|
|
21
|
+
uniform mat4 previousWorld;
|
|
22
|
+
#endif
|
|
23
|
+
#endif
|
|
24
|
+
`;
|
|
25
|
+
e.IncludesShadersStore[d] || (e.IncludesShadersStore[d] = r);
|
|
26
|
+
const i = "instancesVertex", f = `#ifdef INSTANCES
|
|
27
|
+
mat4 finalWorld=mat4(world0,world1,world2,world3);
|
|
28
|
+
#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)
|
|
29
|
+
mat4 finalPreviousWorld=mat4(previousWorld0,previousWorld1,
|
|
30
|
+
previousWorld2,previousWorld3);
|
|
31
|
+
#endif
|
|
32
|
+
#ifdef THIN_INSTANCES
|
|
33
|
+
finalWorld=world*finalWorld;
|
|
34
|
+
#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)
|
|
35
|
+
finalPreviousWorld=previousWorld*finalPreviousWorld;
|
|
36
|
+
#endif
|
|
37
|
+
#endif
|
|
38
|
+
#else
|
|
39
|
+
mat4 finalWorld=world;
|
|
40
|
+
#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)
|
|
41
|
+
mat4 finalPreviousWorld=previousWorld;
|
|
42
|
+
#endif
|
|
43
|
+
#endif
|
|
44
|
+
`;
|
|
45
|
+
e.IncludesShadersStore[i] || (e.IncludesShadersStore[i] = f);
|
|
46
|
+
//# sourceMappingURL=instancesVertex-BrWNnWxF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instancesVertex-BrWNnWxF.js","sources":["../node_modules/@babylonjs/core/Shaders/ShadersInclude/instancesDeclaration.js","../node_modules/@babylonjs/core/Shaders/ShadersInclude/instancesVertex.js"],"sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore.js\";\nconst name = \"instancesDeclaration\";\nconst shader = `#ifdef INSTANCES\nattribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;\n#ifdef INSTANCESCOLOR\nattribute vec4 instanceColor;\n#endif\n#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)\nuniform mat4 world;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nattribute vec4 previousWorld0;attribute vec4 previousWorld1;attribute vec4 previousWorld2;attribute vec4 previousWorld3;\n#ifdef THIN_INSTANCES\nuniform mat4 previousWorld;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nuniform mat4 world;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nuniform mat4 previousWorld;\n#endif\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const instancesDeclaration = { name, shader };\n//# sourceMappingURL=instancesDeclaration.js.map","// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore.js\";\nconst name = \"instancesVertex\";\nconst shader = `#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nmat4 finalPreviousWorld=mat4(previousWorld0,previousWorld1,\npreviousWorld2,previousWorld3);\n#endif\n#ifdef THIN_INSTANCES\nfinalWorld=world*finalWorld;\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nfinalPreviousWorld=previousWorld*finalPreviousWorld;\n#endif\n#endif\n#else\nmat4 finalWorld=world;\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nmat4 finalPreviousWorld=previousWorld;\n#endif\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const instancesVertex = { name, shader };\n//# sourceMappingURL=instancesVertex.js.map"],"names":["name","shader","ShaderStore"],"mappings":";AAEA,MAAMA,IAAO,wBACPC,IAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBVC,EAAY,qBAAqBF,CAAI,MACtCE,EAAY,qBAAqBF,CAAI,IAAIC;AC1B7C,MAAMD,IAAO,mBACPC,IAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBVC,EAAY,qBAAqBF,CAAI,MACtCE,EAAY,qBAAqBF,CAAI,IAAIC;","x_google_ignoreList":[0,1]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { S as e } from "./index-ChGTkj2q.js";
|
|
2
|
+
const d = "instancesDeclaration", r = `#ifdef INSTANCES
|
|
3
|
+
attribute world0 : vec4<f32>;attribute world1 : vec4<f32>;attribute world2 : vec4<f32>;attribute world3 : vec4<f32>;
|
|
4
|
+
#ifdef INSTANCESCOLOR
|
|
5
|
+
attribute instanceColor : vec4<f32>;
|
|
6
|
+
#endif
|
|
7
|
+
#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)
|
|
8
|
+
uniform world : mat4x4<f32>;
|
|
9
|
+
#endif
|
|
10
|
+
#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)
|
|
11
|
+
attribute previousWorld0 : vec4<f32>;attribute previousWorld1 : vec4<f32>;attribute previousWorld2 : vec4<f32>;attribute previousWorld3 : vec4<f32>;
|
|
12
|
+
#ifdef THIN_INSTANCES
|
|
13
|
+
uniform previousWorld : mat4x4<f32>;
|
|
14
|
+
#endif
|
|
15
|
+
#endif
|
|
16
|
+
#else
|
|
17
|
+
#if !defined(WORLD_UBO)
|
|
18
|
+
uniform world : mat4x4<f32>;
|
|
19
|
+
#endif
|
|
20
|
+
#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)
|
|
21
|
+
uniform previousWorld : mat4x4<f32>;
|
|
22
|
+
#endif
|
|
23
|
+
#endif
|
|
24
|
+
`;
|
|
25
|
+
e.IncludesShadersStoreWGSL[d] || (e.IncludesShadersStoreWGSL[d] = r);
|
|
26
|
+
const i = "instancesVertex", f = `#ifdef INSTANCES
|
|
27
|
+
var finalWorld=mat4x4<f32>(vertexInputs.world0,vertexInputs.world1,vertexInputs.world2,vertexInputs.world3);
|
|
28
|
+
#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)
|
|
29
|
+
var finalPreviousWorld=mat4x4<f32>(
|
|
30
|
+
vertexInputs.previousWorld0,vertexInputs.previousWorld1,
|
|
31
|
+
vertexInputs.previousWorld2,vertexInputs.previousWorld3);
|
|
32
|
+
#endif
|
|
33
|
+
#ifdef THIN_INSTANCES
|
|
34
|
+
#if !defined(WORLD_UBO)
|
|
35
|
+
finalWorld=uniforms.world*finalWorld;
|
|
36
|
+
#else
|
|
37
|
+
finalWorld=mesh.world*finalWorld;
|
|
38
|
+
#endif
|
|
39
|
+
#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)
|
|
40
|
+
finalPreviousWorld=uniforms.previousWorld*finalPreviousWorld;
|
|
41
|
+
#endif
|
|
42
|
+
#endif
|
|
43
|
+
#else
|
|
44
|
+
#if !defined(WORLD_UBO)
|
|
45
|
+
var finalWorld=uniforms.world;
|
|
46
|
+
#else
|
|
47
|
+
var finalWorld=mesh.world;
|
|
48
|
+
#endif
|
|
49
|
+
#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)
|
|
50
|
+
var finalPreviousWorld=uniforms.previousWorld;
|
|
51
|
+
#endif
|
|
52
|
+
#endif
|
|
53
|
+
`;
|
|
54
|
+
e.IncludesShadersStoreWGSL[i] || (e.IncludesShadersStoreWGSL[i] = f);
|
|
55
|
+
//# sourceMappingURL=instancesVertex-evcSIvCA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instancesVertex-evcSIvCA.js","sources":["../node_modules/@babylonjs/core/ShadersWGSL/ShadersInclude/instancesDeclaration.js","../node_modules/@babylonjs/core/ShadersWGSL/ShadersInclude/instancesVertex.js"],"sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore.js\";\nconst name = \"instancesDeclaration\";\nconst shader = `#ifdef INSTANCES\nattribute world0 : vec4<f32>;attribute world1 : vec4<f32>;attribute world2 : vec4<f32>;attribute world3 : vec4<f32>;\n#ifdef INSTANCESCOLOR\nattribute instanceColor : vec4<f32>;\n#endif\n#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)\nuniform world : mat4x4<f32>;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nattribute previousWorld0 : vec4<f32>;attribute previousWorld1 : vec4<f32>;attribute previousWorld2 : vec4<f32>;attribute previousWorld3 : vec4<f32>;\n#ifdef THIN_INSTANCES\nuniform previousWorld : mat4x4<f32>;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nuniform world : mat4x4<f32>;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nuniform previousWorld : mat4x4<f32>;\n#endif\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const instancesDeclarationWGSL = { name, shader };\n//# sourceMappingURL=instancesDeclaration.js.map","// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore.js\";\nconst name = \"instancesVertex\";\nconst shader = `#ifdef INSTANCES\nvar finalWorld=mat4x4<f32>(vertexInputs.world0,vertexInputs.world1,vertexInputs.world2,vertexInputs.world3);\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nvar finalPreviousWorld=mat4x4<f32>(\nvertexInputs.previousWorld0,vertexInputs.previousWorld1,\nvertexInputs.previousWorld2,vertexInputs.previousWorld3);\n#endif\n#ifdef THIN_INSTANCES\n#if !defined(WORLD_UBO)\nfinalWorld=uniforms.world*finalWorld;\n#else\nfinalWorld=mesh.world*finalWorld;\n#endif\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nfinalPreviousWorld=uniforms.previousWorld*finalPreviousWorld;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nvar finalWorld=uniforms.world;\n#else\nvar finalWorld=mesh.world;\n#endif\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nvar finalPreviousWorld=uniforms.previousWorld;\n#endif\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const instancesVertexWGSL = { name, shader };\n//# sourceMappingURL=instancesVertex.js.map"],"names":["name","shader","ShaderStore"],"mappings":";AAEA,MAAMA,IAAO,wBACPC,IAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBVC,EAAY,yBAAyBF,CAAI,MAC1CE,EAAY,yBAAyBF,CAAI,IAAIC;AC1BjD,MAAMD,IAAO,mBACPC,IAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BVC,EAAY,yBAAyBF,CAAI,MAC1CE,EAAY,yBAAyBF,CAAI,IAAIC;","x_google_ignoreList":[0,1]}
|
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
import { c as n, e as _ } from "./index-ChGTkj2q.js";
|
|
2
|
+
class l {
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new KhronosTextureContainer
|
|
5
|
+
* @param data contents of the KTX container file
|
|
6
|
+
* @param facesExpected should be either 1 or 6, based whether a cube texture or or
|
|
7
|
+
*/
|
|
8
|
+
constructor(s, e) {
|
|
9
|
+
if (this.data = s, this.isInvalid = !1, !l.IsValid(s)) {
|
|
10
|
+
this.isInvalid = !0, n.Error("texture missing KTX identifier");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const i = Uint32Array.BYTES_PER_ELEMENT, r = new DataView(this.data.buffer, this.data.byteOffset + 12, 13 * i), a = r.getUint32(0, !0) === 67305985;
|
|
14
|
+
if (this.glType = r.getUint32(1 * i, a), this.glTypeSize = r.getUint32(2 * i, a), this.glFormat = r.getUint32(3 * i, a), this.glInternalFormat = r.getUint32(4 * i, a), this.glBaseInternalFormat = r.getUint32(5 * i, a), this.pixelWidth = r.getUint32(6 * i, a), this.pixelHeight = r.getUint32(7 * i, a), this.pixelDepth = r.getUint32(8 * i, a), this.numberOfArrayElements = r.getUint32(9 * i, a), this.numberOfFaces = r.getUint32(10 * i, a), this.numberOfMipmapLevels = r.getUint32(11 * i, a), this.bytesOfKeyValueData = r.getUint32(12 * i, a), this.glType !== 0) {
|
|
15
|
+
n.Error("only compressed formats currently supported"), this.isInvalid = !0;
|
|
16
|
+
return;
|
|
17
|
+
} else
|
|
18
|
+
this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
|
|
19
|
+
if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
|
|
20
|
+
n.Error("only 2D textures currently supported"), this.isInvalid = !0;
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (this.numberOfArrayElements !== 0) {
|
|
24
|
+
n.Error("texture arrays not currently supported"), this.isInvalid = !0;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (this.numberOfFaces !== e) {
|
|
28
|
+
n.Error("number of faces expected" + e + ", but found " + this.numberOfFaces), this.isInvalid = !0;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
this.loadType = l.COMPRESSED_2D;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Uploads KTX content to a Babylon Texture.
|
|
35
|
+
* It is assumed that the texture has already been created & is currently bound
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
uploadLevels(s, e) {
|
|
39
|
+
switch (this.loadType) {
|
|
40
|
+
case l.COMPRESSED_2D:
|
|
41
|
+
this._upload2DCompressedLevels(s, e);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
_upload2DCompressedLevels(s, e) {
|
|
46
|
+
let i = l.HEADER_LEN + this.bytesOfKeyValueData, r = this.pixelWidth, c = this.pixelHeight;
|
|
47
|
+
const a = e ? this.numberOfMipmapLevels : 1;
|
|
48
|
+
for (let f = 0; f < a; f++) {
|
|
49
|
+
const R = new Int32Array(this.data.buffer, this.data.byteOffset + i, 1)[0];
|
|
50
|
+
i += 4;
|
|
51
|
+
for (let d = 0; d < this.numberOfFaces; d++) {
|
|
52
|
+
const h = new Uint8Array(this.data.buffer, this.data.byteOffset + i, R);
|
|
53
|
+
s.getEngine()._uploadCompressedDataToTextureDirectly(s, s.format, r, c, h, d, f), i += R, i += 3 - (R + 3) % 4;
|
|
54
|
+
}
|
|
55
|
+
r = Math.max(1, r * 0.5), c = Math.max(1, c * 0.5);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Checks if the given data starts with a KTX file identifier.
|
|
60
|
+
* @param data the data to check
|
|
61
|
+
* @returns true if the data is a KTX file or false otherwise
|
|
62
|
+
*/
|
|
63
|
+
static IsValid(s) {
|
|
64
|
+
if (s.byteLength >= 12) {
|
|
65
|
+
const e = new Uint8Array(s.buffer, s.byteOffset, 12);
|
|
66
|
+
if (e[0] === 171 && e[1] === 75 && e[2] === 84 && e[3] === 88 && e[4] === 32 && e[5] === 49 && e[6] === 49 && e[7] === 187 && e[8] === 13 && e[9] === 10 && e[10] === 26 && e[11] === 10)
|
|
67
|
+
return !0;
|
|
68
|
+
}
|
|
69
|
+
return !1;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
l.HEADER_LEN = 12 + 13 * 4;
|
|
73
|
+
l.COMPRESSED_2D = 0;
|
|
74
|
+
l.COMPRESSED_3D = 1;
|
|
75
|
+
l.TEX_2D = 2;
|
|
76
|
+
l.TEX_3D = 3;
|
|
77
|
+
class G {
|
|
78
|
+
/**
|
|
79
|
+
* Constructor
|
|
80
|
+
* @param workers Array of workers to use for actions
|
|
81
|
+
*/
|
|
82
|
+
constructor(s) {
|
|
83
|
+
this._pendingActions = new Array(), this._workerInfos = s.map((e) => ({
|
|
84
|
+
workerPromise: Promise.resolve(e),
|
|
85
|
+
idle: !0
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Terminates all workers and clears any pending actions.
|
|
90
|
+
*/
|
|
91
|
+
dispose() {
|
|
92
|
+
for (const s of this._workerInfos)
|
|
93
|
+
s.workerPromise.then((e) => {
|
|
94
|
+
e.terminate();
|
|
95
|
+
});
|
|
96
|
+
this._workerInfos.length = 0, this._pendingActions.length = 0;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Pushes an action to the worker pool. If all the workers are active, the action will be
|
|
100
|
+
* pended until a worker has completed its action.
|
|
101
|
+
* @param action The action to perform. Call onComplete when the action is complete.
|
|
102
|
+
*/
|
|
103
|
+
push(s) {
|
|
104
|
+
this._executeOnIdleWorker(s) || this._pendingActions.push(s);
|
|
105
|
+
}
|
|
106
|
+
_executeOnIdleWorker(s) {
|
|
107
|
+
for (const e of this._workerInfos)
|
|
108
|
+
if (e.idle)
|
|
109
|
+
return this._execute(e, s), !0;
|
|
110
|
+
return !1;
|
|
111
|
+
}
|
|
112
|
+
_execute(s, e) {
|
|
113
|
+
s.idle = !1, s.workerPromise.then((i) => {
|
|
114
|
+
e(i, () => {
|
|
115
|
+
const r = this._pendingActions.shift();
|
|
116
|
+
r ? this._execute(s, r) : s.idle = !0;
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
class A extends G {
|
|
122
|
+
constructor(s, e, i = A.DefaultOptions) {
|
|
123
|
+
super([]), this._maxWorkers = s, this._createWorkerAsync = e, this._options = i;
|
|
124
|
+
}
|
|
125
|
+
push(s) {
|
|
126
|
+
if (!this._executeOnIdleWorker(s))
|
|
127
|
+
if (this._workerInfos.length < this._maxWorkers) {
|
|
128
|
+
const e = {
|
|
129
|
+
workerPromise: this._createWorkerAsync(),
|
|
130
|
+
idle: !1
|
|
131
|
+
};
|
|
132
|
+
this._workerInfos.push(e), this._execute(e, s);
|
|
133
|
+
} else
|
|
134
|
+
this._pendingActions.push(s);
|
|
135
|
+
}
|
|
136
|
+
_execute(s, e) {
|
|
137
|
+
s.timeoutId && (clearTimeout(s.timeoutId), delete s.timeoutId), super._execute(s, (i, r) => {
|
|
138
|
+
e(i, () => {
|
|
139
|
+
r(), s.idle && (s.timeoutId = setTimeout(() => {
|
|
140
|
+
s.workerPromise.then((a) => {
|
|
141
|
+
a.terminate();
|
|
142
|
+
});
|
|
143
|
+
const c = this._workerInfos.indexOf(s);
|
|
144
|
+
c !== -1 && this._workerInfos.splice(c, 1);
|
|
145
|
+
}, this._options.idleTimeElapsedBeforeRelease));
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
A.DefaultOptions = {
|
|
151
|
+
idleTimeElapsedBeforeRelease: 1e3
|
|
152
|
+
};
|
|
153
|
+
var D;
|
|
154
|
+
(function(t) {
|
|
155
|
+
t[t.ETC1S = 0] = "ETC1S", t[t.UASTC4x4 = 1] = "UASTC4x4";
|
|
156
|
+
})(D || (D = {}));
|
|
157
|
+
var S;
|
|
158
|
+
(function(t) {
|
|
159
|
+
t[t.ASTC_4X4_RGBA = 0] = "ASTC_4X4_RGBA", t[t.BC7_RGBA = 1] = "BC7_RGBA", t[t.BC3_RGBA = 2] = "BC3_RGBA", t[t.BC1_RGB = 3] = "BC1_RGB", t[t.PVRTC1_4_RGBA = 4] = "PVRTC1_4_RGBA", t[t.PVRTC1_4_RGB = 5] = "PVRTC1_4_RGB", t[t.ETC2_RGBA = 6] = "ETC2_RGBA", t[t.ETC1_RGB = 7] = "ETC1_RGB", t[t.RGBA32 = 8] = "RGBA32", t[t.R8 = 9] = "R8", t[t.RG8 = 10] = "RG8";
|
|
160
|
+
})(S || (S = {}));
|
|
161
|
+
var u;
|
|
162
|
+
(function(t) {
|
|
163
|
+
t[t.COMPRESSED_RGBA_BPTC_UNORM_EXT = 36492] = "COMPRESSED_RGBA_BPTC_UNORM_EXT", t[t.COMPRESSED_RGBA_ASTC_4X4_KHR = 37808] = "COMPRESSED_RGBA_ASTC_4X4_KHR", t[t.COMPRESSED_RGB_S3TC_DXT1_EXT = 33776] = "COMPRESSED_RGB_S3TC_DXT1_EXT", t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779] = "COMPRESSED_RGBA_S3TC_DXT5_EXT", t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 35842] = "COMPRESSED_RGBA_PVRTC_4BPPV1_IMG", t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 35840] = "COMPRESSED_RGB_PVRTC_4BPPV1_IMG", t[t.COMPRESSED_RGBA8_ETC2_EAC = 37496] = "COMPRESSED_RGBA8_ETC2_EAC", t[t.COMPRESSED_RGB8_ETC2 = 37492] = "COMPRESSED_RGB8_ETC2", t[t.COMPRESSED_RGB_ETC1_WEBGL = 36196] = "COMPRESSED_RGB_ETC1_WEBGL", t[t.RGBA8Format = 32856] = "RGBA8Format", t[t.R8Format = 33321] = "R8Format", t[t.RG8Format = 33323] = "RG8Format";
|
|
164
|
+
})(u || (u = {}));
|
|
165
|
+
function p(t, s) {
|
|
166
|
+
const e = (s == null ? void 0 : s.jsDecoderModule) || KTX2DECODER;
|
|
167
|
+
t && (t.wasmUASTCToASTC && (e.LiteTranscoder_UASTC_ASTC.WasmModuleURL = t.wasmUASTCToASTC), t.wasmUASTCToBC7 && (e.LiteTranscoder_UASTC_BC7.WasmModuleURL = t.wasmUASTCToBC7), t.wasmUASTCToRGBA_UNORM && (e.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL = t.wasmUASTCToRGBA_UNORM), t.wasmUASTCToRGBA_SRGB && (e.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL = t.wasmUASTCToRGBA_SRGB), t.wasmUASTCToR8_UNORM && (e.LiteTranscoder_UASTC_R8_UNORM.WasmModuleURL = t.wasmUASTCToR8_UNORM), t.wasmUASTCToRG8_UNORM && (e.LiteTranscoder_UASTC_RG8_UNORM.WasmModuleURL = t.wasmUASTCToRG8_UNORM), t.jsMSCTranscoder && (e.MSCTranscoder.JSModuleURL = t.jsMSCTranscoder), t.wasmMSCTranscoder && (e.MSCTranscoder.WasmModuleURL = t.wasmMSCTranscoder), t.wasmZSTDDecoder && (e.ZSTDDecoder.WasmModuleURL = t.wasmZSTDDecoder)), s && (s.wasmUASTCToASTC && (e.LiteTranscoder_UASTC_ASTC.WasmBinary = s.wasmUASTCToASTC), s.wasmUASTCToBC7 && (e.LiteTranscoder_UASTC_BC7.WasmBinary = s.wasmUASTCToBC7), s.wasmUASTCToRGBA_UNORM && (e.LiteTranscoder_UASTC_RGBA_UNORM.WasmBinary = s.wasmUASTCToRGBA_UNORM), s.wasmUASTCToRGBA_SRGB && (e.LiteTranscoder_UASTC_RGBA_SRGB.WasmBinary = s.wasmUASTCToRGBA_SRGB), s.wasmUASTCToR8_UNORM && (e.LiteTranscoder_UASTC_R8_UNORM.WasmBinary = s.wasmUASTCToR8_UNORM), s.wasmUASTCToRG8_UNORM && (e.LiteTranscoder_UASTC_RG8_UNORM.WasmBinary = s.wasmUASTCToRG8_UNORM), s.jsMSCTranscoder && (e.MSCTranscoder.JSModule = s.jsMSCTranscoder), s.wasmMSCTranscoder && (e.MSCTranscoder.WasmBinary = s.wasmMSCTranscoder), s.wasmZSTDDecoder && (e.ZSTDDecoder.WasmBinary = s.wasmZSTDDecoder));
|
|
168
|
+
}
|
|
169
|
+
function M(t) {
|
|
170
|
+
typeof t > "u" && typeof KTX2DECODER < "u" && (t = KTX2DECODER);
|
|
171
|
+
let s;
|
|
172
|
+
onmessage = (e) => {
|
|
173
|
+
if (e.data)
|
|
174
|
+
switch (e.data.action) {
|
|
175
|
+
case "init": {
|
|
176
|
+
const i = e.data.urls;
|
|
177
|
+
i && (i.jsDecoderModule && typeof t > "u" && (importScripts(i.jsDecoderModule), t = KTX2DECODER), p(i)), e.data.wasmBinaries && p(void 0, { ...e.data.wasmBinaries, jsDecoderModule: t }), s = new t.KTX2Decoder(), postMessage({ action: "init" });
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
case "setDefaultDecoderOptions": {
|
|
181
|
+
t.KTX2Decoder.DefaultDecoderOptions = e.data.options;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
case "decode":
|
|
185
|
+
s.decode(e.data.data, e.data.caps, e.data.options).then((i) => {
|
|
186
|
+
const r = [];
|
|
187
|
+
for (let c = 0; c < i.mipmaps.length; ++c) {
|
|
188
|
+
const a = i.mipmaps[c];
|
|
189
|
+
a && a.data && r.push(a.data.buffer);
|
|
190
|
+
}
|
|
191
|
+
postMessage({ action: "decoded", success: !0, decodedData: i }, r);
|
|
192
|
+
}).catch((i) => {
|
|
193
|
+
postMessage({ action: "decoded", success: !1, msg: i });
|
|
194
|
+
});
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
async function y(t, s, e) {
|
|
200
|
+
return await new Promise((i, r) => {
|
|
201
|
+
const c = (f) => {
|
|
202
|
+
t.removeEventListener("error", c), t.removeEventListener("message", a), r(f);
|
|
203
|
+
}, a = (f) => {
|
|
204
|
+
f.data.action === "init" && (t.removeEventListener("error", c), t.removeEventListener("message", a), i(t));
|
|
205
|
+
};
|
|
206
|
+
t.addEventListener("error", c), t.addEventListener("message", a), t.postMessage({
|
|
207
|
+
action: "init",
|
|
208
|
+
urls: e,
|
|
209
|
+
wasmBinaries: s
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
class w {
|
|
214
|
+
constructor() {
|
|
215
|
+
this._isDirty = !0, this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC = !0, this._ktx2DecoderOptions = {};
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Gets the dirty flag
|
|
219
|
+
*/
|
|
220
|
+
get isDirty() {
|
|
221
|
+
return this._isDirty;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* force a (uncompressed) RGBA transcoded format if transcoding a UASTC source format and ASTC + BC7 are not available as a compressed transcoded format
|
|
225
|
+
*/
|
|
226
|
+
get useRGBAIfASTCBC7NotAvailableWhenUASTC() {
|
|
227
|
+
return this._useRGBAIfASTCBC7NotAvailableWhenUASTC;
|
|
228
|
+
}
|
|
229
|
+
set useRGBAIfASTCBC7NotAvailableWhenUASTC(s) {
|
|
230
|
+
this._useRGBAIfASTCBC7NotAvailableWhenUASTC !== s && (this._useRGBAIfASTCBC7NotAvailableWhenUASTC = s, this._isDirty = !0);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* force a (uncompressed) RGBA transcoded format if transcoding a UASTC source format and only BC1 or BC3 are available as a compressed transcoded format.
|
|
234
|
+
* This property is true by default to favor speed over memory, because currently transcoding from UASTC to BC1/3 is slow because the transcoder transcodes
|
|
235
|
+
* to uncompressed and then recompresses the texture
|
|
236
|
+
*/
|
|
237
|
+
get useRGBAIfOnlyBC1BC3AvailableWhenUASTC() {
|
|
238
|
+
return this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC;
|
|
239
|
+
}
|
|
240
|
+
set useRGBAIfOnlyBC1BC3AvailableWhenUASTC(s) {
|
|
241
|
+
this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC !== s && (this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC = s, this._isDirty = !0);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* force to always use (uncompressed) RGBA for transcoded format
|
|
245
|
+
*/
|
|
246
|
+
get forceRGBA() {
|
|
247
|
+
return this._forceRGBA;
|
|
248
|
+
}
|
|
249
|
+
set forceRGBA(s) {
|
|
250
|
+
this._forceRGBA !== s && (this._forceRGBA = s, this._isDirty = !0);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* force to always use (uncompressed) R8 for transcoded format
|
|
254
|
+
*/
|
|
255
|
+
get forceR8() {
|
|
256
|
+
return this._forceR8;
|
|
257
|
+
}
|
|
258
|
+
set forceR8(s) {
|
|
259
|
+
this._forceR8 !== s && (this._forceR8 = s, this._isDirty = !0);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* force to always use (uncompressed) RG8 for transcoded format
|
|
263
|
+
*/
|
|
264
|
+
get forceRG8() {
|
|
265
|
+
return this._forceRG8;
|
|
266
|
+
}
|
|
267
|
+
set forceRG8(s) {
|
|
268
|
+
this._forceRG8 !== s && (this._forceRG8 = s, this._isDirty = !0);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* list of transcoders to bypass when looking for a suitable transcoder. The available transcoders are:
|
|
272
|
+
* UniversalTranscoder_UASTC_ASTC
|
|
273
|
+
* UniversalTranscoder_UASTC_BC7
|
|
274
|
+
* UniversalTranscoder_UASTC_RGBA_UNORM
|
|
275
|
+
* UniversalTranscoder_UASTC_RGBA_SRGB
|
|
276
|
+
* UniversalTranscoder_UASTC_R8_UNORM
|
|
277
|
+
* UniversalTranscoder_UASTC_RG8_UNORM
|
|
278
|
+
* MSCTranscoder
|
|
279
|
+
*/
|
|
280
|
+
get bypassTranscoders() {
|
|
281
|
+
return this._bypassTranscoders;
|
|
282
|
+
}
|
|
283
|
+
set bypassTranscoders(s) {
|
|
284
|
+
this._bypassTranscoders !== s && (this._bypassTranscoders = s, this._isDirty = !0);
|
|
285
|
+
}
|
|
286
|
+
/** @internal */
|
|
287
|
+
_getKTX2DecoderOptions() {
|
|
288
|
+
if (!this._isDirty)
|
|
289
|
+
return this._ktx2DecoderOptions;
|
|
290
|
+
this._isDirty = !1;
|
|
291
|
+
const s = {
|
|
292
|
+
useRGBAIfASTCBC7NotAvailableWhenUASTC: this._useRGBAIfASTCBC7NotAvailableWhenUASTC,
|
|
293
|
+
forceRGBA: this._forceRGBA,
|
|
294
|
+
forceR8: this._forceR8,
|
|
295
|
+
forceRG8: this._forceRG8,
|
|
296
|
+
bypassTranscoders: this._bypassTranscoders
|
|
297
|
+
};
|
|
298
|
+
return this.useRGBAIfOnlyBC1BC3AvailableWhenUASTC && (s.transcodeFormatDecisionTree = {
|
|
299
|
+
UASTC: {
|
|
300
|
+
transcodeFormat: [S.BC1_RGB, S.BC3_RGBA],
|
|
301
|
+
yes: {
|
|
302
|
+
transcodeFormat: S.RGBA32,
|
|
303
|
+
engineFormat: 32856,
|
|
304
|
+
roundToMultiple4: !1
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}), this._ktx2DecoderOptions = s, s;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
class o {
|
|
311
|
+
static GetDefaultNumWorkers() {
|
|
312
|
+
return typeof navigator != "object" || !navigator.hardwareConcurrency ? 1 : Math.min(Math.floor(navigator.hardwareConcurrency * 0.5), 4);
|
|
313
|
+
}
|
|
314
|
+
static _Initialize(s) {
|
|
315
|
+
if (o._WorkerPoolPromise || o._DecoderModulePromise)
|
|
316
|
+
return;
|
|
317
|
+
const e = {
|
|
318
|
+
jsDecoderModule: _.GetBabylonScriptURL(this.URLConfig.jsDecoderModule, !0),
|
|
319
|
+
wasmUASTCToASTC: _.GetBabylonScriptURL(this.URLConfig.wasmUASTCToASTC, !0),
|
|
320
|
+
wasmUASTCToBC7: _.GetBabylonScriptURL(this.URLConfig.wasmUASTCToBC7, !0),
|
|
321
|
+
wasmUASTCToRGBA_UNORM: _.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRGBA_UNORM, !0),
|
|
322
|
+
wasmUASTCToRGBA_SRGB: _.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRGBA_SRGB, !0),
|
|
323
|
+
wasmUASTCToR8_UNORM: _.GetBabylonScriptURL(this.URLConfig.wasmUASTCToR8_UNORM, !0),
|
|
324
|
+
wasmUASTCToRG8_UNORM: _.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRG8_UNORM, !0),
|
|
325
|
+
jsMSCTranscoder: _.GetBabylonScriptURL(this.URLConfig.jsMSCTranscoder, !0),
|
|
326
|
+
wasmMSCTranscoder: _.GetBabylonScriptURL(this.URLConfig.wasmMSCTranscoder, !0),
|
|
327
|
+
wasmZSTDDecoder: _.GetBabylonScriptURL(this.URLConfig.wasmZSTDDecoder, !0)
|
|
328
|
+
};
|
|
329
|
+
s && typeof Worker == "function" && typeof URL < "u" ? o._WorkerPoolPromise = new Promise((i) => {
|
|
330
|
+
const r = `${p}(${M})()`, c = URL.createObjectURL(new Blob([r], { type: "application/javascript" }));
|
|
331
|
+
i(new A(s, async () => await y(new Worker(c), void 0, e)));
|
|
332
|
+
}) : typeof o._KTX2DecoderModule > "u" ? o._DecoderModulePromise = _.LoadBabylonScriptAsync(e.jsDecoderModule).then(() => (o._KTX2DecoderModule = KTX2DECODER, o._KTX2DecoderModule.MSCTranscoder.UseFromWorkerThread = !1, o._KTX2DecoderModule.WASMMemoryManager.LoadBinariesFromCurrentThread = !0, p(e, o._KTX2DecoderModule), new o._KTX2DecoderModule.KTX2Decoder())) : (o._KTX2DecoderModule.MSCTranscoder.UseFromWorkerThread = !1, o._KTX2DecoderModule.WASMMemoryManager.LoadBinariesFromCurrentThread = !0, o._DecoderModulePromise = Promise.resolve(new o._KTX2DecoderModule.KTX2Decoder()));
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Constructor
|
|
336
|
+
* @param engine The engine to use
|
|
337
|
+
* @param numWorkersOrOptions The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
|
|
338
|
+
*/
|
|
339
|
+
constructor(s, e = o.DefaultNumWorkers) {
|
|
340
|
+
var r;
|
|
341
|
+
this._engine = s;
|
|
342
|
+
const i = typeof e == "object" && e.workerPool || o.WorkerPool;
|
|
343
|
+
if (i)
|
|
344
|
+
o._WorkerPoolPromise = Promise.resolve(i);
|
|
345
|
+
else {
|
|
346
|
+
typeof e == "object" ? o._KTX2DecoderModule = (r = e == null ? void 0 : e.binariesAndModulesContainer) == null ? void 0 : r.jsDecoderModule : typeof KTX2DECODER < "u" && (o._KTX2DecoderModule = KTX2DECODER);
|
|
347
|
+
const c = typeof e == "number" ? e : e.numWorkers ?? o.DefaultNumWorkers;
|
|
348
|
+
o._Initialize(c);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* @internal
|
|
353
|
+
*/
|
|
354
|
+
async _uploadAsync(s, e, i) {
|
|
355
|
+
const r = this._engine.getCaps(), c = {
|
|
356
|
+
astc: !!r.astc,
|
|
357
|
+
bptc: !!r.bptc,
|
|
358
|
+
s3tc: !!r.s3tc,
|
|
359
|
+
pvrtc: !!r.pvrtc,
|
|
360
|
+
etc2: !!r.etc2,
|
|
361
|
+
etc1: !!r.etc1
|
|
362
|
+
};
|
|
363
|
+
if (o._WorkerPoolPromise) {
|
|
364
|
+
const a = await o._WorkerPoolPromise;
|
|
365
|
+
return await new Promise((f, R) => {
|
|
366
|
+
a.push((d, h) => {
|
|
367
|
+
const T = (m) => {
|
|
368
|
+
d.removeEventListener("error", T), d.removeEventListener("message", C), R(m), h();
|
|
369
|
+
}, C = (m) => {
|
|
370
|
+
if (m.data.action === "decoded") {
|
|
371
|
+
if (d.removeEventListener("error", T), d.removeEventListener("message", C), !m.data.success)
|
|
372
|
+
R({ message: m.data.msg });
|
|
373
|
+
else
|
|
374
|
+
try {
|
|
375
|
+
this._createTexture(m.data.decodedData, e, i), f();
|
|
376
|
+
} catch (U) {
|
|
377
|
+
R({ message: U });
|
|
378
|
+
}
|
|
379
|
+
h();
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
d.addEventListener("error", T), d.addEventListener("message", C), d.postMessage({ action: "setDefaultDecoderOptions", options: o.DefaultDecoderOptions._getKTX2DecoderOptions() });
|
|
383
|
+
const B = new Uint8Array(s.byteLength);
|
|
384
|
+
B.set(new Uint8Array(s.buffer, s.byteOffset, s.byteLength)), d.postMessage({ action: "decode", data: B, caps: c, options: i }, [B.buffer]);
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
} else if (o._DecoderModulePromise) {
|
|
388
|
+
const a = await o._DecoderModulePromise;
|
|
389
|
+
return o.DefaultDecoderOptions.isDirty && (o._KTX2DecoderModule.KTX2Decoder.DefaultDecoderOptions = o.DefaultDecoderOptions._getKTX2DecoderOptions()), await new Promise((f, R) => {
|
|
390
|
+
a.decode(s, r).then((d) => {
|
|
391
|
+
this._createTexture(d, e), f();
|
|
392
|
+
}).catch((d) => {
|
|
393
|
+
R({ message: d });
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
throw new Error("KTX2 decoder module is not available");
|
|
398
|
+
}
|
|
399
|
+
_createTexture(s, e, i) {
|
|
400
|
+
this._engine._bindTextureDirectly(3553, e), i && (i.transcodedFormat = s.transcodedFormat, i.isInGammaSpace = s.isInGammaSpace, i.hasAlpha = s.hasAlpha, i.transcoderName = s.transcoderName);
|
|
401
|
+
let c = !0;
|
|
402
|
+
switch (s.transcodedFormat) {
|
|
403
|
+
case 32856:
|
|
404
|
+
e.type = 0, e.format = 5;
|
|
405
|
+
break;
|
|
406
|
+
case 33321:
|
|
407
|
+
e.type = 0, e.format = 6;
|
|
408
|
+
break;
|
|
409
|
+
case 33323:
|
|
410
|
+
e.type = 0, e.format = 7;
|
|
411
|
+
break;
|
|
412
|
+
default:
|
|
413
|
+
e.format = s.transcodedFormat, c = !1;
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
if (e._gammaSpace = s.isInGammaSpace, e.generateMipMaps = s.mipmaps.length > 1, s.errors)
|
|
417
|
+
throw new Error("KTX2 container - could not transcode the data. " + s.errors);
|
|
418
|
+
for (let a = 0; a < s.mipmaps.length; ++a) {
|
|
419
|
+
const f = s.mipmaps[a];
|
|
420
|
+
if (!f || !f.data)
|
|
421
|
+
throw new Error("KTX2 container - could not transcode one of the image");
|
|
422
|
+
c ? (e.width = f.width, e.height = f.height, this._engine._uploadDataToTextureDirectly(e, f.data, 0, a, void 0, !0)) : this._engine._uploadCompressedDataToTextureDirectly(e, s.transcodedFormat, f.width, f.height, f.data, 0, a);
|
|
423
|
+
}
|
|
424
|
+
e._extension = ".ktx2", e.width = s.mipmaps[0].width, e.height = s.mipmaps[0].height, e.isReady = !0, this._engine._bindTextureDirectly(3553, null);
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Checks if the given data starts with a KTX2 file identifier.
|
|
428
|
+
* @param data the data to check
|
|
429
|
+
* @returns true if the data is a KTX2 file or false otherwise
|
|
430
|
+
*/
|
|
431
|
+
static IsValid(s) {
|
|
432
|
+
if (s.byteLength >= 12) {
|
|
433
|
+
const e = new Uint8Array(s.buffer, s.byteOffset, 12);
|
|
434
|
+
if (e[0] === 171 && e[1] === 75 && e[2] === 84 && e[3] === 88 && e[4] === 32 && e[5] === 50 && e[6] === 48 && e[7] === 187 && e[8] === 13 && e[9] === 10 && e[10] === 26 && e[11] === 10)
|
|
435
|
+
return !0;
|
|
436
|
+
}
|
|
437
|
+
return !1;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
o.URLConfig = {
|
|
441
|
+
jsDecoderModule: "https://cdn.babylonjs.com/babylon.ktx2Decoder.js",
|
|
442
|
+
wasmUASTCToASTC: null,
|
|
443
|
+
wasmUASTCToBC7: null,
|
|
444
|
+
wasmUASTCToRGBA_UNORM: null,
|
|
445
|
+
wasmUASTCToRGBA_SRGB: null,
|
|
446
|
+
wasmUASTCToR8_UNORM: null,
|
|
447
|
+
wasmUASTCToRG8_UNORM: null,
|
|
448
|
+
jsMSCTranscoder: null,
|
|
449
|
+
wasmMSCTranscoder: null,
|
|
450
|
+
wasmZSTDDecoder: null
|
|
451
|
+
};
|
|
452
|
+
o.DefaultNumWorkers = o.GetDefaultNumWorkers();
|
|
453
|
+
o.DefaultDecoderOptions = new w();
|
|
454
|
+
function E(t) {
|
|
455
|
+
switch (t) {
|
|
456
|
+
case 35916:
|
|
457
|
+
return 33776;
|
|
458
|
+
case 35918:
|
|
459
|
+
return 33778;
|
|
460
|
+
case 35919:
|
|
461
|
+
return 33779;
|
|
462
|
+
case 37493:
|
|
463
|
+
return 37492;
|
|
464
|
+
case 37497:
|
|
465
|
+
return 37496;
|
|
466
|
+
case 37495:
|
|
467
|
+
return 37494;
|
|
468
|
+
case 37840:
|
|
469
|
+
return 37808;
|
|
470
|
+
case 36493:
|
|
471
|
+
return 36492;
|
|
472
|
+
}
|
|
473
|
+
return null;
|
|
474
|
+
}
|
|
475
|
+
class g {
|
|
476
|
+
constructor() {
|
|
477
|
+
this.supportCascades = !1;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Uploads the cube texture data to the WebGL texture. It has already been bound.
|
|
481
|
+
* @param data contains the texture data
|
|
482
|
+
* @param texture defines the BabylonJS internal texture
|
|
483
|
+
* @param createPolynomials will be true if polynomials have been requested
|
|
484
|
+
* @param onLoad defines the callback to trigger once the texture is ready
|
|
485
|
+
*/
|
|
486
|
+
loadCubeData(s, e, i, r) {
|
|
487
|
+
if (Array.isArray(s))
|
|
488
|
+
return;
|
|
489
|
+
e._invertVScale = !e.invertY;
|
|
490
|
+
const c = e.getEngine(), a = new l(s, 6), f = a.numberOfMipmapLevels > 1 && e.generateMipMaps;
|
|
491
|
+
c._unpackFlipY(!0), a.uploadLevels(e, e.generateMipMaps), e.width = a.pixelWidth, e.height = a.pixelHeight, c._setCubeMapTextureParams(e, f, a.numberOfMipmapLevels - 1), e.isReady = !0, e.onLoadedObservable.notifyObservers(e), e.onLoadedObservable.clear(), r && r();
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
|
|
495
|
+
* @param data contains the texture data
|
|
496
|
+
* @param texture defines the BabylonJS internal texture
|
|
497
|
+
* @param callback defines the method to call once ready to upload
|
|
498
|
+
* @param options
|
|
499
|
+
*/
|
|
500
|
+
loadData(s, e, i, r) {
|
|
501
|
+
if (l.IsValid(s)) {
|
|
502
|
+
e._invertVScale = !e.invertY;
|
|
503
|
+
const c = new l(s, 1), a = E(c.glInternalFormat);
|
|
504
|
+
a ? (e.format = a, e._useSRGBBuffer = e.getEngine()._getUseSRGBBuffer(!0, e.generateMipMaps), e._gammaSpace = !0) : e.format = c.glInternalFormat, i(c.pixelWidth, c.pixelHeight, e.generateMipMaps, !0, () => {
|
|
505
|
+
c.uploadLevels(e, e.generateMipMaps);
|
|
506
|
+
}, c.isInvalid);
|
|
507
|
+
} else o.IsValid(s) ? new o(e.getEngine())._uploadAsync(s, e, r).then(() => {
|
|
508
|
+
i(e.width, e.height, e.generateMipMaps, !0, () => {
|
|
509
|
+
}, !1);
|
|
510
|
+
}, (a) => {
|
|
511
|
+
n.Warn(`Failed to load KTX2 texture data: ${a.message}`), i(0, 0, !1, !1, () => {
|
|
512
|
+
}, !0);
|
|
513
|
+
}) : (n.Error("texture missing KTX identifier"), i(0, 0, !1, !1, () => {
|
|
514
|
+
}, !0));
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
export {
|
|
518
|
+
g as _KTXTextureLoader
|
|
519
|
+
};
|
|
520
|
+
//# sourceMappingURL=ktxTextureLoader-Dg1h0a-4.js.map
|