@babylonjs/loaders 5.0.0-rc.5 → 5.0.0-rc.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. package/OBJ/index.d.ts +4 -4
  2. package/OBJ/index.js +4 -4
  3. package/OBJ/mtlFileLoader.d.ts +41 -41
  4. package/OBJ/mtlFileLoader.js +232 -232
  5. package/OBJ/objFileLoader.d.ts +126 -126
  6. package/OBJ/objFileLoader.js +296 -296
  7. package/OBJ/objLoadingOptions.d.ts +43 -43
  8. package/OBJ/objLoadingOptions.js +1 -1
  9. package/OBJ/solidParser.d.ts +154 -154
  10. package/OBJ/solidParser.js +693 -693
  11. package/STL/index.d.ts +1 -1
  12. package/STL/index.js +1 -1
  13. package/STL/stlFileLoader.d.ts +64 -64
  14. package/STL/stlFileLoader.js +233 -233
  15. package/glTF/1.0/glTFBinaryExtension.d.ts +13 -13
  16. package/glTF/1.0/glTFBinaryExtension.js +60 -60
  17. package/glTF/1.0/glTFLoader.d.ts +136 -136
  18. package/glTF/1.0/glTFLoader.js +1815 -1815
  19. package/glTF/1.0/glTFLoaderInterfaces.d.ts +412 -412
  20. package/glTF/1.0/glTFLoaderInterfaces.js +95 -95
  21. package/glTF/1.0/glTFLoaderUtils.d.ts +62 -62
  22. package/glTF/1.0/glTFLoaderUtils.js +250 -250
  23. package/glTF/1.0/glTFMaterialsCommonExtension.d.ts +10 -10
  24. package/glTF/1.0/glTFMaterialsCommonExtension.js +129 -129
  25. package/glTF/1.0/index.d.ts +5 -5
  26. package/glTF/1.0/index.js +5 -5
  27. package/glTF/2.0/Extensions/EXT_lights_image_based.d.ts +43 -43
  28. package/glTF/2.0/Extensions/EXT_lights_image_based.js +117 -117
  29. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +36 -36
  30. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +88 -88
  31. package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +34 -34
  32. package/glTF/2.0/Extensions/EXT_meshopt_compression.js +49 -49
  33. package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +29 -29
  34. package/glTF/2.0/Extensions/EXT_texture_webp.js +40 -40
  35. package/glTF/2.0/Extensions/ExtrasAsMetadata.d.ts +50 -50
  36. package/glTF/2.0/Extensions/ExtrasAsMetadata.js +73 -73
  37. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +39 -39
  38. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +112 -112
  39. package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +36 -36
  40. package/glTF/2.0/Extensions/KHR_lights_punctual.js +89 -89
  41. package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +39 -39
  42. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +94 -94
  43. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +38 -38
  44. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +53 -53
  45. package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +42 -42
  46. package/glTF/2.0/Extensions/KHR_materials_ior.js +62 -62
  47. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.d.ts +38 -38
  48. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +80 -80
  49. package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +39 -39
  50. package/glTF/2.0/Extensions/KHR_materials_sheen.js +84 -84
  51. package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +38 -38
  52. package/glTF/2.0/Extensions/KHR_materials_specular.js +74 -74
  53. package/glTF/2.0/Extensions/KHR_materials_translucency.d.ts +39 -39
  54. package/glTF/2.0/Extensions/KHR_materials_translucency.js +83 -83
  55. package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +38 -38
  56. package/glTF/2.0/Extensions/KHR_materials_transmission.js +288 -288
  57. package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +38 -38
  58. package/glTF/2.0/Extensions/KHR_materials_unlit.js +73 -73
  59. package/glTF/2.0/Extensions/KHR_materials_variants.d.ts +87 -87
  60. package/glTF/2.0/Extensions/KHR_materials_variants.js +254 -254
  61. package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +39 -39
  62. package/glTF/2.0/Extensions/KHR_materials_volume.js +85 -85
  63. package/glTF/2.0/Extensions/KHR_mesh_quantization.d.ts +22 -22
  64. package/glTF/2.0/Extensions/KHR_mesh_quantization.js +23 -23
  65. package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +29 -29
  66. package/glTF/2.0/Extensions/KHR_texture_basisu.js +40 -40
  67. package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +33 -33
  68. package/glTF/2.0/Extensions/KHR_texture_transform.js +61 -61
  69. package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +32 -32
  70. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +49 -49
  71. package/glTF/2.0/Extensions/MSFT_audio_emitter.d.ts +54 -54
  72. package/glTF/2.0/Extensions/MSFT_audio_emitter.js +240 -240
  73. package/glTF/2.0/Extensions/MSFT_lod.d.ts +109 -109
  74. package/glTF/2.0/Extensions/MSFT_lod.js +369 -369
  75. package/glTF/2.0/Extensions/MSFT_minecraftMesh.d.ts +14 -14
  76. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +36 -36
  77. package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +14 -14
  78. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +36 -36
  79. package/glTF/2.0/Extensions/index.d.ts +26 -26
  80. package/glTF/2.0/Extensions/index.js +26 -26
  81. package/glTF/2.0/glTFLoader.d.ts +405 -405
  82. package/glTF/2.0/glTFLoader.js +2366 -2366
  83. package/glTF/2.0/glTFLoaderExtension.d.ts +152 -152
  84. package/glTF/2.0/glTFLoaderExtension.js +1 -1
  85. package/glTF/2.0/glTFLoaderInterfaces.d.ts +211 -211
  86. package/glTF/2.0/glTFLoaderInterfaces.js +1 -1
  87. package/glTF/2.0/index.d.ts +4 -4
  88. package/glTF/2.0/index.js +4 -4
  89. package/glTF/glTFFileLoader.d.ts +433 -433
  90. package/glTF/glTFFileLoader.js +927 -927
  91. package/glTF/glTFValidation.d.ts +29 -29
  92. package/glTF/glTFValidation.js +123 -123
  93. package/glTF/index.d.ts +5 -5
  94. package/glTF/index.js +5 -5
  95. package/index.d.ts +3 -3
  96. package/index.js +3 -3
  97. package/legacy/legacy-glTF.d.ts +2 -2
  98. package/legacy/legacy-glTF.js +18 -18
  99. package/legacy/legacy-glTF1.d.ts +2 -2
  100. package/legacy/legacy-glTF1.js +14 -14
  101. package/legacy/legacy-glTF1FileLoader.d.ts +2 -2
  102. package/legacy/legacy-glTF1FileLoader.js +3 -3
  103. package/legacy/legacy-glTF2.d.ts +2 -2
  104. package/legacy/legacy-glTF2.js +32 -32
  105. package/legacy/legacy-glTF2FileLoader.d.ts +2 -2
  106. package/legacy/legacy-glTF2FileLoader.js +3 -3
  107. package/legacy/legacy-glTFFileLoader.d.ts +3 -3
  108. package/legacy/legacy-glTFFileLoader.js +4 -4
  109. package/legacy/legacy-objFileLoader.d.ts +1 -1
  110. package/legacy/legacy-objFileLoader.js +12 -12
  111. package/legacy/legacy-stlFileLoader.d.ts +1 -1
  112. package/legacy/legacy-stlFileLoader.js +12 -12
  113. package/legacy/legacy.d.ts +6 -6
  114. package/legacy/legacy.js +7 -7
  115. package/package.json +3 -3
@@ -1,130 +1,130 @@
1
- import { __extends } from "tslib";
2
- import { GLTFLoaderExtension, GLTFLoaderBase, GLTFLoader } from "./glTFLoader.js";
3
- import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
4
- import { Color3 } from "@babylonjs/core/Maths/math.color.js";
5
- import { Tools } from "@babylonjs/core/Misc/tools.js";
6
- import { Material } from "@babylonjs/core/Materials/material.js";
7
- import { StandardMaterial } from "@babylonjs/core/Materials/standardMaterial.js";
8
- import { HemisphericLight } from "@babylonjs/core/Lights/hemisphericLight.js";
9
- import { DirectionalLight } from "@babylonjs/core/Lights/directionalLight.js";
10
- import { PointLight } from "@babylonjs/core/Lights/pointLight.js";
11
- import { SpotLight } from "@babylonjs/core/Lights/spotLight.js";
12
- /** @hidden */
13
- var GLTFMaterialsCommonExtension = /** @class */ (function (_super) {
14
- __extends(GLTFMaterialsCommonExtension, _super);
15
- function GLTFMaterialsCommonExtension() {
16
- return _super.call(this, "KHR_materials_common") || this;
17
- }
18
- GLTFMaterialsCommonExtension.prototype.loadRuntimeExtensionsAsync = function (gltfRuntime) {
19
- if (!gltfRuntime.extensions) {
20
- return false;
21
- }
22
- var extension = gltfRuntime.extensions[this.name];
23
- if (!extension) {
24
- return false;
25
- }
26
- // Create lights
27
- var lights = extension.lights;
28
- if (lights) {
29
- for (var thing in lights) {
30
- var light = lights[thing];
31
- switch (light.type) {
32
- case "ambient": {
33
- var ambientLight = new HemisphericLight(light.name, new Vector3(0, 1, 0), gltfRuntime.scene);
34
- var ambient = light.ambient;
35
- if (ambient) {
36
- ambientLight.diffuse = Color3.FromArray(ambient.color || [1, 1, 1]);
37
- }
38
- break;
39
- }
40
- case "point": {
41
- var pointLight = new PointLight(light.name, new Vector3(10, 10, 10), gltfRuntime.scene);
42
- var point = light.point;
43
- if (point) {
44
- pointLight.diffuse = Color3.FromArray(point.color || [1, 1, 1]);
45
- }
46
- break;
47
- }
48
- case "directional": {
49
- var dirLight = new DirectionalLight(light.name, new Vector3(0, -1, 0), gltfRuntime.scene);
50
- var directional = light.directional;
51
- if (directional) {
52
- dirLight.diffuse = Color3.FromArray(directional.color || [1, 1, 1]);
53
- }
54
- break;
55
- }
56
- case "spot": {
57
- var spot = light.spot;
58
- if (spot) {
59
- var spotLight = new SpotLight(light.name, new Vector3(0, 10, 0), new Vector3(0, -1, 0), spot.fallOffAngle || Math.PI, spot.fallOffExponent || 0.0, gltfRuntime.scene);
60
- spotLight.diffuse = Color3.FromArray(spot.color || [1, 1, 1]);
61
- }
62
- break;
63
- }
64
- default:
65
- Tools.Warn('GLTF Material Common extension: light type "' + light.type + "” not supported");
66
- break;
67
- }
68
- }
69
- }
70
- return false;
71
- };
72
- GLTFMaterialsCommonExtension.prototype.loadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
73
- var material = gltfRuntime.materials[id];
74
- if (!material || !material.extensions) {
75
- return false;
76
- }
77
- var extension = material.extensions[this.name];
78
- if (!extension) {
79
- return false;
80
- }
81
- var standardMaterial = new StandardMaterial(id, gltfRuntime.scene);
82
- standardMaterial.sideOrientation = Material.CounterClockWiseSideOrientation;
83
- if (extension.technique === "CONSTANT") {
84
- standardMaterial.disableLighting = true;
85
- }
86
- standardMaterial.backFaceCulling = extension.doubleSided === undefined ? false : !extension.doubleSided;
87
- standardMaterial.alpha = extension.values.transparency === undefined ? 1.0 : extension.values.transparency;
88
- standardMaterial.specularPower = extension.values.shininess === undefined ? 0.0 : extension.values.shininess;
89
- // Ambient
90
- if (typeof extension.values.ambient === "string") {
91
- this._loadTexture(gltfRuntime, extension.values.ambient, standardMaterial, "ambientTexture", onError);
92
- }
93
- else {
94
- standardMaterial.ambientColor = Color3.FromArray(extension.values.ambient || [0, 0, 0]);
95
- }
96
- // Diffuse
97
- if (typeof extension.values.diffuse === "string") {
98
- this._loadTexture(gltfRuntime, extension.values.diffuse, standardMaterial, "diffuseTexture", onError);
99
- }
100
- else {
101
- standardMaterial.diffuseColor = Color3.FromArray(extension.values.diffuse || [0, 0, 0]);
102
- }
103
- // Emission
104
- if (typeof extension.values.emission === "string") {
105
- this._loadTexture(gltfRuntime, extension.values.emission, standardMaterial, "emissiveTexture", onError);
106
- }
107
- else {
108
- standardMaterial.emissiveColor = Color3.FromArray(extension.values.emission || [0, 0, 0]);
109
- }
110
- // Specular
111
- if (typeof extension.values.specular === "string") {
112
- this._loadTexture(gltfRuntime, extension.values.specular, standardMaterial, "specularTexture", onError);
113
- }
114
- else {
115
- standardMaterial.specularColor = Color3.FromArray(extension.values.specular || [0, 0, 0]);
116
- }
117
- return true;
118
- };
119
- GLTFMaterialsCommonExtension.prototype._loadTexture = function (gltfRuntime, id, material, propertyPath, onError) {
120
- // Create buffer from texture url
121
- GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, function (buffer) {
122
- // Create texture from buffer
123
- GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, function (texture) { return (material[propertyPath] = texture); });
124
- }, onError);
125
- };
126
- return GLTFMaterialsCommonExtension;
127
- }(GLTFLoaderExtension));
128
- export { GLTFMaterialsCommonExtension };
129
- GLTFLoader.RegisterExtension(new GLTFMaterialsCommonExtension());
1
+ import { __extends } from "tslib";
2
+ import { GLTFLoaderExtension, GLTFLoaderBase, GLTFLoader } from "./glTFLoader";
3
+ import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
4
+ import { Color3 } from "@babylonjs/core/Maths/math.color.js";
5
+ import { Tools } from "@babylonjs/core/Misc/tools.js";
6
+ import { Material } from "@babylonjs/core/Materials/material.js";
7
+ import { StandardMaterial } from "@babylonjs/core/Materials/standardMaterial.js";
8
+ import { HemisphericLight } from "@babylonjs/core/Lights/hemisphericLight.js";
9
+ import { DirectionalLight } from "@babylonjs/core/Lights/directionalLight.js";
10
+ import { PointLight } from "@babylonjs/core/Lights/pointLight.js";
11
+ import { SpotLight } from "@babylonjs/core/Lights/spotLight.js";
12
+ /** @hidden */
13
+ var GLTFMaterialsCommonExtension = /** @class */ (function (_super) {
14
+ __extends(GLTFMaterialsCommonExtension, _super);
15
+ function GLTFMaterialsCommonExtension() {
16
+ return _super.call(this, "KHR_materials_common") || this;
17
+ }
18
+ GLTFMaterialsCommonExtension.prototype.loadRuntimeExtensionsAsync = function (gltfRuntime) {
19
+ if (!gltfRuntime.extensions) {
20
+ return false;
21
+ }
22
+ var extension = gltfRuntime.extensions[this.name];
23
+ if (!extension) {
24
+ return false;
25
+ }
26
+ // Create lights
27
+ var lights = extension.lights;
28
+ if (lights) {
29
+ for (var thing in lights) {
30
+ var light = lights[thing];
31
+ switch (light.type) {
32
+ case "ambient": {
33
+ var ambientLight = new HemisphericLight(light.name, new Vector3(0, 1, 0), gltfRuntime.scene);
34
+ var ambient = light.ambient;
35
+ if (ambient) {
36
+ ambientLight.diffuse = Color3.FromArray(ambient.color || [1, 1, 1]);
37
+ }
38
+ break;
39
+ }
40
+ case "point": {
41
+ var pointLight = new PointLight(light.name, new Vector3(10, 10, 10), gltfRuntime.scene);
42
+ var point = light.point;
43
+ if (point) {
44
+ pointLight.diffuse = Color3.FromArray(point.color || [1, 1, 1]);
45
+ }
46
+ break;
47
+ }
48
+ case "directional": {
49
+ var dirLight = new DirectionalLight(light.name, new Vector3(0, -1, 0), gltfRuntime.scene);
50
+ var directional = light.directional;
51
+ if (directional) {
52
+ dirLight.diffuse = Color3.FromArray(directional.color || [1, 1, 1]);
53
+ }
54
+ break;
55
+ }
56
+ case "spot": {
57
+ var spot = light.spot;
58
+ if (spot) {
59
+ var spotLight = new SpotLight(light.name, new Vector3(0, 10, 0), new Vector3(0, -1, 0), spot.fallOffAngle || Math.PI, spot.fallOffExponent || 0.0, gltfRuntime.scene);
60
+ spotLight.diffuse = Color3.FromArray(spot.color || [1, 1, 1]);
61
+ }
62
+ break;
63
+ }
64
+ default:
65
+ Tools.Warn('GLTF Material Common extension: light type "' + light.type + "” not supported");
66
+ break;
67
+ }
68
+ }
69
+ }
70
+ return false;
71
+ };
72
+ GLTFMaterialsCommonExtension.prototype.loadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
73
+ var material = gltfRuntime.materials[id];
74
+ if (!material || !material.extensions) {
75
+ return false;
76
+ }
77
+ var extension = material.extensions[this.name];
78
+ if (!extension) {
79
+ return false;
80
+ }
81
+ var standardMaterial = new StandardMaterial(id, gltfRuntime.scene);
82
+ standardMaterial.sideOrientation = Material.CounterClockWiseSideOrientation;
83
+ if (extension.technique === "CONSTANT") {
84
+ standardMaterial.disableLighting = true;
85
+ }
86
+ standardMaterial.backFaceCulling = extension.doubleSided === undefined ? false : !extension.doubleSided;
87
+ standardMaterial.alpha = extension.values.transparency === undefined ? 1.0 : extension.values.transparency;
88
+ standardMaterial.specularPower = extension.values.shininess === undefined ? 0.0 : extension.values.shininess;
89
+ // Ambient
90
+ if (typeof extension.values.ambient === "string") {
91
+ this._loadTexture(gltfRuntime, extension.values.ambient, standardMaterial, "ambientTexture", onError);
92
+ }
93
+ else {
94
+ standardMaterial.ambientColor = Color3.FromArray(extension.values.ambient || [0, 0, 0]);
95
+ }
96
+ // Diffuse
97
+ if (typeof extension.values.diffuse === "string") {
98
+ this._loadTexture(gltfRuntime, extension.values.diffuse, standardMaterial, "diffuseTexture", onError);
99
+ }
100
+ else {
101
+ standardMaterial.diffuseColor = Color3.FromArray(extension.values.diffuse || [0, 0, 0]);
102
+ }
103
+ // Emission
104
+ if (typeof extension.values.emission === "string") {
105
+ this._loadTexture(gltfRuntime, extension.values.emission, standardMaterial, "emissiveTexture", onError);
106
+ }
107
+ else {
108
+ standardMaterial.emissiveColor = Color3.FromArray(extension.values.emission || [0, 0, 0]);
109
+ }
110
+ // Specular
111
+ if (typeof extension.values.specular === "string") {
112
+ this._loadTexture(gltfRuntime, extension.values.specular, standardMaterial, "specularTexture", onError);
113
+ }
114
+ else {
115
+ standardMaterial.specularColor = Color3.FromArray(extension.values.specular || [0, 0, 0]);
116
+ }
117
+ return true;
118
+ };
119
+ GLTFMaterialsCommonExtension.prototype._loadTexture = function (gltfRuntime, id, material, propertyPath, onError) {
120
+ // Create buffer from texture url
121
+ GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, function (buffer) {
122
+ // Create texture from buffer
123
+ GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, function (texture) { return (material[propertyPath] = texture); });
124
+ }, onError);
125
+ };
126
+ return GLTFMaterialsCommonExtension;
127
+ }(GLTFLoaderExtension));
128
+ export { GLTFMaterialsCommonExtension };
129
+ GLTFLoader.RegisterExtension(new GLTFMaterialsCommonExtension());
130
130
  //# sourceMappingURL=glTFMaterialsCommonExtension.js.map
@@ -1,5 +1,5 @@
1
- export * from "./glTFBinaryExtension";
2
- export * from "./glTFLoader";
3
- export * from "./glTFLoaderInterfaces";
4
- export * from "./glTFLoaderUtils";
5
- export * from "./glTFMaterialsCommonExtension";
1
+ export * from "./glTFBinaryExtension";
2
+ export * from "./glTFLoader";
3
+ export * from "./glTFLoaderInterfaces";
4
+ export * from "./glTFLoaderUtils";
5
+ export * from "./glTFMaterialsCommonExtension";
package/glTF/1.0/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export * from "./glTFBinaryExtension.js";
2
- export * from "./glTFLoader.js";
3
- export * from "./glTFLoaderInterfaces.js";
4
- export * from "./glTFLoaderUtils.js";
5
- export * from "./glTFMaterialsCommonExtension.js";
1
+ export * from "./glTFBinaryExtension";
2
+ export * from "./glTFLoader";
3
+ export * from "./glTFLoaderInterfaces";
4
+ export * from "./glTFLoaderUtils";
5
+ export * from "./glTFMaterialsCommonExtension";
6
6
  //# sourceMappingURL=index.js.map
@@ -1,43 +1,43 @@
1
- import { Nullable } from "@babylonjs/core/types.js";
2
- import { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
3
- import { IScene } from "../glTFLoaderInterfaces";
4
- import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
5
- import { GLTFLoader } from "../glTFLoader";
6
- declare module "babylonjs-gltf2interface" {
7
- /** @hidden */
8
- interface IEXTLightsImageBased_LightImageBased {
9
- _babylonTexture?: BaseTexture;
10
- _loaded?: Promise<void>;
11
- }
12
- }
13
- /**
14
- * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
15
- */
16
- export declare class EXT_lights_image_based implements IGLTFLoaderExtension {
17
- /**
18
- * The name of this extension.
19
- */
20
- readonly name = "EXT_lights_image_based";
21
- /**
22
- * Defines whether this extension is enabled.
23
- */
24
- enabled: boolean;
25
- private _loader;
26
- private _lights?;
27
- /**
28
- * @param loader
29
- * @hidden
30
- */
31
- constructor(loader: GLTFLoader);
32
- /** @hidden */
33
- dispose(): void;
34
- /** @hidden */
35
- onLoading(): void;
36
- /**
37
- * @param context
38
- * @param scene
39
- * @hidden
40
- */
41
- loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
42
- private _loadLightAsync;
43
- }
1
+ import { Nullable } from "@babylonjs/core/types.js";
2
+ import { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
3
+ import { IScene } from "../glTFLoaderInterfaces";
4
+ import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
5
+ import { GLTFLoader } from "../glTFLoader";
6
+ declare module "babylonjs-gltf2interface" {
7
+ /** @hidden */
8
+ interface IEXTLightsImageBased_LightImageBased {
9
+ _babylonTexture?: BaseTexture;
10
+ _loaded?: Promise<void>;
11
+ }
12
+ }
13
+ /**
14
+ * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
15
+ */
16
+ export declare class EXT_lights_image_based implements IGLTFLoaderExtension {
17
+ /**
18
+ * The name of this extension.
19
+ */
20
+ readonly name = "EXT_lights_image_based";
21
+ /**
22
+ * Defines whether this extension is enabled.
23
+ */
24
+ enabled: boolean;
25
+ private _loader;
26
+ private _lights?;
27
+ /**
28
+ * @param loader
29
+ * @hidden
30
+ */
31
+ constructor(loader: GLTFLoader);
32
+ /** @hidden */
33
+ dispose(): void;
34
+ /** @hidden */
35
+ onLoading(): void;
36
+ /**
37
+ * @param context
38
+ * @param scene
39
+ * @hidden
40
+ */
41
+ loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
42
+ private _loadLightAsync;
43
+ }
@@ -1,118 +1,118 @@
1
- import { Scalar } from "@babylonjs/core/Maths/math.scalar.js";
2
- import { SphericalHarmonics, SphericalPolynomial } from "@babylonjs/core/Maths/sphericalPolynomial.js";
3
- import { Quaternion, Matrix } from "@babylonjs/core/Maths/math.vector.js";
4
- import { RawCubeTexture } from "@babylonjs/core/Materials/Textures/rawCubeTexture.js";
5
- import { GLTFLoader, ArrayItem } from "../glTFLoader.js";
6
- var NAME = "EXT_lights_image_based";
7
- /**
8
- * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
9
- */
10
- var EXT_lights_image_based = /** @class */ (function () {
11
- /**
12
- * @param loader
13
- * @hidden
14
- */
15
- function EXT_lights_image_based(loader) {
16
- /**
17
- * The name of this extension.
18
- */
19
- this.name = NAME;
20
- this._loader = loader;
21
- this.enabled = this._loader.isExtensionUsed(NAME);
22
- }
23
- /** @hidden */
24
- EXT_lights_image_based.prototype.dispose = function () {
25
- this._loader = null;
26
- delete this._lights;
27
- };
28
- /** @hidden */
29
- EXT_lights_image_based.prototype.onLoading = function () {
30
- var extensions = this._loader.gltf.extensions;
31
- if (extensions && extensions[this.name]) {
32
- var extension = extensions[this.name];
33
- this._lights = extension.lights;
34
- }
35
- };
36
- /**
37
- * @param context
38
- * @param scene
39
- * @hidden
40
- */
41
- EXT_lights_image_based.prototype.loadSceneAsync = function (context, scene) {
42
- var _this = this;
43
- return GLTFLoader.LoadExtensionAsync(context, scene, this.name, function (extensionContext, extension) {
44
- var promises = new Array();
45
- promises.push(_this._loader.loadSceneAsync(context, scene));
46
- _this._loader.logOpen("".concat(extensionContext));
47
- var light = ArrayItem.Get("".concat(extensionContext, "/light"), _this._lights, extension.light);
48
- promises.push(_this._loadLightAsync("/extensions/".concat(_this.name, "/lights/").concat(extension.light), light).then(function (texture) {
49
- _this._loader.babylonScene.environmentTexture = texture;
50
- }));
51
- _this._loader.logClose();
52
- return Promise.all(promises).then(function () { });
53
- });
54
- };
55
- EXT_lights_image_based.prototype._loadLightAsync = function (context, light) {
56
- var _this = this;
57
- if (!light._loaded) {
58
- var promises = new Array();
59
- this._loader.logOpen("".concat(context));
60
- var imageData_1 = new Array(light.specularImages.length);
61
- var _loop_1 = function (mipmap) {
62
- var faces = light.specularImages[mipmap];
63
- imageData_1[mipmap] = new Array(faces.length);
64
- var _loop_2 = function (face) {
65
- var specularImageContext = "".concat(context, "/specularImages/").concat(mipmap, "/").concat(face);
66
- this_1._loader.logOpen("".concat(specularImageContext));
67
- var index = faces[face];
68
- var image = ArrayItem.Get(specularImageContext, this_1._loader.gltf.images, index);
69
- promises.push(this_1._loader.loadImageAsync("/images/".concat(index), image).then(function (data) {
70
- imageData_1[mipmap][face] = data;
71
- }));
72
- this_1._loader.logClose();
73
- };
74
- for (var face = 0; face < faces.length; face++) {
75
- _loop_2(face);
76
- }
77
- };
78
- var this_1 = this;
79
- for (var mipmap = 0; mipmap < light.specularImages.length; mipmap++) {
80
- _loop_1(mipmap);
81
- }
82
- this._loader.logClose();
83
- light._loaded = Promise.all(promises).then(function () {
84
- var babylonTexture = new RawCubeTexture(_this._loader.babylonScene, null, light.specularImageSize);
85
- babylonTexture.name = light.name || "environment";
86
- light._babylonTexture = babylonTexture;
87
- if (light.intensity != undefined) {
88
- babylonTexture.level = light.intensity;
89
- }
90
- if (light.rotation) {
91
- var rotation = Quaternion.FromArray(light.rotation);
92
- // Invert the rotation so that positive rotation is counter-clockwise.
93
- if (!_this._loader.babylonScene.useRightHandedSystem) {
94
- rotation = Quaternion.Inverse(rotation);
95
- }
96
- Matrix.FromQuaternionToRef(rotation, babylonTexture.getReflectionTextureMatrix());
97
- }
98
- if (!light.irradianceCoefficients) {
99
- throw new Error("".concat(context, ": Irradiance coefficients are missing"));
100
- }
101
- var sphericalHarmonics = SphericalHarmonics.FromArray(light.irradianceCoefficients);
102
- sphericalHarmonics.scaleInPlace(light.intensity);
103
- sphericalHarmonics.convertIrradianceToLambertianRadiance();
104
- var sphericalPolynomial = SphericalPolynomial.FromHarmonics(sphericalHarmonics);
105
- // Compute the lod generation scale to fit exactly to the number of levels available.
106
- var lodGenerationScale = (imageData_1.length - 1) / Scalar.Log2(light.specularImageSize);
107
- return babylonTexture.updateRGBDAsync(imageData_1, sphericalPolynomial, lodGenerationScale);
108
- });
109
- }
110
- return light._loaded.then(function () {
111
- return light._babylonTexture;
112
- });
113
- };
114
- return EXT_lights_image_based;
115
- }());
116
- export { EXT_lights_image_based };
117
- GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_lights_image_based(loader); });
1
+ import { Scalar } from "@babylonjs/core/Maths/math.scalar.js";
2
+ import { SphericalHarmonics, SphericalPolynomial } from "@babylonjs/core/Maths/sphericalPolynomial.js";
3
+ import { Quaternion, Matrix } from "@babylonjs/core/Maths/math.vector.js";
4
+ import { RawCubeTexture } from "@babylonjs/core/Materials/Textures/rawCubeTexture.js";
5
+ import { GLTFLoader, ArrayItem } from "../glTFLoader";
6
+ var NAME = "EXT_lights_image_based";
7
+ /**
8
+ * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
9
+ */
10
+ var EXT_lights_image_based = /** @class */ (function () {
11
+ /**
12
+ * @param loader
13
+ * @hidden
14
+ */
15
+ function EXT_lights_image_based(loader) {
16
+ /**
17
+ * The name of this extension.
18
+ */
19
+ this.name = NAME;
20
+ this._loader = loader;
21
+ this.enabled = this._loader.isExtensionUsed(NAME);
22
+ }
23
+ /** @hidden */
24
+ EXT_lights_image_based.prototype.dispose = function () {
25
+ this._loader = null;
26
+ delete this._lights;
27
+ };
28
+ /** @hidden */
29
+ EXT_lights_image_based.prototype.onLoading = function () {
30
+ var extensions = this._loader.gltf.extensions;
31
+ if (extensions && extensions[this.name]) {
32
+ var extension = extensions[this.name];
33
+ this._lights = extension.lights;
34
+ }
35
+ };
36
+ /**
37
+ * @param context
38
+ * @param scene
39
+ * @hidden
40
+ */
41
+ EXT_lights_image_based.prototype.loadSceneAsync = function (context, scene) {
42
+ var _this = this;
43
+ return GLTFLoader.LoadExtensionAsync(context, scene, this.name, function (extensionContext, extension) {
44
+ var promises = new Array();
45
+ promises.push(_this._loader.loadSceneAsync(context, scene));
46
+ _this._loader.logOpen("".concat(extensionContext));
47
+ var light = ArrayItem.Get("".concat(extensionContext, "/light"), _this._lights, extension.light);
48
+ promises.push(_this._loadLightAsync("/extensions/".concat(_this.name, "/lights/").concat(extension.light), light).then(function (texture) {
49
+ _this._loader.babylonScene.environmentTexture = texture;
50
+ }));
51
+ _this._loader.logClose();
52
+ return Promise.all(promises).then(function () { });
53
+ });
54
+ };
55
+ EXT_lights_image_based.prototype._loadLightAsync = function (context, light) {
56
+ var _this = this;
57
+ if (!light._loaded) {
58
+ var promises = new Array();
59
+ this._loader.logOpen("".concat(context));
60
+ var imageData_1 = new Array(light.specularImages.length);
61
+ var _loop_1 = function (mipmap) {
62
+ var faces = light.specularImages[mipmap];
63
+ imageData_1[mipmap] = new Array(faces.length);
64
+ var _loop_2 = function (face) {
65
+ var specularImageContext = "".concat(context, "/specularImages/").concat(mipmap, "/").concat(face);
66
+ this_1._loader.logOpen("".concat(specularImageContext));
67
+ var index = faces[face];
68
+ var image = ArrayItem.Get(specularImageContext, this_1._loader.gltf.images, index);
69
+ promises.push(this_1._loader.loadImageAsync("/images/".concat(index), image).then(function (data) {
70
+ imageData_1[mipmap][face] = data;
71
+ }));
72
+ this_1._loader.logClose();
73
+ };
74
+ for (var face = 0; face < faces.length; face++) {
75
+ _loop_2(face);
76
+ }
77
+ };
78
+ var this_1 = this;
79
+ for (var mipmap = 0; mipmap < light.specularImages.length; mipmap++) {
80
+ _loop_1(mipmap);
81
+ }
82
+ this._loader.logClose();
83
+ light._loaded = Promise.all(promises).then(function () {
84
+ var babylonTexture = new RawCubeTexture(_this._loader.babylonScene, null, light.specularImageSize);
85
+ babylonTexture.name = light.name || "environment";
86
+ light._babylonTexture = babylonTexture;
87
+ if (light.intensity != undefined) {
88
+ babylonTexture.level = light.intensity;
89
+ }
90
+ if (light.rotation) {
91
+ var rotation = Quaternion.FromArray(light.rotation);
92
+ // Invert the rotation so that positive rotation is counter-clockwise.
93
+ if (!_this._loader.babylonScene.useRightHandedSystem) {
94
+ rotation = Quaternion.Inverse(rotation);
95
+ }
96
+ Matrix.FromQuaternionToRef(rotation, babylonTexture.getReflectionTextureMatrix());
97
+ }
98
+ if (!light.irradianceCoefficients) {
99
+ throw new Error("".concat(context, ": Irradiance coefficients are missing"));
100
+ }
101
+ var sphericalHarmonics = SphericalHarmonics.FromArray(light.irradianceCoefficients);
102
+ sphericalHarmonics.scaleInPlace(light.intensity);
103
+ sphericalHarmonics.convertIrradianceToLambertianRadiance();
104
+ var sphericalPolynomial = SphericalPolynomial.FromHarmonics(sphericalHarmonics);
105
+ // Compute the lod generation scale to fit exactly to the number of levels available.
106
+ var lodGenerationScale = (imageData_1.length - 1) / Scalar.Log2(light.specularImageSize);
107
+ return babylonTexture.updateRGBDAsync(imageData_1, sphericalPolynomial, lodGenerationScale);
108
+ });
109
+ }
110
+ return light._loaded.then(function () {
111
+ return light._babylonTexture;
112
+ });
113
+ };
114
+ return EXT_lights_image_based;
115
+ }());
116
+ export { EXT_lights_image_based };
117
+ GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_lights_image_based(loader); });
118
118
  //# sourceMappingURL=EXT_lights_image_based.js.map