@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,31 +1,39 @@
1
- import { DracoCompression } from "@babylonjs/core/Meshes/Compression/dracoCompression";
2
- import { Nullable } from "@babylonjs/core/types";
3
- import { Geometry } from "@babylonjs/core/Meshes/geometry";
4
- import { Mesh } from "@babylonjs/core/Meshes/mesh";
5
- import { IMeshPrimitive } from "../glTFLoaderInterfaces";
6
- import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
7
- import { GLTFLoader } from "../glTFLoader";
8
- /**
9
- * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
10
- */
11
- export declare class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
12
- /**
13
- * The name of this extension.
14
- */
15
- readonly name = "KHR_draco_mesh_compression";
16
- /**
17
- * The draco compression used to decode vertex data or DracoCompression.Default if not defined
18
- */
19
- dracoCompression?: DracoCompression;
20
- /**
21
- * Defines whether this extension is enabled.
22
- */
23
- enabled: boolean;
24
- private _loader;
25
- /** @hidden */
26
- constructor(loader: GLTFLoader);
27
- /** @hidden */
28
- dispose(): void;
29
- /** @hidden */
30
- _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
31
- }
1
+ import { DracoCompression } from "@babylonjs/core/Meshes/Compression/dracoCompression.js";
2
+ import type { Nullable } from "@babylonjs/core/types.js";
3
+ import { Geometry } from "@babylonjs/core/Meshes/geometry.js";
4
+ import type { Mesh } from "@babylonjs/core/Meshes/mesh.js";
5
+ import type { IMeshPrimitive } from "../glTFLoaderInterfaces";
6
+ import type { IGLTFLoaderExtension } from "../glTFLoaderExtension";
7
+ import { GLTFLoader } from "../glTFLoader";
8
+ /**
9
+ * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
10
+ */
11
+ export declare class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
12
+ /**
13
+ * The name of this extension.
14
+ */
15
+ readonly name = "KHR_draco_mesh_compression";
16
+ /**
17
+ * The draco compression used to decode vertex data or DracoCompression.Default if not defined
18
+ */
19
+ dracoCompression?: DracoCompression;
20
+ /**
21
+ * Defines whether this extension is enabled.
22
+ */
23
+ enabled: boolean;
24
+ private _loader;
25
+ /**
26
+ * @param loader
27
+ * @hidden
28
+ */
29
+ constructor(loader: GLTFLoader);
30
+ /** @hidden */
31
+ dispose(): void;
32
+ /**
33
+ * @param context
34
+ * @param primitive
35
+ * @param babylonMesh
36
+ * @hidden
37
+ */
38
+ _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
39
+ }
@@ -1,102 +1,113 @@
1
- import { DracoCompression } from "@babylonjs/core/Meshes/Compression/dracoCompression.js";
2
- import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
3
- import { Geometry } from "@babylonjs/core/Meshes/geometry.js";
4
- import { GLTFLoader, ArrayItem } from "../glTFLoader.js";
5
- var NAME = "KHR_draco_mesh_compression";
6
- /**
7
- * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
8
- */
9
- var KHR_draco_mesh_compression = /** @class */ (function () {
10
- /** @hidden */
11
- function KHR_draco_mesh_compression(loader) {
12
- /**
13
- * The name of this extension.
14
- */
15
- this.name = NAME;
16
- this._loader = loader;
17
- this.enabled = DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME);
18
- }
19
- /** @hidden */
20
- KHR_draco_mesh_compression.prototype.dispose = function () {
21
- delete this.dracoCompression;
22
- this._loader = null;
23
- };
24
- /** @hidden */
25
- KHR_draco_mesh_compression.prototype._loadVertexDataAsync = function (context, primitive, babylonMesh) {
26
- var _this = this;
27
- return GLTFLoader.LoadExtensionAsync(context, primitive, this.name, function (extensionContext, extension) {
28
- if (primitive.mode != undefined) {
29
- if (primitive.mode !== 5 /* TRIANGLE_STRIP */ &&
30
- primitive.mode !== 4 /* TRIANGLES */) {
31
- throw new Error("".concat(context, ": Unsupported mode ").concat(primitive.mode));
32
- }
33
- // TODO: handle triangle strips
34
- if (primitive.mode === 5 /* TRIANGLE_STRIP */) {
35
- throw new Error("".concat(context, ": Mode ").concat(primitive.mode, " is not currently supported"));
36
- }
37
- }
38
- var attributes = {};
39
- var dividers = {};
40
- var loadAttribute = function (name, kind) {
41
- var uniqueId = extension.attributes[name];
42
- if (uniqueId === undefined || primitive.attributes[name] === undefined) {
43
- return;
44
- }
45
- attributes[kind] = uniqueId;
46
- var accessor = ArrayItem.Get("".concat(context, "/attributes/").concat(name), _this._loader.gltf.accessors, primitive.attributes[name]);
47
- if (accessor.normalized && accessor.componentType !== 5126 /* FLOAT */) {
48
- var divider = 1;
49
- switch (accessor.componentType) {
50
- case 5120 /* BYTE */:
51
- divider = 127.0;
52
- break;
53
- case 5121 /* UNSIGNED_BYTE */:
54
- divider = 255.0;
55
- break;
56
- case 5122 /* SHORT */:
57
- divider = 32767.0;
58
- break;
59
- case 5123 /* UNSIGNED_SHORT */:
60
- divider = 65535.0;
61
- break;
62
- }
63
- dividers[kind] = divider;
64
- }
65
- babylonMesh._delayInfo = babylonMesh._delayInfo || [];
66
- if (babylonMesh._delayInfo.indexOf(kind) === -1) {
67
- babylonMesh._delayInfo.push(kind);
68
- }
69
- };
70
- loadAttribute("POSITION", VertexBuffer.PositionKind);
71
- loadAttribute("NORMAL", VertexBuffer.NormalKind);
72
- loadAttribute("TANGENT", VertexBuffer.TangentKind);
73
- loadAttribute("TEXCOORD_0", VertexBuffer.UVKind);
74
- loadAttribute("TEXCOORD_1", VertexBuffer.UV2Kind);
75
- loadAttribute("TEXCOORD_2", VertexBuffer.UV3Kind);
76
- loadAttribute("TEXCOORD_3", VertexBuffer.UV4Kind);
77
- loadAttribute("TEXCOORD_4", VertexBuffer.UV5Kind);
78
- loadAttribute("TEXCOORD_5", VertexBuffer.UV6Kind);
79
- loadAttribute("JOINTS_0", VertexBuffer.MatricesIndicesKind);
80
- loadAttribute("WEIGHTS_0", VertexBuffer.MatricesWeightsKind);
81
- loadAttribute("COLOR_0", VertexBuffer.ColorKind);
82
- var bufferView = ArrayItem.Get(extensionContext, _this._loader.gltf.bufferViews, extension.bufferView);
83
- if (!bufferView._dracoBabylonGeometry) {
84
- bufferView._dracoBabylonGeometry = _this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) {
85
- var dracoCompression = _this.dracoCompression || DracoCompression.Default;
86
- return dracoCompression.decodeMeshAsync(data, attributes, dividers).then(function (babylonVertexData) {
87
- var babylonGeometry = new Geometry(babylonMesh.name, _this._loader.babylonScene);
88
- babylonVertexData.applyToGeometry(babylonGeometry);
89
- return babylonGeometry;
90
- }).catch(function (error) {
91
- throw new Error("".concat(context, ": ").concat(error.message));
92
- });
93
- });
94
- }
95
- return bufferView._dracoBabylonGeometry;
96
- });
97
- };
98
- return KHR_draco_mesh_compression;
99
- }());
100
- export { KHR_draco_mesh_compression };
101
- GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_draco_mesh_compression(loader); });
1
+ /* eslint-disable @typescript-eslint/naming-convention */
2
+ import { DracoCompression } from "@babylonjs/core/Meshes/Compression/dracoCompression.js";
3
+ import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
4
+ import { Geometry } from "@babylonjs/core/Meshes/geometry.js";
5
+ import { GLTFLoader, ArrayItem } from "../glTFLoader";
6
+ var NAME = "KHR_draco_mesh_compression";
7
+ /**
8
+ * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
9
+ */
10
+ var KHR_draco_mesh_compression = /** @class */ (function () {
11
+ /**
12
+ * @param loader
13
+ * @hidden
14
+ */
15
+ function KHR_draco_mesh_compression(loader) {
16
+ /**
17
+ * The name of this extension.
18
+ */
19
+ this.name = NAME;
20
+ this._loader = loader;
21
+ this.enabled = DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME);
22
+ }
23
+ /** @hidden */
24
+ KHR_draco_mesh_compression.prototype.dispose = function () {
25
+ delete this.dracoCompression;
26
+ this._loader = null;
27
+ };
28
+ /**
29
+ * @param context
30
+ * @param primitive
31
+ * @param babylonMesh
32
+ * @hidden
33
+ */
34
+ KHR_draco_mesh_compression.prototype._loadVertexDataAsync = function (context, primitive, babylonMesh) {
35
+ var _this = this;
36
+ return GLTFLoader.LoadExtensionAsync(context, primitive, this.name, function (extensionContext, extension) {
37
+ if (primitive.mode != undefined) {
38
+ if (primitive.mode !== 5 /* TRIANGLE_STRIP */ && primitive.mode !== 4 /* TRIANGLES */) {
39
+ throw new Error("".concat(context, ": Unsupported mode ").concat(primitive.mode));
40
+ }
41
+ // TODO: handle triangle strips
42
+ if (primitive.mode === 5 /* TRIANGLE_STRIP */) {
43
+ throw new Error("".concat(context, ": Mode ").concat(primitive.mode, " is not currently supported"));
44
+ }
45
+ }
46
+ var attributes = {};
47
+ var dividers = {};
48
+ var loadAttribute = function (name, kind) {
49
+ var uniqueId = extension.attributes[name];
50
+ if (uniqueId === undefined || primitive.attributes[name] === undefined) {
51
+ return;
52
+ }
53
+ attributes[kind] = uniqueId;
54
+ var accessor = ArrayItem.Get("".concat(context, "/attributes/").concat(name), _this._loader.gltf.accessors, primitive.attributes[name]);
55
+ if (accessor.normalized && accessor.componentType !== 5126 /* FLOAT */) {
56
+ var divider = 1;
57
+ switch (accessor.componentType) {
58
+ case 5120 /* BYTE */:
59
+ divider = 127.0;
60
+ break;
61
+ case 5121 /* UNSIGNED_BYTE */:
62
+ divider = 255.0;
63
+ break;
64
+ case 5122 /* SHORT */:
65
+ divider = 32767.0;
66
+ break;
67
+ case 5123 /* UNSIGNED_SHORT */:
68
+ divider = 65535.0;
69
+ break;
70
+ }
71
+ dividers[kind] = divider;
72
+ }
73
+ babylonMesh._delayInfo = babylonMesh._delayInfo || [];
74
+ if (babylonMesh._delayInfo.indexOf(kind) === -1) {
75
+ babylonMesh._delayInfo.push(kind);
76
+ }
77
+ };
78
+ loadAttribute("POSITION", VertexBuffer.PositionKind);
79
+ loadAttribute("NORMAL", VertexBuffer.NormalKind);
80
+ loadAttribute("TANGENT", VertexBuffer.TangentKind);
81
+ loadAttribute("TEXCOORD_0", VertexBuffer.UVKind);
82
+ loadAttribute("TEXCOORD_1", VertexBuffer.UV2Kind);
83
+ loadAttribute("TEXCOORD_2", VertexBuffer.UV3Kind);
84
+ loadAttribute("TEXCOORD_3", VertexBuffer.UV4Kind);
85
+ loadAttribute("TEXCOORD_4", VertexBuffer.UV5Kind);
86
+ loadAttribute("TEXCOORD_5", VertexBuffer.UV6Kind);
87
+ loadAttribute("JOINTS_0", VertexBuffer.MatricesIndicesKind);
88
+ loadAttribute("WEIGHTS_0", VertexBuffer.MatricesWeightsKind);
89
+ loadAttribute("COLOR_0", VertexBuffer.ColorKind);
90
+ var bufferView = ArrayItem.Get(extensionContext, _this._loader.gltf.bufferViews, extension.bufferView);
91
+ if (!bufferView._dracoBabylonGeometry) {
92
+ bufferView._dracoBabylonGeometry = _this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) {
93
+ var dracoCompression = _this.dracoCompression || DracoCompression.Default;
94
+ return dracoCompression
95
+ .decodeMeshAsync(data, attributes, dividers)
96
+ .then(function (babylonVertexData) {
97
+ var babylonGeometry = new Geometry(babylonMesh.name, _this._loader.babylonScene);
98
+ babylonVertexData.applyToGeometry(babylonGeometry);
99
+ return babylonGeometry;
100
+ })
101
+ .catch(function (error) {
102
+ throw new Error("".concat(context, ": ").concat(error.message));
103
+ });
104
+ });
105
+ }
106
+ return bufferView._dracoBabylonGeometry;
107
+ });
108
+ };
109
+ return KHR_draco_mesh_compression;
110
+ }());
111
+ export { KHR_draco_mesh_compression };
112
+ GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_draco_mesh_compression(loader); });
102
113
  //# sourceMappingURL=KHR_draco_mesh_compression.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_draco_mesh_compression.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAEvF,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAM3D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEtD,IAAM,IAAI,GAAG,4BAA4B,CAAC;AAM1C;;GAEG;AACH;IAkBI,cAAc;IACd,oCAAY,MAAkB;QAlB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAgBxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC,gBAAgB,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC3F,CAAC;IAED,cA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,MAAM,IAAK,OAAA,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAtC,CAAsC,CAAC,CAAC","sourcesContent":["import { DracoCompression } from \"@babylonjs/core/Meshes/Compression/dracoCompression\";\r\nimport { Nullable } from \"@babylonjs/core/types\";\r\nimport { VertexBuffer } from \"@babylonjs/core/Buffers/buffer\";\r\nimport { Geometry } from \"@babylonjs/core/Meshes/geometry\";\r\nimport { Mesh } from \"@babylonjs/core/Meshes/mesh\";\r\n\r\nimport { MeshPrimitiveMode, IKHRDracoMeshCompression, AccessorComponentType } from \"babylonjs-gltf2interface\";\r\nimport { IMeshPrimitive, IBufferView } from \"../glTFLoaderInterfaces\";\r\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\n\r\nconst NAME = \"KHR_draco_mesh_compression\";\r\n\r\ninterface IBufferViewDraco extends IBufferView {\r\n _dracoBabylonGeometry?: Promise<Geometry>;\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)\r\n */\r\nexport class KHR_draco_mesh_compression implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * The draco compression used to decode vertex data or DracoCompression.Default if not defined\r\n */\r\n public dracoCompression?: DracoCompression;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /** @hidden */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @hidden */\r\n public dispose(): void {\r\n delete this.dracoCompression;\r\n (this._loader as any) = null;\r\n }\r\n\r\n /** @hidden */\r\n public _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRDracoMeshCompression, Geometry>(context, primitive, this.name, (extensionContext, extension) => {\r\n if (primitive.mode != undefined) {\r\n if (primitive.mode !== MeshPrimitiveMode.TRIANGLE_STRIP &&\r\n primitive.mode !== MeshPrimitiveMode.TRIANGLES) {\r\n throw new Error(`${context}: Unsupported mode ${primitive.mode}`);\r\n }\r\n\r\n // TODO: handle triangle strips\r\n if (primitive.mode === MeshPrimitiveMode.TRIANGLE_STRIP) {\r\n throw new Error(`${context}: Mode ${primitive.mode} is not currently supported`);\r\n }\r\n }\r\n\r\n const attributes: {\r\n [kind: string]: number\r\n } = {};\r\n const dividers: {\r\n [kind: string]: number\r\n } = {};\r\n const loadAttribute = (name: string, kind: string) => {\r\n const uniqueId = extension.attributes[name];\r\n if (uniqueId === undefined || primitive.attributes[name] === undefined) {\r\n return;\r\n }\r\n\r\n attributes[kind] = uniqueId;\r\n const accessor = ArrayItem.Get(`${context}/attributes/${name}`, this._loader.gltf.accessors, primitive.attributes[name]);\r\n if (accessor.normalized && accessor.componentType !== AccessorComponentType.FLOAT) {\r\n let divider = 1;\r\n switch (accessor.componentType) {\r\n case AccessorComponentType.BYTE:\r\n divider = 127.0;\r\n break;\r\n case AccessorComponentType.UNSIGNED_BYTE:\r\n divider = 255.0;\r\n break;\r\n case AccessorComponentType.SHORT:\r\n divider = 32767.0;\r\n break;\r\n case AccessorComponentType.UNSIGNED_SHORT:\r\n divider = 65535.0;\r\n break;\r\n }\r\n dividers[kind] = divider;\r\n }\r\n\r\n babylonMesh._delayInfo = babylonMesh._delayInfo || [];\r\n if (babylonMesh._delayInfo.indexOf(kind) === -1) {\r\n babylonMesh._delayInfo.push(kind);\r\n }\r\n\r\n };\r\n\r\n loadAttribute(\"POSITION\", VertexBuffer.PositionKind);\r\n loadAttribute(\"NORMAL\", VertexBuffer.NormalKind);\r\n loadAttribute(\"TANGENT\", VertexBuffer.TangentKind);\r\n loadAttribute(\"TEXCOORD_0\", VertexBuffer.UVKind);\r\n loadAttribute(\"TEXCOORD_1\", VertexBuffer.UV2Kind);\r\n loadAttribute(\"TEXCOORD_2\", VertexBuffer.UV3Kind);\r\n loadAttribute(\"TEXCOORD_3\", VertexBuffer.UV4Kind);\r\n loadAttribute(\"TEXCOORD_4\", VertexBuffer.UV5Kind);\r\n loadAttribute(\"TEXCOORD_5\", VertexBuffer.UV6Kind);\r\n loadAttribute(\"JOINTS_0\", VertexBuffer.MatricesIndicesKind);\r\n loadAttribute(\"WEIGHTS_0\", VertexBuffer.MatricesWeightsKind);\r\n loadAttribute(\"COLOR_0\", VertexBuffer.ColorKind);\r\n\r\n var bufferView = ArrayItem.Get(extensionContext, this._loader.gltf.bufferViews, extension.bufferView) as IBufferViewDraco;\r\n if (!bufferView._dracoBabylonGeometry) {\r\n bufferView._dracoBabylonGeometry = this._loader.loadBufferViewAsync(`/bufferViews/${bufferView.index}`, bufferView).then((data) => {\r\n const dracoCompression = this.dracoCompression || DracoCompression.Default;\r\n return dracoCompression.decodeMeshAsync(data, attributes, dividers).then((babylonVertexData) => {\r\n const babylonGeometry = new Geometry(babylonMesh.name, this._loader.babylonScene);\r\n babylonVertexData.applyToGeometry(babylonGeometry);\r\n return babylonGeometry;\r\n }).catch((error) => {\r\n throw new Error(`${context}: ${error.message}`);\r\n });\r\n });\r\n }\r\n\r\n return bufferView._dracoBabylonGeometry;\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_draco_mesh_compression(loader));"]}
1
+ {"version":3,"file":"KHR_draco_mesh_compression.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,gBAAgB,EAAE,+DAAiD;AAE5E,OAAO,EAAE,YAAY,EAAE,0CAA4B;AACnD,OAAO,EAAE,QAAQ,EAAE,2CAA6B;AAOhD,OAAO,EAAE,UAAU,EAAE,SAA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AC3B,CAAC,CAAC;yBACD,KAAK,CAAC,UAAC,KAAK;wBACT,MAAM,IAAI,KAAK,CAAC,UAAG,OAAO,eAAK,KAAK,CAAC,OAAO,CAAE,CAAC,CAAC;oBACpD,CAAC,CAAC,CAAC;gBACX,CAAC,CAAC,CAAC;aACN;YAED,OAAO,UAAU,CAAC,qBAAqB,CAAC;QAC5C,CAAC,CAAC,CAAC;IACP,CAAC;IACL,iCAAC;AAAD,CAAC,AA5HD,IA4HC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAtC,CAAsC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { DracoCompression } from \"core/Meshes/Compression/dracoCompression\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport { Geometry } from \"core/Meshes/geometry\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\n\r\nimport type { IKHRDracoMeshCompression } from \"babylonjs-gltf2interface\";\r\nimport { MeshPrimitiveMode, AccessorComponentType } from \"babylonjs-gltf2interface\";\r\nimport type { IMeshPrimitive, IBufferView } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\n\r\nconst NAME = \"KHR_draco_mesh_compression\";\r\n\r\ninterface IBufferViewDraco extends IBufferView {\r\n _dracoBabylonGeometry?: Promise<Geometry>;\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)\r\n */\r\nexport class KHR_draco_mesh_compression implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * The draco compression used to decode vertex data or DracoCompression.Default if not defined\r\n */\r\n public dracoCompression?: DracoCompression;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @param loader\r\n * @hidden\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @hidden */\r\n public dispose(): void {\r\n delete this.dracoCompression;\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @param context\r\n * @param primitive\r\n * @param babylonMesh\r\n * @hidden\r\n */\r\n public _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRDracoMeshCompression, Geometry>(context, primitive, this.name, (extensionContext, extension) => {\r\n if (primitive.mode != undefined) {\r\n if (primitive.mode !== MeshPrimitiveMode.TRIANGLE_STRIP && primitive.mode !== MeshPrimitiveMode.TRIANGLES) {\r\n throw new Error(`${context}: Unsupported mode ${primitive.mode}`);\r\n }\r\n\r\n // TODO: handle triangle strips\r\n if (primitive.mode === MeshPrimitiveMode.TRIANGLE_STRIP) {\r\n throw new Error(`${context}: Mode ${primitive.mode} is not currently supported`);\r\n }\r\n }\r\n\r\n const attributes: {\r\n [kind: string]: number;\r\n } = {};\r\n const dividers: {\r\n [kind: string]: number;\r\n } = {};\r\n const loadAttribute = (name: string, kind: string) => {\r\n const uniqueId = extension.attributes[name];\r\n if (uniqueId === undefined || primitive.attributes[name] === undefined) {\r\n return;\r\n }\r\n\r\n attributes[kind] = uniqueId;\r\n const accessor = ArrayItem.Get(`${context}/attributes/${name}`, this._loader.gltf.accessors, primitive.attributes[name]);\r\n if (accessor.normalized && accessor.componentType !== AccessorComponentType.FLOAT) {\r\n let divider = 1;\r\n switch (accessor.componentType) {\r\n case AccessorComponentType.BYTE:\r\n divider = 127.0;\r\n break;\r\n case AccessorComponentType.UNSIGNED_BYTE:\r\n divider = 255.0;\r\n break;\r\n case AccessorComponentType.SHORT:\r\n divider = 32767.0;\r\n break;\r\n case AccessorComponentType.UNSIGNED_SHORT:\r\n divider = 65535.0;\r\n break;\r\n }\r\n dividers[kind] = divider;\r\n }\r\n\r\n babylonMesh._delayInfo = babylonMesh._delayInfo || [];\r\n if (babylonMesh._delayInfo.indexOf(kind) === -1) {\r\n babylonMesh._delayInfo.push(kind);\r\n }\r\n };\r\n\r\n loadAttribute(\"POSITION\", VertexBuffer.PositionKind);\r\n loadAttribute(\"NORMAL\", VertexBuffer.NormalKind);\r\n loadAttribute(\"TANGENT\", VertexBuffer.TangentKind);\r\n loadAttribute(\"TEXCOORD_0\", VertexBuffer.UVKind);\r\n loadAttribute(\"TEXCOORD_1\", VertexBuffer.UV2Kind);\r\n loadAttribute(\"TEXCOORD_2\", VertexBuffer.UV3Kind);\r\n loadAttribute(\"TEXCOORD_3\", VertexBuffer.UV4Kind);\r\n loadAttribute(\"TEXCOORD_4\", VertexBuffer.UV5Kind);\r\n loadAttribute(\"TEXCOORD_5\", VertexBuffer.UV6Kind);\r\n loadAttribute(\"JOINTS_0\", VertexBuffer.MatricesIndicesKind);\r\n loadAttribute(\"WEIGHTS_0\", VertexBuffer.MatricesWeightsKind);\r\n loadAttribute(\"COLOR_0\", VertexBuffer.ColorKind);\r\n\r\n const bufferView = ArrayItem.Get(extensionContext, this._loader.gltf.bufferViews, extension.bufferView) as IBufferViewDraco;\r\n if (!bufferView._dracoBabylonGeometry) {\r\n bufferView._dracoBabylonGeometry = this._loader.loadBufferViewAsync(`/bufferViews/${bufferView.index}`, bufferView).then((data) => {\r\n const dracoCompression = this.dracoCompression || DracoCompression.Default;\r\n return dracoCompression\r\n .decodeMeshAsync(data, attributes, dividers)\r\n .then((babylonVertexData) => {\r\n const babylonGeometry = new Geometry(babylonMesh.name, this._loader.babylonScene);\r\n babylonVertexData.applyToGeometry(babylonGeometry);\r\n return babylonGeometry;\r\n })\r\n .catch((error) => {\r\n throw new Error(`${context}: ${error.message}`);\r\n });\r\n });\r\n }\r\n\r\n return bufferView._dracoBabylonGeometry;\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_draco_mesh_compression(loader));\r\n"]}
@@ -1,28 +1,36 @@
1
- import { Nullable } from "@babylonjs/core/types";
2
- import { TransformNode } from "@babylonjs/core/Meshes/transformNode";
3
- import { INode } from "../glTFLoaderInterfaces";
4
- import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
5
- import { GLTFLoader } from "../glTFLoader";
6
- /**
7
- * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
8
- */
9
- export declare class KHR_lights implements IGLTFLoaderExtension {
10
- /**
11
- * The name of this extension.
12
- */
13
- readonly name = "KHR_lights_punctual";
14
- /**
15
- * Defines whether this extension is enabled.
16
- */
17
- enabled: boolean;
18
- private _loader;
19
- private _lights?;
20
- /** @hidden */
21
- constructor(loader: GLTFLoader);
22
- /** @hidden */
23
- dispose(): void;
24
- /** @hidden */
25
- onLoading(): void;
26
- /** @hidden */
27
- loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
28
- }
1
+ import type { Nullable } from "@babylonjs/core/types.js";
2
+ import type { TransformNode } from "@babylonjs/core/Meshes/transformNode.js";
3
+ import type { INode } from "../glTFLoaderInterfaces";
4
+ import type { IGLTFLoaderExtension } from "../glTFLoaderExtension";
5
+ import { GLTFLoader } from "../glTFLoader";
6
+ /**
7
+ * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
8
+ */
9
+ export declare class KHR_lights implements IGLTFLoaderExtension {
10
+ /**
11
+ * The name of this extension.
12
+ */
13
+ readonly name = "KHR_lights_punctual";
14
+ /**
15
+ * Defines whether this extension is enabled.
16
+ */
17
+ enabled: boolean;
18
+ private _loader;
19
+ private _lights?;
20
+ /**
21
+ * @param loader
22
+ * @hidden
23
+ */
24
+ constructor(loader: GLTFLoader);
25
+ /** @hidden */
26
+ dispose(): void;
27
+ /** @hidden */
28
+ onLoading(): void;
29
+ /**
30
+ * @param context
31
+ * @param node
32
+ * @param assign
33
+ * @hidden
34
+ */
35
+ loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
36
+ }
@@ -1,82 +1,90 @@
1
- import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
2
- import { Color3 } from '@babylonjs/core/Maths/math.color.js';
3
- import { DirectionalLight } from "@babylonjs/core/Lights/directionalLight.js";
4
- import { PointLight } from "@babylonjs/core/Lights/pointLight.js";
5
- import { SpotLight } from "@babylonjs/core/Lights/spotLight.js";
6
- import { Light } from "@babylonjs/core/Lights/light.js";
7
- import { GLTFLoader, ArrayItem } from "../glTFLoader.js";
8
- var NAME = "KHR_lights_punctual";
9
- /**
10
- * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
11
- */
12
- var KHR_lights = /** @class */ (function () {
13
- /** @hidden */
14
- function KHR_lights(loader) {
15
- /**
16
- * The name of this extension.
17
- */
18
- this.name = NAME;
19
- this._loader = loader;
20
- this.enabled = this._loader.isExtensionUsed(NAME);
21
- }
22
- /** @hidden */
23
- KHR_lights.prototype.dispose = function () {
24
- this._loader = null;
25
- delete this._lights;
26
- };
27
- /** @hidden */
28
- KHR_lights.prototype.onLoading = function () {
29
- var extensions = this._loader.gltf.extensions;
30
- if (extensions && extensions[this.name]) {
31
- var extension = extensions[this.name];
32
- this._lights = extension.lights;
33
- }
34
- };
35
- /** @hidden */
36
- KHR_lights.prototype.loadNodeAsync = function (context, node, assign) {
37
- var _this = this;
38
- return GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) {
39
- return _this._loader.loadNodeAsync(context, node, function (babylonMesh) {
40
- var babylonLight;
41
- var light = ArrayItem.Get(extensionContext, _this._lights, extension.light);
42
- var name = light.name || babylonMesh.name;
43
- _this._loader.babylonScene._blockEntityCollection = !!_this._loader._assetContainer;
44
- switch (light.type) {
45
- case "directional" /* DIRECTIONAL */: {
46
- babylonLight = new DirectionalLight(name, Vector3.Backward(), _this._loader.babylonScene);
47
- break;
48
- }
49
- case "point" /* POINT */: {
50
- babylonLight = new PointLight(name, Vector3.Zero(), _this._loader.babylonScene);
51
- break;
52
- }
53
- case "spot" /* SPOT */: {
54
- var babylonSpotLight = new SpotLight(name, Vector3.Zero(), Vector3.Backward(), 0, 1, _this._loader.babylonScene);
55
- babylonSpotLight.angle = ((light.spot && light.spot.outerConeAngle) || Math.PI / 4) * 2;
56
- babylonSpotLight.innerAngle = ((light.spot && light.spot.innerConeAngle) || 0) * 2;
57
- babylonLight = babylonSpotLight;
58
- break;
59
- }
60
- default: {
61
- _this._loader.babylonScene._blockEntityCollection = false;
62
- throw new Error("".concat(extensionContext, ": Invalid light type (").concat(light.type, ")"));
63
- }
64
- }
65
- babylonLight._parentContainer = _this._loader._assetContainer;
66
- _this._loader.babylonScene._blockEntityCollection = false;
67
- babylonLight.falloffType = Light.FALLOFF_GLTF;
68
- babylonLight.diffuse = light.color ? Color3.FromArray(light.color) : Color3.White();
69
- babylonLight.intensity = light.intensity == undefined ? 1 : light.intensity;
70
- babylonLight.range = light.range == undefined ? Number.MAX_VALUE : light.range;
71
- babylonLight.parent = babylonMesh;
72
- _this._loader._babylonLights.push(babylonLight);
73
- GLTFLoader.AddPointerMetadata(babylonLight, extensionContext);
74
- assign(babylonMesh);
75
- });
76
- });
77
- };
78
- return KHR_lights;
79
- }());
80
- export { KHR_lights };
81
- GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_lights(loader); });
1
+ import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
2
+ import { Color3 } from "@babylonjs/core/Maths/math.color.js";
3
+ import { DirectionalLight } from "@babylonjs/core/Lights/directionalLight.js";
4
+ import { PointLight } from "@babylonjs/core/Lights/pointLight.js";
5
+ import { SpotLight } from "@babylonjs/core/Lights/spotLight.js";
6
+ import { Light } from "@babylonjs/core/Lights/light.js";
7
+ import { GLTFLoader, ArrayItem } from "../glTFLoader";
8
+ var NAME = "KHR_lights_punctual";
9
+ /**
10
+ * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
11
+ */
12
+ var KHR_lights = /** @class */ (function () {
13
+ /**
14
+ * @param loader
15
+ * @hidden
16
+ */
17
+ function KHR_lights(loader) {
18
+ /**
19
+ * The name of this extension.
20
+ */
21
+ this.name = NAME;
22
+ this._loader = loader;
23
+ this.enabled = this._loader.isExtensionUsed(NAME);
24
+ }
25
+ /** @hidden */
26
+ KHR_lights.prototype.dispose = function () {
27
+ this._loader = null;
28
+ delete this._lights;
29
+ };
30
+ /** @hidden */
31
+ KHR_lights.prototype.onLoading = function () {
32
+ var extensions = this._loader.gltf.extensions;
33
+ if (extensions && extensions[this.name]) {
34
+ var extension = extensions[this.name];
35
+ this._lights = extension.lights;
36
+ }
37
+ };
38
+ /**
39
+ * @param context
40
+ * @param node
41
+ * @param assign
42
+ * @hidden
43
+ */
44
+ KHR_lights.prototype.loadNodeAsync = function (context, node, assign) {
45
+ var _this = this;
46
+ return GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) {
47
+ return _this._loader.loadNodeAsync(context, node, function (babylonMesh) {
48
+ var babylonLight;
49
+ var light = ArrayItem.Get(extensionContext, _this._lights, extension.light);
50
+ var name = light.name || babylonMesh.name;
51
+ _this._loader.babylonScene._blockEntityCollection = !!_this._loader._assetContainer;
52
+ switch (light.type) {
53
+ case "directional" /* DIRECTIONAL */: {
54
+ babylonLight = new DirectionalLight(name, Vector3.Backward(), _this._loader.babylonScene);
55
+ break;
56
+ }
57
+ case "point" /* POINT */: {
58
+ babylonLight = new PointLight(name, Vector3.Zero(), _this._loader.babylonScene);
59
+ break;
60
+ }
61
+ case "spot" /* SPOT */: {
62
+ var babylonSpotLight = new SpotLight(name, Vector3.Zero(), Vector3.Backward(), 0, 1, _this._loader.babylonScene);
63
+ babylonSpotLight.angle = ((light.spot && light.spot.outerConeAngle) || Math.PI / 4) * 2;
64
+ babylonSpotLight.innerAngle = ((light.spot && light.spot.innerConeAngle) || 0) * 2;
65
+ babylonLight = babylonSpotLight;
66
+ break;
67
+ }
68
+ default: {
69
+ _this._loader.babylonScene._blockEntityCollection = false;
70
+ throw new Error("".concat(extensionContext, ": Invalid light type (").concat(light.type, ")"));
71
+ }
72
+ }
73
+ babylonLight._parentContainer = _this._loader._assetContainer;
74
+ _this._loader.babylonScene._blockEntityCollection = false;
75
+ babylonLight.falloffType = Light.FALLOFF_GLTF;
76
+ babylonLight.diffuse = light.color ? Color3.FromArray(light.color) : Color3.White();
77
+ babylonLight.intensity = light.intensity == undefined ? 1 : light.intensity;
78
+ babylonLight.range = light.range == undefined ? Number.MAX_VALUE : light.range;
79
+ babylonLight.parent = babylonMesh;
80
+ _this._loader._babylonLights.push(babylonLight);
81
+ GLTFLoader.AddPointerMetadata(babylonLight, extensionContext);
82
+ assign(babylonMesh);
83
+ });
84
+ });
85
+ };
86
+ return KHR_lights;
87
+ }());
88
+ export { KHR_lights };
89
+ GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_lights(loader); });
82
90
  //# sourceMappingURL=KHR_lights_punctual.js.map