@babylonjs/loaders 5.0.0-beta.8 → 5.0.0-beta.8-snapshot

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. package/package.json +20 -198
  2. package/OBJ/index.d.ts +0 -4
  3. package/OBJ/index.js +0 -5
  4. package/OBJ/index.js.map +0 -1
  5. package/OBJ/mtlFileLoader.d.ts +0 -40
  6. package/OBJ/mtlFileLoader.js +0 -222
  7. package/OBJ/mtlFileLoader.js.map +0 -1
  8. package/OBJ/objFileLoader.d.ts +0 -133
  9. package/OBJ/objFileLoader.js +0 -301
  10. package/OBJ/objFileLoader.js.map +0 -1
  11. package/OBJ/objLoadingOptions.d.ts +0 -43
  12. package/OBJ/objLoadingOptions.js +0 -2
  13. package/OBJ/objLoadingOptions.js.map +0 -1
  14. package/OBJ/solidParser.d.ts +0 -153
  15. package/OBJ/solidParser.js +0 -700
  16. package/OBJ/solidParser.js.map +0 -1
  17. package/STL/index.d.ts +0 -1
  18. package/STL/index.js +0 -2
  19. package/STL/index.js.map +0 -1
  20. package/STL/stlFileLoader.d.ts +0 -71
  21. package/STL/stlFileLoader.js +0 -240
  22. package/STL/stlFileLoader.js.map +0 -1
  23. package/glTF/1.0/glTFBinaryExtension.d.ts +0 -13
  24. package/glTF/1.0/glTFBinaryExtension.js +0 -62
  25. package/glTF/1.0/glTFBinaryExtension.js.map +0 -1
  26. package/glTF/1.0/glTFLoader.d.ts +0 -106
  27. package/glTF/1.0/glTFLoader.js +0 -1697
  28. package/glTF/1.0/glTFLoader.js.map +0 -1
  29. package/glTF/1.0/glTFLoaderInterfaces.d.ts +0 -412
  30. package/glTF/1.0/glTFLoaderInterfaces.js +0 -96
  31. package/glTF/1.0/glTFLoaderInterfaces.js.map +0 -1
  32. package/glTF/1.0/glTFLoaderUtils.d.ts +0 -62
  33. package/glTF/1.0/glTFLoaderUtils.js +0 -233
  34. package/glTF/1.0/glTFLoaderUtils.js.map +0 -1
  35. package/glTF/1.0/glTFMaterialsCommonExtension.d.ts +0 -10
  36. package/glTF/1.0/glTFMaterialsCommonExtension.js +0 -128
  37. package/glTF/1.0/glTFMaterialsCommonExtension.js.map +0 -1
  38. package/glTF/1.0/index.d.ts +0 -5
  39. package/glTF/1.0/index.js +0 -6
  40. package/glTF/1.0/index.js.map +0 -1
  41. package/glTF/2.0/Extensions/EXT_lights_image_based.d.ts +0 -36
  42. package/glTF/2.0/Extensions/EXT_lights_image_based.js +0 -111
  43. package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +0 -1
  44. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +0 -27
  45. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +0 -80
  46. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +0 -1
  47. package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +0 -27
  48. package/glTF/2.0/Extensions/EXT_meshopt_compression.js +0 -43
  49. package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +0 -1
  50. package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +0 -21
  51. package/glTF/2.0/Extensions/EXT_texture_webp.js +0 -33
  52. package/glTF/2.0/Extensions/EXT_texture_webp.js.map +0 -1
  53. package/glTF/2.0/Extensions/ExtrasAsMetadata.d.ts +0 -32
  54. package/glTF/2.0/Extensions/ExtrasAsMetadata.js +0 -56
  55. package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +0 -1
  56. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +0 -31
  57. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +0 -102
  58. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +0 -1
  59. package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +0 -28
  60. package/glTF/2.0/Extensions/KHR_lights_punctual.js +0 -82
  61. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +0 -1
  62. package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +0 -31
  63. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +0 -87
  64. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +0 -1
  65. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +0 -30
  66. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +0 -46
  67. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +0 -1
  68. package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +0 -34
  69. package/glTF/2.0/Extensions/KHR_materials_ior.js +0 -55
  70. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +0 -1
  71. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.d.ts +0 -30
  72. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +0 -73
  73. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +0 -1
  74. package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +0 -31
  75. package/glTF/2.0/Extensions/KHR_materials_sheen.js +0 -77
  76. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +0 -1
  77. package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +0 -30
  78. package/glTF/2.0/Extensions/KHR_materials_specular.js +0 -67
  79. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +0 -1
  80. package/glTF/2.0/Extensions/KHR_materials_translucency.d.ts +0 -31
  81. package/glTF/2.0/Extensions/KHR_materials_translucency.js +0 -77
  82. package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +0 -1
  83. package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +0 -30
  84. package/glTF/2.0/Extensions/KHR_materials_transmission.js +0 -278
  85. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +0 -1
  86. package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +0 -30
  87. package/glTF/2.0/Extensions/KHR_materials_unlit.js +0 -66
  88. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +0 -1
  89. package/glTF/2.0/Extensions/KHR_materials_variants.d.ts +0 -76
  90. package/glTF/2.0/Extensions/KHR_materials_variants.js +0 -244
  91. package/glTF/2.0/Extensions/KHR_materials_variants.js.map +0 -1
  92. package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +0 -31
  93. package/glTF/2.0/Extensions/KHR_materials_volume.js +0 -79
  94. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +0 -1
  95. package/glTF/2.0/Extensions/KHR_mesh_quantization.d.ts +0 -19
  96. package/glTF/2.0/Extensions/KHR_mesh_quantization.js +0 -22
  97. package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +0 -1
  98. package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +0 -21
  99. package/glTF/2.0/Extensions/KHR_texture_basisu.js +0 -33
  100. package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +0 -1
  101. package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +0 -25
  102. package/glTF/2.0/Extensions/KHR_texture_transform.js +0 -54
  103. package/glTF/2.0/Extensions/KHR_texture_transform.js.map +0 -1
  104. package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +0 -29
  105. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +0 -47
  106. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +0 -1
  107. package/glTF/2.0/Extensions/MSFT_audio_emitter.d.ts +0 -38
  108. package/glTF/2.0/Extensions/MSFT_audio_emitter.js +0 -217
  109. package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +0 -1
  110. package/glTF/2.0/Extensions/MSFT_lod.d.ts +0 -75
  111. package/glTF/2.0/Extensions/MSFT_lod.js +0 -334
  112. package/glTF/2.0/Extensions/MSFT_lod.js.map +0 -1
  113. package/glTF/2.0/Extensions/MSFT_minecraftMesh.d.ts +0 -14
  114. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +0 -37
  115. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +0 -1
  116. package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +0 -14
  117. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +0 -37
  118. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +0 -1
  119. package/glTF/2.0/Extensions/index.d.ts +0 -26
  120. package/glTF/2.0/Extensions/index.js +0 -27
  121. package/glTF/2.0/Extensions/index.js.map +0 -1
  122. package/glTF/2.0/glTFLoader.d.ts +0 -357
  123. package/glTF/2.0/glTFLoader.js +0 -2249
  124. package/glTF/2.0/glTFLoader.js.map +0 -1
  125. package/glTF/2.0/glTFLoaderExtension.d.ts +0 -152
  126. package/glTF/2.0/glTFLoaderExtension.js +0 -2
  127. package/glTF/2.0/glTFLoaderExtension.js.map +0 -1
  128. package/glTF/2.0/glTFLoaderInterfaces.d.ts +0 -209
  129. package/glTF/2.0/glTFLoaderInterfaces.js +0 -2
  130. package/glTF/2.0/glTFLoaderInterfaces.js.map +0 -1
  131. package/glTF/2.0/index.d.ts +0 -4
  132. package/glTF/2.0/index.js +0 -5
  133. package/glTF/2.0/index.js.map +0 -1
  134. package/glTF/glTFFileLoader.d.ts +0 -368
  135. package/glTF/glTFFileLoader.js +0 -869
  136. package/glTF/glTFFileLoader.js.map +0 -1
  137. package/glTF/glTFValidation.d.ts +0 -29
  138. package/glTF/glTFValidation.js +0 -122
  139. package/glTF/glTFValidation.js.map +0 -1
  140. package/glTF/index.d.ts +0 -5
  141. package/glTF/index.js +0 -6
  142. package/glTF/index.js.map +0 -1
  143. package/index.d.ts +0 -3
  144. package/index.js.map +0 -1
  145. package/legacy/legacy-glTF.d.ts +0 -2
  146. package/legacy/legacy-glTF.js +0 -19
  147. package/legacy/legacy-glTF.js.map +0 -1
  148. package/legacy/legacy-glTF1.d.ts +0 -2
  149. package/legacy/legacy-glTF1.js +0 -15
  150. package/legacy/legacy-glTF1.js.map +0 -1
  151. package/legacy/legacy-glTF1FileLoader.d.ts +0 -2
  152. package/legacy/legacy-glTF1FileLoader.js +0 -3
  153. package/legacy/legacy-glTF1FileLoader.js.map +0 -1
  154. package/legacy/legacy-glTF2.d.ts +0 -2
  155. package/legacy/legacy-glTF2.js +0 -33
  156. package/legacy/legacy-glTF2.js.map +0 -1
  157. package/legacy/legacy-glTF2FileLoader.d.ts +0 -2
  158. package/legacy/legacy-glTF2FileLoader.js +0 -3
  159. package/legacy/legacy-glTF2FileLoader.js.map +0 -1
  160. package/legacy/legacy-glTFFileLoader.d.ts +0 -3
  161. package/legacy/legacy-glTFFileLoader.js +0 -4
  162. package/legacy/legacy-glTFFileLoader.js.map +0 -1
  163. package/legacy/legacy-objFileLoader.d.ts +0 -1
  164. package/legacy/legacy-objFileLoader.js +0 -13
  165. package/legacy/legacy-objFileLoader.js.map +0 -1
  166. package/legacy/legacy-stlFileLoader.d.ts +0 -1
  167. package/legacy/legacy-stlFileLoader.js +0 -13
  168. package/legacy/legacy-stlFileLoader.js.map +0 -1
  169. package/legacy/legacy.d.ts +0 -6
  170. package/legacy/legacy.js +0 -7
  171. package/legacy/legacy.js.map +0 -1
  172. package/readme.md +0 -24
@@ -1,334 +0,0 @@
1
- import { Observable } from "@babylonjs/core/Misc/observable.js";
2
- import { Deferred } from "@babylonjs/core/Misc/deferred.js";
3
- import { GLTFLoader, ArrayItem } from "../glTFLoader.js";
4
- var NAME = "MSFT_lod";
5
- /**
6
- * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
7
- */
8
- var MSFT_lod = /** @class */ (function () {
9
- /** @hidden */
10
- function MSFT_lod(loader) {
11
- /**
12
- * The name of this extension.
13
- */
14
- this.name = NAME;
15
- /**
16
- * Defines a number that determines the order the extensions are applied.
17
- */
18
- this.order = 100;
19
- /**
20
- * Maximum number of LODs to load, starting from the lowest LOD.
21
- */
22
- this.maxLODsToLoad = 10;
23
- /**
24
- * Observable raised when all node LODs of one level are loaded.
25
- * The event data is the index of the loaded LOD starting from zero.
26
- * Dispose the loader to cancel the loading of the next level of LODs.
27
- */
28
- this.onNodeLODsLoadedObservable = new Observable();
29
- /**
30
- * Observable raised when all material LODs of one level are loaded.
31
- * The event data is the index of the loaded LOD starting from zero.
32
- * Dispose the loader to cancel the loading of the next level of LODs.
33
- */
34
- this.onMaterialLODsLoadedObservable = new Observable();
35
- this._bufferLODs = new Array();
36
- this._nodeIndexLOD = null;
37
- this._nodeSignalLODs = new Array();
38
- this._nodePromiseLODs = new Array();
39
- this._nodeBufferLODs = new Array();
40
- this._materialIndexLOD = null;
41
- this._materialSignalLODs = new Array();
42
- this._materialPromiseLODs = new Array();
43
- this._materialBufferLODs = new Array();
44
- this._loader = loader;
45
- this.enabled = this._loader.isExtensionUsed(NAME);
46
- }
47
- /** @hidden */
48
- MSFT_lod.prototype.dispose = function () {
49
- this._loader = null;
50
- this._nodeIndexLOD = null;
51
- this._nodeSignalLODs.length = 0;
52
- this._nodePromiseLODs.length = 0;
53
- this._nodeBufferLODs.length = 0;
54
- this._materialIndexLOD = null;
55
- this._materialSignalLODs.length = 0;
56
- this._materialPromiseLODs.length = 0;
57
- this._materialBufferLODs.length = 0;
58
- this.onMaterialLODsLoadedObservable.clear();
59
- this.onNodeLODsLoadedObservable.clear();
60
- };
61
- /** @hidden */
62
- MSFT_lod.prototype.onReady = function () {
63
- var _this = this;
64
- var _loop_1 = function (indexLOD) {
65
- var promise = Promise.all(this_1._nodePromiseLODs[indexLOD]).then(function () {
66
- if (indexLOD !== 0) {
67
- _this._loader.endPerformanceCounter("Node LOD ".concat(indexLOD));
68
- _this._loader.log("Loaded node LOD ".concat(indexLOD));
69
- }
70
- _this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);
71
- if (indexLOD !== _this._nodePromiseLODs.length - 1) {
72
- _this._loader.startPerformanceCounter("Node LOD ".concat(indexLOD + 1));
73
- _this._loadBufferLOD(_this._nodeBufferLODs, indexLOD + 1);
74
- if (_this._nodeSignalLODs[indexLOD]) {
75
- _this._nodeSignalLODs[indexLOD].resolve();
76
- }
77
- }
78
- });
79
- this_1._loader._completePromises.push(promise);
80
- };
81
- var this_1 = this;
82
- for (var indexLOD = 0; indexLOD < this._nodePromiseLODs.length; indexLOD++) {
83
- _loop_1(indexLOD);
84
- }
85
- var _loop_2 = function (indexLOD) {
86
- var promise = Promise.all(this_2._materialPromiseLODs[indexLOD]).then(function () {
87
- if (indexLOD !== 0) {
88
- _this._loader.endPerformanceCounter("Material LOD ".concat(indexLOD));
89
- _this._loader.log("Loaded material LOD ".concat(indexLOD));
90
- }
91
- _this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);
92
- if (indexLOD !== _this._materialPromiseLODs.length - 1) {
93
- _this._loader.startPerformanceCounter("Material LOD ".concat(indexLOD + 1));
94
- _this._loadBufferLOD(_this._materialBufferLODs, indexLOD + 1);
95
- if (_this._materialSignalLODs[indexLOD]) {
96
- _this._materialSignalLODs[indexLOD].resolve();
97
- }
98
- }
99
- });
100
- this_2._loader._completePromises.push(promise);
101
- };
102
- var this_2 = this;
103
- for (var indexLOD = 0; indexLOD < this._materialPromiseLODs.length; indexLOD++) {
104
- _loop_2(indexLOD);
105
- }
106
- };
107
- /** @hidden */
108
- MSFT_lod.prototype.loadSceneAsync = function (context, scene) {
109
- var promise = this._loader.loadSceneAsync(context, scene);
110
- this._loadBufferLOD(this._bufferLODs, 0);
111
- return promise;
112
- };
113
- /** @hidden */
114
- MSFT_lod.prototype.loadNodeAsync = function (context, node, assign) {
115
- var _this = this;
116
- return GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) {
117
- var firstPromise;
118
- var nodeLODs = _this._getLODs(extensionContext, node, _this._loader.gltf.nodes, extension.ids);
119
- _this._loader.logOpen("".concat(extensionContext));
120
- var _loop_3 = function (indexLOD) {
121
- var nodeLOD = nodeLODs[indexLOD];
122
- if (indexLOD !== 0) {
123
- _this._nodeIndexLOD = indexLOD;
124
- _this._nodeSignalLODs[indexLOD] = _this._nodeSignalLODs[indexLOD] || new Deferred();
125
- }
126
- var assignWrap = function (babylonTransformNode) {
127
- assign(babylonTransformNode);
128
- babylonTransformNode.setEnabled(false);
129
- };
130
- var promise = _this._loader.loadNodeAsync("/nodes/".concat(nodeLOD.index), nodeLOD, assignWrap).then(function (babylonMesh) {
131
- if (indexLOD !== 0) {
132
- // TODO: should not rely on _babylonTransformNode
133
- var previousNodeLOD = nodeLODs[indexLOD - 1];
134
- if (previousNodeLOD._babylonTransformNode) {
135
- _this._disposeTransformNode(previousNodeLOD._babylonTransformNode);
136
- delete previousNodeLOD._babylonTransformNode;
137
- }
138
- }
139
- babylonMesh.setEnabled(true);
140
- return babylonMesh;
141
- });
142
- _this._nodePromiseLODs[indexLOD] = _this._nodePromiseLODs[indexLOD] || [];
143
- if (indexLOD === 0) {
144
- firstPromise = promise;
145
- }
146
- else {
147
- _this._nodeIndexLOD = null;
148
- _this._nodePromiseLODs[indexLOD].push(promise);
149
- }
150
- };
151
- for (var indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) {
152
- _loop_3(indexLOD);
153
- }
154
- _this._loader.logClose();
155
- return firstPromise;
156
- });
157
- };
158
- /** @hidden */
159
- MSFT_lod.prototype._loadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) {
160
- var _this = this;
161
- // Don't load material LODs if already loading a node LOD.
162
- if (this._nodeIndexLOD) {
163
- return null;
164
- }
165
- return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
166
- var firstPromise;
167
- var materialLODs = _this._getLODs(extensionContext, material, _this._loader.gltf.materials, extension.ids);
168
- _this._loader.logOpen("".concat(extensionContext));
169
- var _loop_4 = function (indexLOD) {
170
- var materialLOD = materialLODs[indexLOD];
171
- if (indexLOD !== 0) {
172
- _this._materialIndexLOD = indexLOD;
173
- }
174
- var promise = _this._loader._loadMaterialAsync("/materials/".concat(materialLOD.index), materialLOD, babylonMesh, babylonDrawMode, function (babylonMaterial) {
175
- if (indexLOD === 0) {
176
- assign(babylonMaterial);
177
- }
178
- }).then(function (babylonMaterial) {
179
- if (indexLOD !== 0) {
180
- assign(babylonMaterial);
181
- // TODO: should not rely on _data
182
- var previousDataLOD = materialLODs[indexLOD - 1]._data;
183
- if (previousDataLOD[babylonDrawMode]) {
184
- _this._disposeMaterials([previousDataLOD[babylonDrawMode].babylonMaterial]);
185
- delete previousDataLOD[babylonDrawMode];
186
- }
187
- }
188
- return babylonMaterial;
189
- });
190
- _this._materialPromiseLODs[indexLOD] = _this._materialPromiseLODs[indexLOD] || [];
191
- if (indexLOD === 0) {
192
- firstPromise = promise;
193
- }
194
- else {
195
- _this._materialIndexLOD = null;
196
- _this._materialPromiseLODs[indexLOD].push(promise);
197
- }
198
- };
199
- for (var indexLOD = 0; indexLOD < materialLODs.length; indexLOD++) {
200
- _loop_4(indexLOD);
201
- }
202
- _this._loader.logClose();
203
- return firstPromise;
204
- });
205
- };
206
- /** @hidden */
207
- MSFT_lod.prototype._loadUriAsync = function (context, property, uri) {
208
- var _this = this;
209
- // Defer the loading of uris if loading a node or material LOD.
210
- if (this._nodeIndexLOD !== null) {
211
- this._loader.log("deferred");
212
- var previousIndexLOD = this._nodeIndexLOD - 1;
213
- this._nodeSignalLODs[previousIndexLOD] = this._nodeSignalLODs[previousIndexLOD] || new Deferred();
214
- return this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(function () {
215
- return _this._loader.loadUriAsync(context, property, uri);
216
- });
217
- }
218
- else if (this._materialIndexLOD !== null) {
219
- this._loader.log("deferred");
220
- var previousIndexLOD = this._materialIndexLOD - 1;
221
- this._materialSignalLODs[previousIndexLOD] = this._materialSignalLODs[previousIndexLOD] || new Deferred();
222
- return this._materialSignalLODs[previousIndexLOD].promise.then(function () {
223
- return _this._loader.loadUriAsync(context, property, uri);
224
- });
225
- }
226
- return null;
227
- };
228
- /** @hidden */
229
- MSFT_lod.prototype.loadBufferAsync = function (context, buffer, byteOffset, byteLength) {
230
- if (this._loader.parent.useRangeRequests && !buffer.uri) {
231
- if (!this._loader.bin) {
232
- throw new Error("".concat(context, ": Uri is missing or the binary glTF is missing its binary chunk"));
233
- }
234
- var loadAsync = function (bufferLODs, indexLOD) {
235
- var start = byteOffset;
236
- var end = start + byteLength - 1;
237
- var bufferLOD = bufferLODs[indexLOD];
238
- if (bufferLOD) {
239
- bufferLOD.start = Math.min(bufferLOD.start, start);
240
- bufferLOD.end = Math.max(bufferLOD.end, end);
241
- }
242
- else {
243
- bufferLOD = { start: start, end: end, loaded: new Deferred() };
244
- bufferLODs[indexLOD] = bufferLOD;
245
- }
246
- return bufferLOD.loaded.promise.then(function (data) {
247
- return new Uint8Array(data.buffer, data.byteOffset + byteOffset - bufferLOD.start, byteLength);
248
- });
249
- };
250
- this._loader.log("deferred");
251
- if (this._nodeIndexLOD !== null) {
252
- return loadAsync(this._nodeBufferLODs, this._nodeIndexLOD);
253
- }
254
- else if (this._materialIndexLOD !== null) {
255
- return loadAsync(this._materialBufferLODs, this._materialIndexLOD);
256
- }
257
- else {
258
- return loadAsync(this._bufferLODs, 0);
259
- }
260
- }
261
- return null;
262
- };
263
- MSFT_lod.prototype._loadBufferLOD = function (bufferLODs, indexLOD) {
264
- var bufferLOD = bufferLODs[indexLOD];
265
- if (bufferLOD) {
266
- this._loader.log("Loading buffer range [".concat(bufferLOD.start, "-").concat(bufferLOD.end, "]"));
267
- this._loader.bin.readAsync(bufferLOD.start, bufferLOD.end - bufferLOD.start + 1).then(function (data) {
268
- bufferLOD.loaded.resolve(data);
269
- }, function (error) {
270
- bufferLOD.loaded.reject(error);
271
- });
272
- }
273
- };
274
- /**
275
- * Gets an array of LOD properties from lowest to highest.
276
- */
277
- MSFT_lod.prototype._getLODs = function (context, property, array, ids) {
278
- if (this.maxLODsToLoad <= 0) {
279
- throw new Error("maxLODsToLoad must be greater than zero");
280
- }
281
- var properties = new Array();
282
- for (var i = ids.length - 1; i >= 0; i--) {
283
- properties.push(ArrayItem.Get("".concat(context, "/ids/").concat(ids[i]), array, ids[i]));
284
- if (properties.length === this.maxLODsToLoad) {
285
- return properties;
286
- }
287
- }
288
- properties.push(property);
289
- return properties;
290
- };
291
- MSFT_lod.prototype._disposeTransformNode = function (babylonTransformNode) {
292
- var _this = this;
293
- var babylonMaterials = new Array();
294
- var babylonMaterial = babylonTransformNode.material;
295
- if (babylonMaterial) {
296
- babylonMaterials.push(babylonMaterial);
297
- }
298
- for (var _i = 0, _a = babylonTransformNode.getChildMeshes(); _i < _a.length; _i++) {
299
- var babylonMesh = _a[_i];
300
- if (babylonMesh.material) {
301
- babylonMaterials.push(babylonMesh.material);
302
- }
303
- }
304
- babylonTransformNode.dispose();
305
- var babylonMaterialsToDispose = babylonMaterials.filter(function (babylonMaterial) { return _this._loader.babylonScene.meshes.every(function (mesh) { return mesh.material != babylonMaterial; }); });
306
- this._disposeMaterials(babylonMaterialsToDispose);
307
- };
308
- MSFT_lod.prototype._disposeMaterials = function (babylonMaterials) {
309
- var babylonTextures = {};
310
- for (var _i = 0, babylonMaterials_1 = babylonMaterials; _i < babylonMaterials_1.length; _i++) {
311
- var babylonMaterial = babylonMaterials_1[_i];
312
- for (var _a = 0, _b = babylonMaterial.getActiveTextures(); _a < _b.length; _a++) {
313
- var babylonTexture = _b[_a];
314
- babylonTextures[babylonTexture.uniqueId] = babylonTexture;
315
- }
316
- babylonMaterial.dispose();
317
- }
318
- for (var uniqueId in babylonTextures) {
319
- for (var _c = 0, _d = this._loader.babylonScene.materials; _c < _d.length; _c++) {
320
- var babylonMaterial = _d[_c];
321
- if (babylonMaterial.hasTexture(babylonTextures[uniqueId])) {
322
- delete babylonTextures[uniqueId];
323
- }
324
- }
325
- }
326
- for (var uniqueId in babylonTextures) {
327
- babylonTextures[uniqueId].dispose();
328
- }
329
- };
330
- return MSFT_lod;
331
- }());
332
- export { MSFT_lod };
333
- GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_lod(loader); });
334
- //# sourceMappingURL=MSFT_lod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MSFT_lod.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts"],"names":[],"mappings":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C,CAAC;iBACpC;aACJ;SACJ;QAED,KAAK,IAAM,QAAQ,IAAI,eAAe,EAAE;YACpC,eAAe,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC;SACvC;IACL,CAAC;IACL,eAAC;AAAD,CAAC,AA3WD,IA2WC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,QAAQ,CAAC,MAAM,CAAC,EAApB,CAAoB,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { Observable } from \"@babylonjs/core/Misc/observable\";\nimport { Deferred } from \"@babylonjs/core/Misc/deferred\";\nimport { Material } from \"@babylonjs/core/Materials/material\";\nimport { TransformNode } from \"@babylonjs/core/Meshes/transformNode\";\nimport { Mesh } from \"@babylonjs/core/Meshes/mesh\";\nimport { BaseTexture } from \"@babylonjs/core/Materials/Textures/baseTexture\";\nimport { INode, IMaterial, IBuffer, IScene } from \"../glTFLoaderInterfaces\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\nimport { IProperty, IMSFTLOD } from \"babylonjs-gltf2interface\";\n\nconst NAME = \"MSFT_lod\";\n\ninterface IBufferInfo {\n start: number;\n end: number;\n loaded: Deferred<ArrayBufferView>;\n}\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)\n */\nexport class MSFT_lod implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n /**\n * Defines a number that determines the order the extensions are applied.\n */\n public order = 100;\n\n /**\n * Maximum number of LODs to load, starting from the lowest LOD.\n */\n public maxLODsToLoad = 10;\n\n /**\n * Observable raised when all node LODs of one level are loaded.\n * The event data is the index of the loaded LOD starting from zero.\n * Dispose the loader to cancel the loading of the next level of LODs.\n */\n public onNodeLODsLoadedObservable = new Observable<number>();\n\n /**\n * Observable raised when all material LODs of one level are loaded.\n * The event data is the index of the loaded LOD starting from zero.\n * Dispose the loader to cancel the loading of the next level of LODs.\n */\n public onMaterialLODsLoadedObservable = new Observable<number>();\n\n private _loader: GLTFLoader;\n\n private _bufferLODs = new Array<IBufferInfo>();\n\n private _nodeIndexLOD: Nullable<number> = null;\n private _nodeSignalLODs = new Array<Deferred<void>>();\n private _nodePromiseLODs = new Array<Array<Promise<any>>>();\n private _nodeBufferLODs = new Array<IBufferInfo>();\n\n private _materialIndexLOD: Nullable<number> = null;\n private _materialSignalLODs = new Array<Deferred<void>>();\n private _materialPromiseLODs = new Array<Array<Promise<any>>>();\n private _materialBufferLODs = new Array<IBufferInfo>();\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n\n this._nodeIndexLOD = null;\n this._nodeSignalLODs.length = 0;\n this._nodePromiseLODs.length = 0;\n this._nodeBufferLODs.length = 0;\n\n this._materialIndexLOD = null;\n this._materialSignalLODs.length = 0;\n this._materialPromiseLODs.length = 0;\n this._materialBufferLODs.length = 0;\n\n this.onMaterialLODsLoadedObservable.clear();\n this.onNodeLODsLoadedObservable.clear();\n }\n\n /** @hidden */\n public onReady(): void {\n for (let indexLOD = 0; indexLOD < this._nodePromiseLODs.length; indexLOD++) {\n const promise = Promise.all(this._nodePromiseLODs[indexLOD]).then(() => {\n if (indexLOD !== 0) {\n this._loader.endPerformanceCounter(`Node LOD ${indexLOD}`);\n this._loader.log(`Loaded node LOD ${indexLOD}`);\n }\n\n this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);\n\n if (indexLOD !== this._nodePromiseLODs.length - 1) {\n this._loader.startPerformanceCounter(`Node LOD ${indexLOD + 1}`);\n this._loadBufferLOD(this._nodeBufferLODs, indexLOD + 1);\n if (this._nodeSignalLODs[indexLOD]) {\n this._nodeSignalLODs[indexLOD].resolve();\n }\n }\n });\n\n this._loader._completePromises.push(promise);\n }\n\n for (let indexLOD = 0; indexLOD < this._materialPromiseLODs.length; indexLOD++) {\n const promise = Promise.all(this._materialPromiseLODs[indexLOD]).then(() => {\n if (indexLOD !== 0) {\n this._loader.endPerformanceCounter(`Material LOD ${indexLOD}`);\n this._loader.log(`Loaded material LOD ${indexLOD}`);\n }\n\n this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);\n\n if (indexLOD !== this._materialPromiseLODs.length - 1) {\n this._loader.startPerformanceCounter(`Material LOD ${indexLOD + 1}`);\n this._loadBufferLOD(this._materialBufferLODs, indexLOD + 1);\n if (this._materialSignalLODs[indexLOD]) {\n this._materialSignalLODs[indexLOD].resolve();\n }\n }\n });\n\n this._loader._completePromises.push(promise);\n }\n }\n\n /** @hidden */\n public loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>> {\n const promise = this._loader.loadSceneAsync(context, scene);\n this._loadBufferLOD(this._bufferLODs, 0);\n return promise;\n }\n\n /** @hidden */\n public loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>> {\n return GLTFLoader.LoadExtensionAsync<IMSFTLOD, TransformNode>(context, node, this.name, (extensionContext, extension) => {\n let firstPromise: Promise<TransformNode>;\n\n const nodeLODs = this._getLODs(extensionContext, node, this._loader.gltf.nodes, extension.ids);\n this._loader.logOpen(`${extensionContext}`);\n\n for (let indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) {\n const nodeLOD = nodeLODs[indexLOD];\n\n if (indexLOD !== 0) {\n this._nodeIndexLOD = indexLOD;\n this._nodeSignalLODs[indexLOD] = this._nodeSignalLODs[indexLOD] || new Deferred();\n }\n\n const assignWrap = (babylonTransformNode: TransformNode) => {\n assign(babylonTransformNode);\n babylonTransformNode.setEnabled(false);\n };\n\n const promise = this._loader.loadNodeAsync(`/nodes/${nodeLOD.index}`, nodeLOD, assignWrap).then((babylonMesh) => {\n if (indexLOD !== 0) {\n // TODO: should not rely on _babylonTransformNode\n const previousNodeLOD = nodeLODs[indexLOD - 1];\n if (previousNodeLOD._babylonTransformNode) {\n this._disposeTransformNode(previousNodeLOD._babylonTransformNode);\n delete previousNodeLOD._babylonTransformNode;\n }\n }\n\n babylonMesh.setEnabled(true);\n return babylonMesh;\n });\n\n this._nodePromiseLODs[indexLOD] = this._nodePromiseLODs[indexLOD] || [];\n\n if (indexLOD === 0) {\n firstPromise = promise;\n } else {\n this._nodeIndexLOD = null;\n this._nodePromiseLODs[indexLOD].push(promise);\n }\n }\n\n this._loader.logClose();\n return firstPromise!;\n });\n }\n\n /** @hidden */\n public _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>> {\n // Don't load material LODs if already loading a node LOD.\n if (this._nodeIndexLOD) {\n return null;\n }\n\n return GLTFLoader.LoadExtensionAsync<IMSFTLOD, Material>(context, material, this.name, (extensionContext, extension) => {\n let firstPromise: Promise<Material>;\n\n const materialLODs = this._getLODs(extensionContext, material, this._loader.gltf.materials, extension.ids);\n this._loader.logOpen(`${extensionContext}`);\n\n for (let indexLOD = 0; indexLOD < materialLODs.length; indexLOD++) {\n const materialLOD = materialLODs[indexLOD];\n\n if (indexLOD !== 0) {\n this._materialIndexLOD = indexLOD;\n }\n\n const promise = this._loader._loadMaterialAsync(`/materials/${materialLOD.index}`, materialLOD, babylonMesh, babylonDrawMode, (babylonMaterial) => {\n if (indexLOD === 0) {\n assign(babylonMaterial);\n }\n }).then((babylonMaterial) => {\n if (indexLOD !== 0) {\n assign(babylonMaterial);\n\n // TODO: should not rely on _data\n const previousDataLOD = materialLODs[indexLOD - 1]._data!;\n if (previousDataLOD[babylonDrawMode]) {\n this._disposeMaterials([previousDataLOD[babylonDrawMode].babylonMaterial]);\n delete previousDataLOD[babylonDrawMode];\n }\n }\n\n return babylonMaterial;\n });\n\n this._materialPromiseLODs[indexLOD] = this._materialPromiseLODs[indexLOD] || [];\n\n if (indexLOD === 0) {\n firstPromise = promise;\n } else {\n this._materialIndexLOD = null;\n this._materialPromiseLODs[indexLOD].push(promise);\n }\n }\n\n this._loader.logClose();\n return firstPromise!;\n });\n }\n\n /** @hidden */\n public _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>> {\n // Defer the loading of uris if loading a node or material LOD.\n if (this._nodeIndexLOD !== null) {\n this._loader.log(`deferred`);\n const previousIndexLOD = this._nodeIndexLOD - 1;\n this._nodeSignalLODs[previousIndexLOD] = this._nodeSignalLODs[previousIndexLOD] || new Deferred<void>();\n return this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(() => {\n return this._loader.loadUriAsync(context, property, uri);\n });\n } else if (this._materialIndexLOD !== null) {\n this._loader.log(`deferred`);\n const previousIndexLOD = this._materialIndexLOD - 1;\n this._materialSignalLODs[previousIndexLOD] = this._materialSignalLODs[previousIndexLOD] || new Deferred<void>();\n return this._materialSignalLODs[previousIndexLOD].promise.then(() => {\n return this._loader.loadUriAsync(context, property, uri);\n });\n }\n\n return null;\n }\n\n /** @hidden */\n public loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>> {\n if (this._loader.parent.useRangeRequests && !buffer.uri) {\n if (!this._loader.bin) {\n throw new Error(`${context}: Uri is missing or the binary glTF is missing its binary chunk`);\n }\n\n const loadAsync = (bufferLODs: Array<IBufferInfo>, indexLOD: number) => {\n const start = byteOffset;\n const end = start + byteLength - 1;\n let bufferLOD = bufferLODs[indexLOD];\n if (bufferLOD) {\n bufferLOD.start = Math.min(bufferLOD.start, start);\n bufferLOD.end = Math.max(bufferLOD.end, end);\n } else {\n bufferLOD = { start: start, end: end, loaded: new Deferred() };\n bufferLODs[indexLOD] = bufferLOD;\n }\n\n return bufferLOD.loaded.promise.then((data) => {\n return new Uint8Array(data.buffer, data.byteOffset + byteOffset - bufferLOD.start, byteLength);\n });\n };\n\n this._loader.log(`deferred`);\n\n if (this._nodeIndexLOD !== null) {\n return loadAsync(this._nodeBufferLODs, this._nodeIndexLOD);\n } else if (this._materialIndexLOD !== null) {\n return loadAsync(this._materialBufferLODs, this._materialIndexLOD);\n } else {\n return loadAsync(this._bufferLODs, 0);\n }\n }\n\n return null;\n }\n\n private _loadBufferLOD(bufferLODs: Array<IBufferInfo>, indexLOD: number): void {\n const bufferLOD = bufferLODs[indexLOD];\n if (bufferLOD) {\n this._loader.log(`Loading buffer range [${bufferLOD.start}-${bufferLOD.end}]`);\n this._loader.bin!.readAsync(bufferLOD.start, bufferLOD.end - bufferLOD.start + 1).then((data) => {\n bufferLOD.loaded.resolve(data);\n }, (error) => {\n bufferLOD.loaded.reject(error);\n });\n }\n }\n\n /**\n * Gets an array of LOD properties from lowest to highest.\n */\n private _getLODs<T>(context: string, property: T, array: ArrayLike<T> | undefined, ids: number[]): T[] {\n if (this.maxLODsToLoad <= 0) {\n throw new Error(\"maxLODsToLoad must be greater than zero\");\n }\n\n const properties = new Array<T>();\n\n for (let i = ids.length - 1; i >= 0; i--) {\n properties.push(ArrayItem.Get(`${context}/ids/${ids[i]}`, array, ids[i]));\n if (properties.length === this.maxLODsToLoad) {\n return properties;\n }\n }\n\n properties.push(property);\n return properties;\n }\n\n private _disposeTransformNode(babylonTransformNode: TransformNode): void {\n const babylonMaterials = new Array<Material>();\n const babylonMaterial = (babylonTransformNode as Mesh).material;\n if (babylonMaterial) {\n babylonMaterials.push(babylonMaterial);\n }\n for (const babylonMesh of babylonTransformNode.getChildMeshes()) {\n if (babylonMesh.material) {\n babylonMaterials.push(babylonMesh.material);\n }\n }\n\n babylonTransformNode.dispose();\n\n const babylonMaterialsToDispose = babylonMaterials.filter((babylonMaterial) => this._loader.babylonScene.meshes.every((mesh) => mesh.material != babylonMaterial));\n this._disposeMaterials(babylonMaterialsToDispose);\n }\n\n private _disposeMaterials(babylonMaterials: Material[]): void {\n const babylonTextures: { [uniqueId: number]: BaseTexture } = {};\n\n for (const babylonMaterial of babylonMaterials) {\n for (const babylonTexture of babylonMaterial.getActiveTextures()) {\n babylonTextures[babylonTexture.uniqueId] = babylonTexture;\n }\n\n babylonMaterial.dispose();\n }\n\n for (const uniqueId in babylonTextures) {\n for (const babylonMaterial of this._loader.babylonScene.materials) {\n if (babylonMaterial.hasTexture(babylonTextures[uniqueId])) {\n delete babylonTextures[uniqueId];\n }\n }\n }\n\n for (const uniqueId in babylonTextures) {\n babylonTextures[uniqueId].dispose();\n }\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new MSFT_lod(loader));\n"]}
@@ -1,14 +0,0 @@
1
- import { Nullable } from "@babylonjs/core/types";
2
- import { Material } from "@babylonjs/core/Materials/material";
3
- import { IMaterial } from "../glTFLoaderInterfaces";
4
- import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
5
- import { GLTFLoader } from "../glTFLoader";
6
- /** @hidden */
7
- export declare class MSFT_minecraftMesh implements IGLTFLoaderExtension {
8
- readonly name = "MSFT_minecraftMesh";
9
- enabled: boolean;
10
- private _loader;
11
- constructor(loader: GLTFLoader);
12
- dispose(): void;
13
- loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
14
- }
@@ -1,37 +0,0 @@
1
- import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
2
- import { GLTFLoader } from "../glTFLoader.js";
3
- var NAME = "MSFT_minecraftMesh";
4
- /** @hidden */
5
- var MSFT_minecraftMesh = /** @class */ (function () {
6
- function MSFT_minecraftMesh(loader) {
7
- this.name = NAME;
8
- this._loader = loader;
9
- this.enabled = this._loader.isExtensionUsed(NAME);
10
- }
11
- MSFT_minecraftMesh.prototype.dispose = function () {
12
- this._loader = null;
13
- };
14
- MSFT_minecraftMesh.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
15
- var _this = this;
16
- return GLTFLoader.LoadExtraAsync(context, material, this.name, function (extraContext, extra) {
17
- if (extra) {
18
- if (!(babylonMaterial instanceof PBRMaterial)) {
19
- throw new Error("".concat(extraContext, ": Material type not supported"));
20
- }
21
- var promise = _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial);
22
- if (babylonMaterial.needAlphaBlending()) {
23
- babylonMaterial.forceDepthWrite = true;
24
- babylonMaterial.separateCullingPass = true;
25
- }
26
- babylonMaterial.backFaceCulling = babylonMaterial.forceDepthWrite;
27
- babylonMaterial.twoSidedLighting = true;
28
- return promise;
29
- }
30
- return null;
31
- });
32
- };
33
- return MSFT_minecraftMesh;
34
- }());
35
- export { MSFT_minecraftMesh };
36
- GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_minecraftMesh(loader); });
37
- //# sourceMappingURL=MSFT_minecraftMesh.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MSFT_minecraftMesh.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAIxE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,IAAM,IAAI,GAAG,oBAAoB,CAAC;AAElC,cAAc;AACd;IAMI,4BAAY,MAAkB;QALd,SAAI,GAAG,IAAI,CAAC;QAMxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAEM,oCAAO,GAAd;QACK,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAEM,wDAA2B,GAAlC,UAAmC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAAlG,iBAsBC;QArBG,OAAO,UAAU,CAAC,cAAc,CAAU,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,UAAC,YAAY,EAAE,KAAK;YACxF,IAAI,KAAK,EAAE;gBACP,IAAI,CAAC,CAAC,eAAe,YAAY,WAAW,CAAC,EAAE;oBAC3C,MAAM,IAAI,KAAK,CAAC,UAAG,YAAY,kCAA+B,CAAC,CAAC;iBACnE;gBAED,IAAM,OAAO,GAAG,KAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;gBAE7F,IAAI,eAAe,CAAC,iBAAiB,EAAE,EAAE;oBACrC,eAAe,CAAC,eAAe,GAAG,IAAI,CAAC;oBACvC,eAAe,CAAC,mBAAmB,GAAG,IAAI,CAAC;iBAC9C;gBAED,eAAe,CAAC,eAAe,GAAG,eAAe,CAAC,eAAe,CAAC;gBAClE,eAAe,CAAC,gBAAgB,GAAG,IAAI,CAAC;gBAExC,OAAO,OAAO,CAAC;aAClB;YAED,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;IACL,yBAAC;AAAD,CAAC,AAtCD,IAsCC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAA9B,CAA8B,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\r\nimport { Material } from \"@babylonjs/core/Materials/material\";\r\nimport { PBRMaterial } from \"@babylonjs/core/Materials/PBR/pbrMaterial\";\r\n\r\nimport { IMaterial } from \"../glTFLoaderInterfaces\";\r\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\n\r\nconst NAME = \"MSFT_minecraftMesh\";\r\n\r\n/** @hidden */\r\nexport class MSFT_minecraftMesh implements IGLTFLoaderExtension {\r\n public readonly name = NAME;\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtraAsync<boolean>(context, material, this.name, (extraContext, extra) => {\r\n if (extra) {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${extraContext}: Material type not supported`);\r\n }\r\n\r\n const promise = this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial);\r\n\r\n if (babylonMaterial.needAlphaBlending()) {\r\n babylonMaterial.forceDepthWrite = true;\r\n babylonMaterial.separateCullingPass = true;\r\n }\r\n\r\n babylonMaterial.backFaceCulling = babylonMaterial.forceDepthWrite;\r\n babylonMaterial.twoSidedLighting = true;\r\n\r\n return promise;\r\n }\r\n\r\n return null;\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new MSFT_minecraftMesh(loader));"]}
@@ -1,14 +0,0 @@
1
- import { Nullable } from "@babylonjs/core/types";
2
- import { Material } from "@babylonjs/core/Materials/material";
3
- import { IMaterial } from "../glTFLoaderInterfaces";
4
- import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
5
- import { GLTFLoader } from "../glTFLoader";
6
- /** @hidden */
7
- export declare class MSFT_sRGBFactors implements IGLTFLoaderExtension {
8
- readonly name = "MSFT_sRGBFactors";
9
- enabled: boolean;
10
- private _loader;
11
- constructor(loader: GLTFLoader);
12
- dispose(): void;
13
- loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
14
- }
@@ -1,37 +0,0 @@
1
- import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
2
- import { GLTFLoader } from "../glTFLoader.js";
3
- var NAME = "MSFT_sRGBFactors";
4
- /** @hidden */
5
- var MSFT_sRGBFactors = /** @class */ (function () {
6
- function MSFT_sRGBFactors(loader) {
7
- this.name = NAME;
8
- this._loader = loader;
9
- this.enabled = this._loader.isExtensionUsed(NAME);
10
- }
11
- MSFT_sRGBFactors.prototype.dispose = function () {
12
- this._loader = null;
13
- };
14
- MSFT_sRGBFactors.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
15
- var _this = this;
16
- return GLTFLoader.LoadExtraAsync(context, material, this.name, function (extraContext, extra) {
17
- if (extra) {
18
- if (!(babylonMaterial instanceof PBRMaterial)) {
19
- throw new Error("".concat(extraContext, ": Material type not supported"));
20
- }
21
- var promise = _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial);
22
- if (!babylonMaterial.albedoTexture) {
23
- babylonMaterial.albedoColor.toLinearSpaceToRef(babylonMaterial.albedoColor);
24
- }
25
- if (!babylonMaterial.reflectivityTexture) {
26
- babylonMaterial.reflectivityColor.toLinearSpaceToRef(babylonMaterial.reflectivityColor);
27
- }
28
- return promise;
29
- }
30
- return null;
31
- });
32
- };
33
- return MSFT_sRGBFactors;
34
- }());
35
- export { MSFT_sRGBFactors };
36
- GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_sRGBFactors(loader); });
37
- //# sourceMappingURL=MSFT_sRGBFactors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MSFT_sRGBFactors.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAIxE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,IAAM,IAAI,GAAG,kBAAkB,CAAC;AAEhC,cAAc;AACd;IAMI,0BAAY,MAAkB;QALd,SAAI,GAAG,IAAI,CAAC;QAMxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAEM,kCAAO,GAAd;QACK,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAEM,sDAA2B,GAAlC,UAAmC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAAlG,iBAsBC;QArBG,OAAO,UAAU,CAAC,cAAc,CAAU,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,UAAC,YAAY,EAAE,KAAK;YACxF,IAAI,KAAK,EAAE;gBACP,IAAI,CAAC,CAAC,eAAe,YAAY,WAAW,CAAC,EAAE;oBAC3C,MAAM,IAAI,KAAK,CAAC,UAAG,YAAY,kCAA+B,CAAC,CAAC;iBACnE;gBAED,IAAM,OAAO,GAAG,KAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;gBAE7F,IAAI,CAAC,eAAe,CAAC,aAAa,EAAE;oBAChC,eAAe,CAAC,WAAW,CAAC,kBAAkB,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;iBAC/E;gBAED,IAAI,CAAC,eAAe,CAAC,mBAAmB,EAAE;oBACtC,eAAe,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;iBAC3F;gBAED,OAAO,OAAO,CAAC;aAClB;YAED,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;IACL,uBAAC;AAAD,CAAC,AAtCD,IAsCC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAA5B,CAA4B,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\r\nimport { Material } from \"@babylonjs/core/Materials/material\";\r\nimport { PBRMaterial } from \"@babylonjs/core/Materials/PBR/pbrMaterial\";\r\n\r\nimport { IMaterial } from \"../glTFLoaderInterfaces\";\r\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\n\r\nconst NAME = \"MSFT_sRGBFactors\";\r\n\r\n/** @hidden */\r\nexport class MSFT_sRGBFactors implements IGLTFLoaderExtension {\r\n public readonly name = NAME;\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtraAsync<boolean>(context, material, this.name, (extraContext, extra) => {\r\n if (extra) {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${extraContext}: Material type not supported`);\r\n }\r\n\r\n const promise = this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial);\r\n\r\n if (!babylonMaterial.albedoTexture) {\r\n babylonMaterial.albedoColor.toLinearSpaceToRef(babylonMaterial.albedoColor);\r\n }\r\n\r\n if (!babylonMaterial.reflectivityTexture) {\r\n babylonMaterial.reflectivityColor.toLinearSpaceToRef(babylonMaterial.reflectivityColor);\r\n }\r\n\r\n return promise;\r\n }\r\n\r\n return null;\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new MSFT_sRGBFactors(loader));"]}
@@ -1,26 +0,0 @@
1
- export * from "./EXT_lights_image_based";
2
- export * from "./EXT_mesh_gpu_instancing";
3
- export * from "./EXT_meshopt_compression";
4
- export * from "./EXT_texture_webp";
5
- export * from "./KHR_draco_mesh_compression";
6
- export * from "./KHR_lights_punctual";
7
- export * from "./KHR_materials_pbrSpecularGlossiness";
8
- export * from "./KHR_materials_unlit";
9
- export * from "./KHR_materials_clearcoat";
10
- export * from "./KHR_materials_emissive_strength";
11
- export * from "./KHR_materials_sheen";
12
- export * from "./KHR_materials_specular";
13
- export * from "./KHR_materials_ior";
14
- export * from "./KHR_materials_variants";
15
- export * from "./KHR_materials_transmission";
16
- export * from "./KHR_materials_translucency";
17
- export * from "./KHR_materials_volume";
18
- export * from "./KHR_mesh_quantization";
19
- export * from "./KHR_texture_basisu";
20
- export * from "./KHR_texture_transform";
21
- export * from "./KHR_xmp_json_ld";
22
- export * from "./MSFT_audio_emitter";
23
- export * from "./MSFT_lod";
24
- export * from "./MSFT_minecraftMesh";
25
- export * from "./MSFT_sRGBFactors";
26
- export * from "./ExtrasAsMetadata";
@@ -1,27 +0,0 @@
1
- export * from "./EXT_lights_image_based.js";
2
- export * from "./EXT_mesh_gpu_instancing.js";
3
- export * from "./EXT_meshopt_compression.js";
4
- export * from "./EXT_texture_webp.js";
5
- export * from "./KHR_draco_mesh_compression.js";
6
- export * from "./KHR_lights_punctual.js";
7
- export * from "./KHR_materials_pbrSpecularGlossiness.js";
8
- export * from "./KHR_materials_unlit.js";
9
- export * from "./KHR_materials_clearcoat.js";
10
- export * from "./KHR_materials_emissive_strength.js";
11
- export * from "./KHR_materials_sheen.js";
12
- export * from "./KHR_materials_specular.js";
13
- export * from "./KHR_materials_ior.js";
14
- export * from "./KHR_materials_variants.js";
15
- export * from "./KHR_materials_transmission.js";
16
- export * from "./KHR_materials_translucency.js";
17
- export * from "./KHR_materials_volume.js";
18
- export * from "./KHR_mesh_quantization.js";
19
- export * from "./KHR_texture_basisu.js";
20
- export * from "./KHR_texture_transform.js";
21
- export * from "./KHR_xmp_json_ld.js";
22
- export * from "./MSFT_audio_emitter.js";
23
- export * from "./MSFT_lod.js";
24
- export * from "./MSFT_minecraftMesh.js";
25
- export * from "./MSFT_sRGBFactors.js";
26
- export * from "./ExtrasAsMetadata.js";
27
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./EXT_lights_image_based\";\r\nexport * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./EXT_meshopt_compression\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_pbrSpecularGlossiness\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_emissive_strength\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_variants\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_translucency\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_mesh_quantization\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_xmp_json_ld\";\r\nexport * from \"./MSFT_audio_emitter\";\r\nexport * from \"./MSFT_lod\";\r\nexport * from \"./MSFT_minecraftMesh\";\r\nexport * from \"./MSFT_sRGBFactors\";\r\nexport * from \"./ExtrasAsMetadata\";\r\n"]}