@babylonjs/loaders 5.0.0-rc.1 → 5.0.0-rc.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. package/OBJ/index.d.ts +4 -4
  2. package/OBJ/index.js +4 -4
  3. package/OBJ/index.js.map +1 -1
  4. package/OBJ/mtlFileLoader.d.ts +41 -40
  5. package/OBJ/mtlFileLoader.js +232 -231
  6. package/OBJ/mtlFileLoader.js.map +1 -1
  7. package/OBJ/objFileLoader.d.ts +126 -133
  8. package/OBJ/objFileLoader.js +296 -300
  9. package/OBJ/objFileLoader.js.map +1 -1
  10. package/OBJ/objLoadingOptions.d.ts +43 -43
  11. package/OBJ/objLoadingOptions.js +1 -1
  12. package/OBJ/objLoadingOptions.js.map +1 -1
  13. package/OBJ/solidParser.d.ts +154 -153
  14. package/OBJ/solidParser.js +693 -699
  15. package/OBJ/solidParser.js.map +1 -1
  16. package/STL/index.d.ts +1 -1
  17. package/STL/index.js +1 -1
  18. package/STL/index.js.map +1 -1
  19. package/STL/stlFileLoader.d.ts +64 -71
  20. package/STL/stlFileLoader.js +233 -239
  21. package/STL/stlFileLoader.js.map +1 -1
  22. package/glTF/1.0/glTFBinaryExtension.d.ts +13 -13
  23. package/glTF/1.0/glTFBinaryExtension.js +60 -61
  24. package/glTF/1.0/glTFBinaryExtension.js.map +1 -1
  25. package/glTF/1.0/glTFLoader.d.ts +136 -106
  26. package/glTF/1.0/glTFLoader.js +1814 -1696
  27. package/glTF/1.0/glTFLoader.js.map +1 -1
  28. package/glTF/1.0/glTFLoaderInterfaces.d.ts +412 -412
  29. package/glTF/1.0/glTFLoaderInterfaces.js +95 -95
  30. package/glTF/1.0/glTFLoaderInterfaces.js.map +1 -1
  31. package/glTF/1.0/glTFLoaderUtils.d.ts +63 -62
  32. package/glTF/1.0/glTFLoaderUtils.js +250 -232
  33. package/glTF/1.0/glTFLoaderUtils.js.map +1 -1
  34. package/glTF/1.0/glTFMaterialsCommonExtension.d.ts +10 -10
  35. package/glTF/1.0/glTFMaterialsCommonExtension.js +129 -127
  36. package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -1
  37. package/glTF/1.0/index.d.ts +5 -5
  38. package/glTF/1.0/index.js +5 -5
  39. package/glTF/1.0/index.js.map +1 -1
  40. package/glTF/2.0/Extensions/EXT_lights_image_based.d.ts +43 -36
  41. package/glTF/2.0/Extensions/EXT_lights_image_based.js +117 -110
  42. package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
  43. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +36 -28
  44. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +88 -80
  45. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
  46. package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +34 -27
  47. package/glTF/2.0/Extensions/EXT_meshopt_compression.js +49 -42
  48. package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
  49. package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +29 -21
  50. package/glTF/2.0/Extensions/EXT_texture_webp.js +40 -32
  51. package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
  52. package/glTF/2.0/Extensions/ExtrasAsMetadata.d.ts +50 -32
  53. package/glTF/2.0/Extensions/ExtrasAsMetadata.js +73 -55
  54. package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -1
  55. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +39 -31
  56. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +112 -101
  57. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
  58. package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +36 -28
  59. package/glTF/2.0/Extensions/KHR_lights_punctual.js +89 -81
  60. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
  61. package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +39 -31
  62. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +94 -86
  63. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
  64. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +38 -30
  65. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +53 -45
  66. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
  67. package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +42 -34
  68. package/glTF/2.0/Extensions/KHR_materials_ior.js +62 -54
  69. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
  70. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.d.ts +38 -30
  71. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +80 -72
  72. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
  73. package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +39 -31
  74. package/glTF/2.0/Extensions/KHR_materials_sheen.js +84 -76
  75. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
  76. package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +38 -30
  77. package/glTF/2.0/Extensions/KHR_materials_specular.js +74 -66
  78. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
  79. package/glTF/2.0/Extensions/KHR_materials_translucency.d.ts +39 -31
  80. package/glTF/2.0/Extensions/KHR_materials_translucency.js +83 -76
  81. package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
  82. package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +38 -30
  83. package/glTF/2.0/Extensions/KHR_materials_transmission.js +288 -277
  84. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  85. package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +38 -30
  86. package/glTF/2.0/Extensions/KHR_materials_unlit.js +73 -65
  87. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
  88. package/glTF/2.0/Extensions/KHR_materials_variants.d.ts +87 -76
  89. package/glTF/2.0/Extensions/KHR_materials_variants.js +254 -243
  90. package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
  91. package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +39 -31
  92. package/glTF/2.0/Extensions/KHR_materials_volume.js +85 -78
  93. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
  94. package/glTF/2.0/Extensions/KHR_mesh_quantization.d.ts +22 -19
  95. package/glTF/2.0/Extensions/KHR_mesh_quantization.js +23 -21
  96. package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +1 -1
  97. package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +29 -21
  98. package/glTF/2.0/Extensions/KHR_texture_basisu.js +40 -32
  99. package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
  100. package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +33 -25
  101. package/glTF/2.0/Extensions/KHR_texture_transform.js +61 -53
  102. package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
  103. package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +32 -29
  104. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +49 -46
  105. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
  106. package/glTF/2.0/Extensions/MSFT_audio_emitter.d.ts +54 -38
  107. package/glTF/2.0/Extensions/MSFT_audio_emitter.js +240 -216
  108. package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
  109. package/glTF/2.0/Extensions/MSFT_lod.d.ts +109 -75
  110. package/glTF/2.0/Extensions/MSFT_lod.js +369 -333
  111. package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
  112. package/glTF/2.0/Extensions/MSFT_minecraftMesh.d.ts +14 -14
  113. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +36 -36
  114. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
  115. package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +14 -14
  116. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +36 -36
  117. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
  118. package/glTF/2.0/Extensions/index.d.ts +26 -26
  119. package/glTF/2.0/Extensions/index.js +26 -26
  120. package/glTF/2.0/Extensions/index.js.map +1 -1
  121. package/glTF/2.0/glTFLoader.d.ts +406 -357
  122. package/glTF/2.0/glTFLoader.js +2366 -2266
  123. package/glTF/2.0/glTFLoader.js.map +1 -1
  124. package/glTF/2.0/glTFLoaderExtension.d.ts +152 -152
  125. package/glTF/2.0/glTFLoaderExtension.js +1 -1
  126. package/glTF/2.0/glTFLoaderExtension.js.map +1 -1
  127. package/glTF/2.0/glTFLoaderInterfaces.d.ts +211 -209
  128. package/glTF/2.0/glTFLoaderInterfaces.js +1 -1
  129. package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
  130. package/glTF/2.0/index.d.ts +4 -4
  131. package/glTF/2.0/index.js +5 -4
  132. package/glTF/2.0/index.js.map +1 -1
  133. package/glTF/glTFFileLoader.d.ts +433 -373
  134. package/glTF/glTFFileLoader.js +927 -870
  135. package/glTF/glTFFileLoader.js.map +1 -1
  136. package/glTF/glTFValidation.d.ts +29 -29
  137. package/glTF/glTFValidation.js +123 -121
  138. package/glTF/glTFValidation.js.map +1 -1
  139. package/glTF/index.d.ts +5 -5
  140. package/glTF/index.js +6 -5
  141. package/glTF/index.js.map +1 -1
  142. package/index.d.ts +3 -3
  143. package/index.js +4 -3
  144. package/index.js.map +1 -1
  145. package/legacy/legacy-glTF.d.ts +2 -2
  146. package/legacy/legacy-glTF.js +18 -18
  147. package/legacy/legacy-glTF.js.map +1 -1
  148. package/legacy/legacy-glTF1.d.ts +2 -2
  149. package/legacy/legacy-glTF1.js +15 -14
  150. package/legacy/legacy-glTF1.js.map +1 -1
  151. package/legacy/legacy-glTF1FileLoader.d.ts +2 -2
  152. package/legacy/legacy-glTF1FileLoader.js +3 -2
  153. package/legacy/legacy-glTF1FileLoader.js.map +1 -1
  154. package/legacy/legacy-glTF2.d.ts +2 -2
  155. package/legacy/legacy-glTF2.js +33 -32
  156. package/legacy/legacy-glTF2.js.map +1 -1
  157. package/legacy/legacy-glTF2FileLoader.d.ts +2 -2
  158. package/legacy/legacy-glTF2FileLoader.js +3 -2
  159. package/legacy/legacy-glTF2FileLoader.js.map +1 -1
  160. package/legacy/legacy-glTFFileLoader.d.ts +3 -3
  161. package/legacy/legacy-glTFFileLoader.js +4 -3
  162. package/legacy/legacy-glTFFileLoader.js.map +1 -1
  163. package/legacy/legacy-objFileLoader.d.ts +1 -1
  164. package/legacy/legacy-objFileLoader.js +13 -12
  165. package/legacy/legacy-objFileLoader.js.map +1 -1
  166. package/legacy/legacy-stlFileLoader.d.ts +1 -1
  167. package/legacy/legacy-stlFileLoader.js +13 -12
  168. package/legacy/legacy-stlFileLoader.js.map +1 -1
  169. package/legacy/legacy.d.ts +6 -6
  170. package/legacy/legacy.js +8 -6
  171. package/legacy/legacy.js.map +1 -1
  172. package/license.md +71 -0
  173. package/package.json +37 -193
  174. package/readme.md +2 -2
@@ -1,128 +1,130 @@
1
- import { __extends } from "tslib";
2
- import { GLTFLoaderExtension } from "./glTFLoader.js";
3
- import { GLTFLoaderBase } from "./glTFLoader.js";
4
- import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
5
- import { Color3 } from '@babylonjs/core/Maths/math.color.js';
6
- import { Tools } from "@babylonjs/core/Misc/tools.js";
7
- import { Material } from "@babylonjs/core/Materials/material.js";
8
- import { StandardMaterial } from "@babylonjs/core/Materials/standardMaterial.js";
9
- import { HemisphericLight } from "@babylonjs/core/Lights/hemisphericLight.js";
10
- import { DirectionalLight } from "@babylonjs/core/Lights/directionalLight.js";
11
- import { PointLight } from "@babylonjs/core/Lights/pointLight.js";
12
- import { SpotLight } from "@babylonjs/core/Lights/spotLight.js";
13
- import { GLTFLoader } from "./glTFLoader.js";
14
- /** @hidden */
15
- var GLTFMaterialsCommonExtension = /** @class */ (function (_super) {
16
- __extends(GLTFMaterialsCommonExtension, _super);
17
- function GLTFMaterialsCommonExtension() {
18
- return _super.call(this, "KHR_materials_common") || this;
19
- }
20
- GLTFMaterialsCommonExtension.prototype.loadRuntimeExtensionsAsync = function (gltfRuntime, onSuccess, onError) {
21
- if (!gltfRuntime.extensions) {
22
- return false;
23
- }
24
- var extension = gltfRuntime.extensions[this.name];
25
- if (!extension) {
26
- return false;
27
- }
28
- // Create lights
29
- var lights = extension.lights;
30
- if (lights) {
31
- for (var thing in lights) {
32
- var light = lights[thing];
33
- switch (light.type) {
34
- case "ambient":
35
- var ambientLight = new HemisphericLight(light.name, new Vector3(0, 1, 0), gltfRuntime.scene);
36
- var ambient = light.ambient;
37
- if (ambient) {
38
- ambientLight.diffuse = Color3.FromArray(ambient.color || [1, 1, 1]);
39
- }
40
- break;
41
- case "point":
42
- var pointLight = new PointLight(light.name, new Vector3(10, 10, 10), gltfRuntime.scene);
43
- var point = light.point;
44
- if (point) {
45
- pointLight.diffuse = Color3.FromArray(point.color || [1, 1, 1]);
46
- }
47
- break;
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
- case "spot":
56
- var spot = light.spot;
57
- if (spot) {
58
- 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);
59
- spotLight.diffuse = Color3.FromArray(spot.color || [1, 1, 1]);
60
- }
61
- break;
62
- default:
63
- Tools.Warn("GLTF Material Common extension: light type \"" + light.type + "\” not supported");
64
- break;
65
- }
66
- }
67
- }
68
- return false;
69
- };
70
- GLTFMaterialsCommonExtension.prototype.loadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
71
- var material = gltfRuntime.materials[id];
72
- if (!material || !material.extensions) {
73
- return false;
74
- }
75
- var extension = material.extensions[this.name];
76
- if (!extension) {
77
- return false;
78
- }
79
- var standardMaterial = new StandardMaterial(id, gltfRuntime.scene);
80
- standardMaterial.sideOrientation = Material.CounterClockWiseSideOrientation;
81
- if (extension.technique === "CONSTANT") {
82
- standardMaterial.disableLighting = true;
83
- }
84
- standardMaterial.backFaceCulling = extension.doubleSided === undefined ? false : !extension.doubleSided;
85
- standardMaterial.alpha = extension.values.transparency === undefined ? 1.0 : extension.values.transparency;
86
- standardMaterial.specularPower = extension.values.shininess === undefined ? 0.0 : extension.values.shininess;
87
- // Ambient
88
- if (typeof extension.values.ambient === "string") {
89
- this._loadTexture(gltfRuntime, extension.values.ambient, standardMaterial, "ambientTexture", onError);
90
- }
91
- else {
92
- standardMaterial.ambientColor = Color3.FromArray(extension.values.ambient || [0, 0, 0]);
93
- }
94
- // Diffuse
95
- if (typeof extension.values.diffuse === "string") {
96
- this._loadTexture(gltfRuntime, extension.values.diffuse, standardMaterial, "diffuseTexture", onError);
97
- }
98
- else {
99
- standardMaterial.diffuseColor = Color3.FromArray(extension.values.diffuse || [0, 0, 0]);
100
- }
101
- // Emission
102
- if (typeof extension.values.emission === "string") {
103
- this._loadTexture(gltfRuntime, extension.values.emission, standardMaterial, "emissiveTexture", onError);
104
- }
105
- else {
106
- standardMaterial.emissiveColor = Color3.FromArray(extension.values.emission || [0, 0, 0]);
107
- }
108
- // Specular
109
- if (typeof extension.values.specular === "string") {
110
- this._loadTexture(gltfRuntime, extension.values.specular, standardMaterial, "specularTexture", onError);
111
- }
112
- else {
113
- standardMaterial.specularColor = Color3.FromArray(extension.values.specular || [0, 0, 0]);
114
- }
115
- return true;
116
- };
117
- GLTFMaterialsCommonExtension.prototype._loadTexture = function (gltfRuntime, id, material, propertyPath, onError) {
118
- // Create buffer from texture url
119
- GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, function (buffer) {
120
- // Create texture from buffer
121
- GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, function (texture) { return material[propertyPath] = texture; }, onError);
122
- }, onError);
123
- };
124
- return GLTFMaterialsCommonExtension;
125
- }(GLTFLoaderExtension));
126
- export { GLTFMaterialsCommonExtension };
127
- 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());
128
130
  //# sourceMappingURL=glTFMaterialsCommonExtension.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"glTFMaterialsCommonExtension.js","sourceRoot":"","sources":["../../../../sourceES6/loaders/src/glTF/1.0/glTFMaterialsCommonExtension.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,cA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AAE,CAAC,CAAC","sourcesContent":["import { GLTFLoaderExtension } from \"./glTFLoader\";\nimport { GLTFLoaderBase } from \"./glTFLoader\";\n\nimport { IGLTFRuntime, IGLTFMaterial } from \"./glTFLoaderInterfaces\";\n\nimport { Vector3 } from \"@babylonjs/core/Maths/math.vector\";\nimport { Color3 } from '@babylonjs/core/Maths/math.color';\nimport { Tools } from \"@babylonjs/core/Misc/tools\";\nimport { Material } from \"@babylonjs/core/Materials/material\";\nimport { StandardMaterial } from \"@babylonjs/core/Materials/standardMaterial\";\nimport { HemisphericLight } from \"@babylonjs/core/Lights/hemisphericLight\";\nimport { DirectionalLight } from \"@babylonjs/core/Lights/directionalLight\";\nimport { PointLight } from \"@babylonjs/core/Lights/pointLight\";\nimport { SpotLight } from \"@babylonjs/core/Lights/spotLight\";\n\nimport { GLTFLoader } from \"./glTFLoader\";\n\ninterface IGLTFMaterialsCommonExtensionValues {\n ambient?: number[] | string;\n diffuse?: number[] | string;\n emission?: number[] | string;\n specular?: number[] | string;\n shininess?: number;\n transparency?: number;\n}\n\ninterface IGLTFMaterialsCommonExtension {\n technique: string;\n transparent?: number;\n doubleSided?: boolean;\n values: IGLTFMaterialsCommonExtensionValues;\n}\n\ninterface IGLTFRuntimeCommonExtension {\n lights: { [key: string]: IGLTFLightCommonExtension };\n}\n\ninterface IGLTFLightCommonExtension {\n name: string;\n type: string;\n\n ambient?: IGLTFAmbientLightCommonExtension;\n point?: IGLTFPointLightCommonExtension;\n directional?: IGLTFDirectionalLightCommonExtension;\n spot?: IGLTFSpotLightCommonExtension;\n}\n\ninterface IGLTFPointLightCommonExtension {\n color: number[];\n constantAttenuation: number;\n linearAttenuation: number;\n quadraticAttenuation: number;\n}\n\ninterface IGLTFAmbientLightCommonExtension {\n color: number[];\n}\n\ninterface IGLTFDirectionalLightCommonExtension {\n color: number[];\n}\n\ninterface IGLTFSpotLightCommonExtension {\n color: number[];\n constantAttenuation: number;\n fallOffAngle: number;\n fallOffExponent: number;\n linearAttenuation: number;\n quadraticAttenuation: number;\n}\n\n/** @hidden */\nexport class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {\n\n constructor() {\n super(\"KHR_materials_common\");\n }\n\n public loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean {\n if (!gltfRuntime.extensions) { return false; }\n\n var extension: IGLTFRuntimeCommonExtension = gltfRuntime.extensions[this.name];\n if (!extension) { return false; }\n\n // Create lights\n var lights = extension.lights;\n if (lights) {\n for (var thing in lights) {\n var light: IGLTFLightCommonExtension = lights[thing];\n\n switch (light.type) {\n case \"ambient\":\n var ambientLight = new HemisphericLight(light.name, new Vector3(0, 1, 0), gltfRuntime.scene);\n var ambient = light.ambient;\n if (ambient) {\n ambientLight.diffuse = Color3.FromArray(ambient.color || [1, 1, 1]);\n }\n break;\n case \"point\":\n var pointLight = new PointLight(light.name, new Vector3(10, 10, 10), gltfRuntime.scene);\n var point = light.point;\n if (point) {\n pointLight.diffuse = Color3.FromArray(point.color || [1, 1, 1]);\n }\n break;\n case \"directional\":\n var dirLight = new DirectionalLight(light.name, new Vector3(0, -1, 0), gltfRuntime.scene);\n var directional = light.directional;\n if (directional) {\n dirLight.diffuse = Color3.FromArray(directional.color || [1, 1, 1]);\n }\n break;\n case \"spot\":\n var spot = light.spot;\n if (spot) {\n var spotLight = new SpotLight(light.name, new Vector3(0, 10, 0), new Vector3(0, -1, 0),\n spot.fallOffAngle || Math.PI,\n spot.fallOffExponent || 0.0,\n gltfRuntime.scene);\n spotLight.diffuse = Color3.FromArray(spot.color || [1, 1, 1]);\n }\n break;\n default: Tools.Warn(\"GLTF Material Common extension: light type \\\"\" + light.type + \"\\” not supported\"); break;\n }\n }\n }\n\n return false;\n }\n\n public loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean {\n var material: IGLTFMaterial = gltfRuntime.materials[id];\n if (!material || !material.extensions) { return false; }\n\n var extension: IGLTFMaterialsCommonExtension = material.extensions[this.name];\n if (!extension) { return false; }\n\n var standardMaterial = new StandardMaterial(id, gltfRuntime.scene);\n standardMaterial.sideOrientation = Material.CounterClockWiseSideOrientation;\n\n if (extension.technique === \"CONSTANT\") {\n standardMaterial.disableLighting = true;\n }\n\n standardMaterial.backFaceCulling = extension.doubleSided === undefined ? false : !extension.doubleSided;\n standardMaterial.alpha = extension.values.transparency === undefined ? 1.0 : extension.values.transparency;\n standardMaterial.specularPower = extension.values.shininess === undefined ? 0.0 : extension.values.shininess;\n\n // Ambient\n if (typeof extension.values.ambient === \"string\") {\n this._loadTexture(gltfRuntime, extension.values.ambient, standardMaterial, \"ambientTexture\", onError);\n }\n else {\n standardMaterial.ambientColor = Color3.FromArray(extension.values.ambient || [0, 0, 0]);\n }\n\n // Diffuse\n if (typeof extension.values.diffuse === \"string\") {\n this._loadTexture(gltfRuntime, extension.values.diffuse, standardMaterial, \"diffuseTexture\", onError);\n }\n else {\n standardMaterial.diffuseColor = Color3.FromArray(extension.values.diffuse || [0, 0, 0]);\n }\n\n // Emission\n if (typeof extension.values.emission === \"string\") {\n this._loadTexture(gltfRuntime, extension.values.emission, standardMaterial, \"emissiveTexture\", onError);\n }\n else {\n standardMaterial.emissiveColor = Color3.FromArray(extension.values.emission || [0, 0, 0]);\n }\n\n // Specular\n if (typeof extension.values.specular === \"string\") {\n this._loadTexture(gltfRuntime, extension.values.specular, standardMaterial, \"specularTexture\", onError);\n }\n else {\n standardMaterial.specularColor = Color3.FromArray(extension.values.specular || [0, 0, 0]);\n }\n\n return true;\n }\n\n private _loadTexture(gltfRuntime: IGLTFRuntime, id: string, material: StandardMaterial, propertyPath: string, onError: (message: string) => void): void {\n // Create buffer from texture url\n GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, (buffer) => {\n // Create texture from buffer\n GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, (texture) => (<any>material)[propertyPath] = texture, onError);\n }, onError);\n }\n}\n\nGLTFLoader.RegisterExtension(new GLTFMaterialsCommonExtension());\n"]}
1
+ {"version":3,"file":"glTFMaterialsCommonExtension.js","sourceRoot":"","sources":["../../../../../../lts/loaders/generated/glTF/1.0/glTFMaterialsCommonExtension.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/E,OAAO,EAAE,OAAO,EAAE,6CAA+B;AACjD,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAC/C,OAAO,EAAE,KAAK,EAAE,sCAAwB;AACxC,OAAO,EAAE,QAAQ,EAAE,8CAAgC;AACnD,OAAO,EAAE,gBAAgB,EAAE,sDAAwC;AACnE,OAAO,EAAE,gBAAgB,EAAE,mDAAqC;AAChE,OAAO,EAAE,gBAAgB,EAAE,mDAAqC;AAChE,OAAO,EAAE,UAAU,EAAE,6CAA+B;AACpD,OAAO,EAAE,SAAS,EAAE,4CAA8B;AAwDlD,cAAc;AACd;IAAkD,gDAAmB;IACjE;eACI,kBAAM,sBAAsB,CAAC;IACjC,CAAC;IAEM,iEAA0B,GAAjC,UAAkC,WAAyB;QACvD,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE;YACzB,OAAO,KAAK,CAAC;SAChB;QAED,IAAM,SAAS,GAAgC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjF,IAAI,CAAC,SAAS,EAAE;YACZ,OAAO,KAAK,CAAC;SAChB;QAED,gBAAgB;QAChB,IAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;QAChC,IAAI,MAAM,EAAE;YACR,KAAK,IAAM,KAAK,IAAI,MAAM,EAAE;gBACxB,IAAM,KAAK,GAA8B,MAAM,CAAC,KAAK,CAAC,CAAC;gBAEvD,QAAQ,KAAK,CAAC,IAAI,EAAE;oBAChB,KAAK,SAAS,CAAC,CAAC;wBACZ,IAAM,YAAY,GAAG,IAAI,gBAAgB,CAAC,KAAK,CAAC,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xID,CAAkD,mBAAmB,GAwIpE;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,4BAA4B,EAAE,CAAC,CAAC","sourcesContent":["import { GLTFLoaderExtension, GLTFLoaderBase, GLTFLoader } from \"./glTFLoader\";\r\n\r\nimport type { IGLTFRuntime, IGLTFMaterial } from \"./glTFLoaderInterfaces\";\r\n\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { Material } from \"core/Materials/material\";\r\nimport { StandardMaterial } from \"core/Materials/standardMaterial\";\r\nimport { HemisphericLight } from \"core/Lights/hemisphericLight\";\r\nimport { DirectionalLight } from \"core/Lights/directionalLight\";\r\nimport { PointLight } from \"core/Lights/pointLight\";\r\nimport { SpotLight } from \"core/Lights/spotLight\";\r\n\r\ninterface IGLTFMaterialsCommonExtensionValues {\r\n ambient?: number[] | string;\r\n diffuse?: number[] | string;\r\n emission?: number[] | string;\r\n specular?: number[] | string;\r\n shininess?: number;\r\n transparency?: number;\r\n}\r\n\r\ninterface IGLTFMaterialsCommonExtension {\r\n technique: string;\r\n transparent?: number;\r\n doubleSided?: boolean;\r\n values: IGLTFMaterialsCommonExtensionValues;\r\n}\r\n\r\ninterface IGLTFRuntimeCommonExtension {\r\n lights: { [key: string]: IGLTFLightCommonExtension };\r\n}\r\n\r\ninterface IGLTFLightCommonExtension {\r\n name: string;\r\n type: string;\r\n\r\n ambient?: IGLTFAmbientLightCommonExtension;\r\n point?: IGLTFPointLightCommonExtension;\r\n directional?: IGLTFDirectionalLightCommonExtension;\r\n spot?: IGLTFSpotLightCommonExtension;\r\n}\r\n\r\ninterface IGLTFPointLightCommonExtension {\r\n color: number[];\r\n constantAttenuation: number;\r\n linearAttenuation: number;\r\n quadraticAttenuation: number;\r\n}\r\n\r\ninterface IGLTFAmbientLightCommonExtension {\r\n color: number[];\r\n}\r\n\r\ninterface IGLTFDirectionalLightCommonExtension {\r\n color: number[];\r\n}\r\n\r\ninterface IGLTFSpotLightCommonExtension {\r\n color: number[];\r\n constantAttenuation: number;\r\n fallOffAngle: number;\r\n fallOffExponent: number;\r\n linearAttenuation: number;\r\n quadraticAttenuation: number;\r\n}\r\n\r\n/** @hidden */\r\nexport class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {\r\n constructor() {\r\n super(\"KHR_materials_common\");\r\n }\r\n\r\n public loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime): boolean {\r\n if (!gltfRuntime.extensions) {\r\n return false;\r\n }\r\n\r\n const extension: IGLTFRuntimeCommonExtension = gltfRuntime.extensions[this.name];\r\n if (!extension) {\r\n return false;\r\n }\r\n\r\n // Create lights\r\n const lights = extension.lights;\r\n if (lights) {\r\n for (const thing in lights) {\r\n const light: IGLTFLightCommonExtension = lights[thing];\r\n\r\n switch (light.type) {\r\n case \"ambient\": {\r\n const ambientLight = new HemisphericLight(light.name, new Vector3(0, 1, 0), gltfRuntime.scene);\r\n const ambient = light.ambient;\r\n if (ambient) {\r\n ambientLight.diffuse = Color3.FromArray(ambient.color || [1, 1, 1]);\r\n }\r\n break;\r\n }\r\n case \"point\": {\r\n const pointLight = new PointLight(light.name, new Vector3(10, 10, 10), gltfRuntime.scene);\r\n const point = light.point;\r\n if (point) {\r\n pointLight.diffuse = Color3.FromArray(point.color || [1, 1, 1]);\r\n }\r\n break;\r\n }\r\n case \"directional\": {\r\n const dirLight = new DirectionalLight(light.name, new Vector3(0, -1, 0), gltfRuntime.scene);\r\n const directional = light.directional;\r\n if (directional) {\r\n dirLight.diffuse = Color3.FromArray(directional.color || [1, 1, 1]);\r\n }\r\n break;\r\n }\r\n case \"spot\": {\r\n const spot = light.spot;\r\n if (spot) {\r\n const spotLight = new SpotLight(\r\n light.name,\r\n new Vector3(0, 10, 0),\r\n new Vector3(0, -1, 0),\r\n spot.fallOffAngle || Math.PI,\r\n spot.fallOffExponent || 0.0,\r\n gltfRuntime.scene\r\n );\r\n spotLight.diffuse = Color3.FromArray(spot.color || [1, 1, 1]);\r\n }\r\n break;\r\n }\r\n default:\r\n Tools.Warn('GLTF Material Common extension: light type \"' + light.type + \"” not supported\");\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n public loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean {\r\n const material: IGLTFMaterial = gltfRuntime.materials[id];\r\n if (!material || !material.extensions) {\r\n return false;\r\n }\r\n\r\n const extension: IGLTFMaterialsCommonExtension = material.extensions[this.name];\r\n if (!extension) {\r\n return false;\r\n }\r\n\r\n const standardMaterial = new StandardMaterial(id, gltfRuntime.scene);\r\n standardMaterial.sideOrientation = Material.CounterClockWiseSideOrientation;\r\n\r\n if (extension.technique === \"CONSTANT\") {\r\n standardMaterial.disableLighting = true;\r\n }\r\n\r\n standardMaterial.backFaceCulling = extension.doubleSided === undefined ? false : !extension.doubleSided;\r\n standardMaterial.alpha = extension.values.transparency === undefined ? 1.0 : extension.values.transparency;\r\n standardMaterial.specularPower = extension.values.shininess === undefined ? 0.0 : extension.values.shininess;\r\n\r\n // Ambient\r\n if (typeof extension.values.ambient === \"string\") {\r\n this._loadTexture(gltfRuntime, extension.values.ambient, standardMaterial, \"ambientTexture\", onError);\r\n } else {\r\n standardMaterial.ambientColor = Color3.FromArray(extension.values.ambient || [0, 0, 0]);\r\n }\r\n\r\n // Diffuse\r\n if (typeof extension.values.diffuse === \"string\") {\r\n this._loadTexture(gltfRuntime, extension.values.diffuse, standardMaterial, \"diffuseTexture\", onError);\r\n } else {\r\n standardMaterial.diffuseColor = Color3.FromArray(extension.values.diffuse || [0, 0, 0]);\r\n }\r\n\r\n // Emission\r\n if (typeof extension.values.emission === \"string\") {\r\n this._loadTexture(gltfRuntime, extension.values.emission, standardMaterial, \"emissiveTexture\", onError);\r\n } else {\r\n standardMaterial.emissiveColor = Color3.FromArray(extension.values.emission || [0, 0, 0]);\r\n }\r\n\r\n // Specular\r\n if (typeof extension.values.specular === \"string\") {\r\n this._loadTexture(gltfRuntime, extension.values.specular, standardMaterial, \"specularTexture\", onError);\r\n } else {\r\n standardMaterial.specularColor = Color3.FromArray(extension.values.specular || [0, 0, 0]);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n private _loadTexture(gltfRuntime: IGLTFRuntime, id: string, material: StandardMaterial, propertyPath: string, onError: (message: string) => void): void {\r\n // Create buffer from texture url\r\n GLTFLoaderBase.LoadTextureBufferAsync(\r\n gltfRuntime,\r\n id,\r\n (buffer) => {\r\n // Create texture from buffer\r\n GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, (texture) => ((<any>material)[propertyPath] = texture));\r\n },\r\n onError\r\n );\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(new GLTFMaterialsCommonExtension());\r\n"]}
@@ -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 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../sourceES6/loaders/src/glTF/1.0/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC","sourcesContent":["export * from \"./glTFBinaryExtension\";\r\nexport * from \"./glTFLoader\";\r\nexport * from \"./glTFLoaderInterfaces\";\r\nexport * from \"./glTFLoaderUtils\";\r\nexport * from \"./glTFMaterialsCommonExtension\";"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../lts/loaders/generated/glTF/1.0/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC","sourcesContent":["export * from \"./glTFBinaryExtension\";\r\nexport * from \"./glTFLoader\";\r\nexport * from \"./glTFLoaderInterfaces\";\r\nexport * from \"./glTFLoaderUtils\";\r\nexport * from \"./glTFMaterialsCommonExtension\";\r\n"]}
@@ -1,36 +1,43 @@
1
- import { Nullable } from "@babylonjs/core/types";
2
- import { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture";
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
- /** @hidden */
28
- constructor(loader: GLTFLoader);
29
- /** @hidden */
30
- dispose(): void;
31
- /** @hidden */
32
- onLoading(): void;
33
- /** @hidden */
34
- loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
35
- private _loadLightAsync;
36
- }
1
+ import type { Nullable } from "@babylonjs/core/types.js";
2
+ import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
3
+ import type { IScene } from "../glTFLoaderInterfaces";
4
+ import type { 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
+ }