@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.
- package/OBJ/index.d.ts +4 -4
- package/OBJ/index.js +4 -4
- package/OBJ/index.js.map +1 -1
- package/OBJ/mtlFileLoader.d.ts +41 -40
- package/OBJ/mtlFileLoader.js +232 -231
- package/OBJ/mtlFileLoader.js.map +1 -1
- package/OBJ/objFileLoader.d.ts +126 -133
- package/OBJ/objFileLoader.js +296 -300
- package/OBJ/objFileLoader.js.map +1 -1
- package/OBJ/objLoadingOptions.d.ts +43 -43
- package/OBJ/objLoadingOptions.js +1 -1
- package/OBJ/objLoadingOptions.js.map +1 -1
- package/OBJ/solidParser.d.ts +154 -153
- package/OBJ/solidParser.js +693 -699
- package/OBJ/solidParser.js.map +1 -1
- package/STL/index.d.ts +1 -1
- package/STL/index.js +1 -1
- package/STL/index.js.map +1 -1
- package/STL/stlFileLoader.d.ts +64 -71
- package/STL/stlFileLoader.js +233 -239
- package/STL/stlFileLoader.js.map +1 -1
- package/glTF/1.0/glTFBinaryExtension.d.ts +13 -13
- package/glTF/1.0/glTFBinaryExtension.js +60 -61
- package/glTF/1.0/glTFBinaryExtension.js.map +1 -1
- package/glTF/1.0/glTFLoader.d.ts +136 -106
- package/glTF/1.0/glTFLoader.js +1814 -1696
- package/glTF/1.0/glTFLoader.js.map +1 -1
- package/glTF/1.0/glTFLoaderInterfaces.d.ts +412 -412
- package/glTF/1.0/glTFLoaderInterfaces.js +95 -95
- package/glTF/1.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/1.0/glTFLoaderUtils.d.ts +63 -62
- package/glTF/1.0/glTFLoaderUtils.js +250 -232
- package/glTF/1.0/glTFLoaderUtils.js.map +1 -1
- package/glTF/1.0/glTFMaterialsCommonExtension.d.ts +10 -10
- package/glTF/1.0/glTFMaterialsCommonExtension.js +129 -127
- package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -1
- package/glTF/1.0/index.d.ts +5 -5
- package/glTF/1.0/index.js +5 -5
- package/glTF/1.0/index.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_lights_image_based.d.ts +43 -36
- package/glTF/2.0/Extensions/EXT_lights_image_based.js +117 -110
- package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +36 -28
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +88 -80
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +34 -27
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js +49 -42
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +29 -21
- package/glTF/2.0/Extensions/EXT_texture_webp.js +40 -32
- package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
- package/glTF/2.0/Extensions/ExtrasAsMetadata.d.ts +50 -32
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js +73 -55
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +39 -31
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +112 -101
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +36 -28
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +89 -81
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +39 -31
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +94 -86
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +38 -30
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +53 -45
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +42 -34
- package/glTF/2.0/Extensions/KHR_materials_ior.js +62 -54
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.d.ts +38 -30
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +80 -72
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +39 -31
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +84 -76
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +38 -30
- package/glTF/2.0/Extensions/KHR_materials_specular.js +74 -66
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_translucency.d.ts +39 -31
- package/glTF/2.0/Extensions/KHR_materials_translucency.js +83 -76
- package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +38 -30
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +288 -277
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +38 -30
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +73 -65
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_variants.d.ts +87 -76
- package/glTF/2.0/Extensions/KHR_materials_variants.js +254 -243
- package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +39 -31
- package/glTF/2.0/Extensions/KHR_materials_volume.js +85 -78
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_mesh_quantization.d.ts +22 -19
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js +23 -21
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +29 -21
- package/glTF/2.0/Extensions/KHR_texture_basisu.js +40 -32
- package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +33 -25
- package/glTF/2.0/Extensions/KHR_texture_transform.js +61 -53
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +32 -29
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +49 -46
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_audio_emitter.d.ts +54 -38
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js +240 -216
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_lod.d.ts +109 -75
- package/glTF/2.0/Extensions/MSFT_lod.js +369 -333
- package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.d.ts +14 -14
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +36 -36
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +14 -14
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +36 -36
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
- package/glTF/2.0/Extensions/index.d.ts +26 -26
- package/glTF/2.0/Extensions/index.js +26 -26
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/glTFLoader.d.ts +406 -357
- package/glTF/2.0/glTFLoader.js +2366 -2266
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/2.0/glTFLoaderExtension.d.ts +152 -152
- package/glTF/2.0/glTFLoaderExtension.js +1 -1
- package/glTF/2.0/glTFLoaderExtension.js.map +1 -1
- package/glTF/2.0/glTFLoaderInterfaces.d.ts +211 -209
- package/glTF/2.0/glTFLoaderInterfaces.js +1 -1
- package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/2.0/index.d.ts +4 -4
- package/glTF/2.0/index.js +5 -4
- package/glTF/2.0/index.js.map +1 -1
- package/glTF/glTFFileLoader.d.ts +433 -373
- package/glTF/glTFFileLoader.js +927 -870
- package/glTF/glTFFileLoader.js.map +1 -1
- package/glTF/glTFValidation.d.ts +29 -29
- package/glTF/glTFValidation.js +123 -121
- package/glTF/glTFValidation.js.map +1 -1
- package/glTF/index.d.ts +5 -5
- package/glTF/index.js +6 -5
- package/glTF/index.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +4 -3
- package/index.js.map +1 -1
- package/legacy/legacy-glTF.d.ts +2 -2
- package/legacy/legacy-glTF.js +18 -18
- package/legacy/legacy-glTF.js.map +1 -1
- package/legacy/legacy-glTF1.d.ts +2 -2
- package/legacy/legacy-glTF1.js +15 -14
- package/legacy/legacy-glTF1.js.map +1 -1
- package/legacy/legacy-glTF1FileLoader.d.ts +2 -2
- package/legacy/legacy-glTF1FileLoader.js +3 -2
- package/legacy/legacy-glTF1FileLoader.js.map +1 -1
- package/legacy/legacy-glTF2.d.ts +2 -2
- package/legacy/legacy-glTF2.js +33 -32
- package/legacy/legacy-glTF2.js.map +1 -1
- package/legacy/legacy-glTF2FileLoader.d.ts +2 -2
- package/legacy/legacy-glTF2FileLoader.js +3 -2
- package/legacy/legacy-glTF2FileLoader.js.map +1 -1
- package/legacy/legacy-glTFFileLoader.d.ts +3 -3
- package/legacy/legacy-glTFFileLoader.js +4 -3
- package/legacy/legacy-glTFFileLoader.js.map +1 -1
- package/legacy/legacy-objFileLoader.d.ts +1 -1
- package/legacy/legacy-objFileLoader.js +13 -12
- package/legacy/legacy-objFileLoader.js.map +1 -1
- package/legacy/legacy-stlFileLoader.d.ts +1 -1
- package/legacy/legacy-stlFileLoader.js +13 -12
- package/legacy/legacy-stlFileLoader.js.map +1 -1
- package/legacy/legacy.d.ts +6 -6
- package/legacy/legacy.js +8 -6
- package/legacy/legacy.js.map +1 -1
- package/license.md +71 -0
- package/package.json +37 -193
- package/readme.md +2 -2
@@ -1,334 +1,370 @@
|
|
1
|
-
import { Observable } from "@babylonjs/core/Misc/observable.js";
|
2
|
-
import { Deferred } from "@babylonjs/core/Misc/deferred.js";
|
3
|
-
import { GLTFLoader, ArrayItem } from "../glTFLoader
|
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
|
-
/**
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
this.
|
38
|
-
this.
|
39
|
-
this.
|
40
|
-
this.
|
41
|
-
this.
|
42
|
-
this.
|
43
|
-
this.
|
44
|
-
this.
|
45
|
-
this.
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
this.
|
53
|
-
this.
|
54
|
-
this.
|
55
|
-
this.
|
56
|
-
this.
|
57
|
-
this.
|
58
|
-
this.
|
59
|
-
this.
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
var
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
}
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
var
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
}
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
bufferLOD
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
for (var
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
1
|
+
import { Observable } from "@babylonjs/core/Misc/observable.js";
|
2
|
+
import { Deferred } from "@babylonjs/core/Misc/deferred.js";
|
3
|
+
import { GLTFLoader, ArrayItem } from "../glTFLoader";
|
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
|
+
/**
|
10
|
+
* @param loader
|
11
|
+
* @hidden
|
12
|
+
*/
|
13
|
+
function MSFT_lod(loader) {
|
14
|
+
/**
|
15
|
+
* The name of this extension.
|
16
|
+
*/
|
17
|
+
this.name = NAME;
|
18
|
+
/**
|
19
|
+
* Defines a number that determines the order the extensions are applied.
|
20
|
+
*/
|
21
|
+
this.order = 100;
|
22
|
+
/**
|
23
|
+
* Maximum number of LODs to load, starting from the lowest LOD.
|
24
|
+
*/
|
25
|
+
this.maxLODsToLoad = 10;
|
26
|
+
/**
|
27
|
+
* Observable raised when all node LODs of one level are loaded.
|
28
|
+
* The event data is the index of the loaded LOD starting from zero.
|
29
|
+
* Dispose the loader to cancel the loading of the next level of LODs.
|
30
|
+
*/
|
31
|
+
this.onNodeLODsLoadedObservable = new Observable();
|
32
|
+
/**
|
33
|
+
* Observable raised when all material LODs of one level are loaded.
|
34
|
+
* The event data is the index of the loaded LOD starting from zero.
|
35
|
+
* Dispose the loader to cancel the loading of the next level of LODs.
|
36
|
+
*/
|
37
|
+
this.onMaterialLODsLoadedObservable = new Observable();
|
38
|
+
this._bufferLODs = new Array();
|
39
|
+
this._nodeIndexLOD = null;
|
40
|
+
this._nodeSignalLODs = new Array();
|
41
|
+
this._nodePromiseLODs = new Array();
|
42
|
+
this._nodeBufferLODs = new Array();
|
43
|
+
this._materialIndexLOD = null;
|
44
|
+
this._materialSignalLODs = new Array();
|
45
|
+
this._materialPromiseLODs = new Array();
|
46
|
+
this._materialBufferLODs = new Array();
|
47
|
+
this._loader = loader;
|
48
|
+
this.enabled = this._loader.isExtensionUsed(NAME);
|
49
|
+
}
|
50
|
+
/** @hidden */
|
51
|
+
MSFT_lod.prototype.dispose = function () {
|
52
|
+
this._loader = null;
|
53
|
+
this._nodeIndexLOD = null;
|
54
|
+
this._nodeSignalLODs.length = 0;
|
55
|
+
this._nodePromiseLODs.length = 0;
|
56
|
+
this._nodeBufferLODs.length = 0;
|
57
|
+
this._materialIndexLOD = null;
|
58
|
+
this._materialSignalLODs.length = 0;
|
59
|
+
this._materialPromiseLODs.length = 0;
|
60
|
+
this._materialBufferLODs.length = 0;
|
61
|
+
this.onMaterialLODsLoadedObservable.clear();
|
62
|
+
this.onNodeLODsLoadedObservable.clear();
|
63
|
+
};
|
64
|
+
/** @hidden */
|
65
|
+
MSFT_lod.prototype.onReady = function () {
|
66
|
+
var _this = this;
|
67
|
+
var _loop_1 = function (indexLOD) {
|
68
|
+
var promise = Promise.all(this_1._nodePromiseLODs[indexLOD]).then(function () {
|
69
|
+
if (indexLOD !== 0) {
|
70
|
+
_this._loader.endPerformanceCounter("Node LOD ".concat(indexLOD));
|
71
|
+
_this._loader.log("Loaded node LOD ".concat(indexLOD));
|
72
|
+
}
|
73
|
+
_this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);
|
74
|
+
if (indexLOD !== _this._nodePromiseLODs.length - 1) {
|
75
|
+
_this._loader.startPerformanceCounter("Node LOD ".concat(indexLOD + 1));
|
76
|
+
_this._loadBufferLOD(_this._nodeBufferLODs, indexLOD + 1);
|
77
|
+
if (_this._nodeSignalLODs[indexLOD]) {
|
78
|
+
_this._nodeSignalLODs[indexLOD].resolve();
|
79
|
+
}
|
80
|
+
}
|
81
|
+
});
|
82
|
+
this_1._loader._completePromises.push(promise);
|
83
|
+
};
|
84
|
+
var this_1 = this;
|
85
|
+
for (var indexLOD = 0; indexLOD < this._nodePromiseLODs.length; indexLOD++) {
|
86
|
+
_loop_1(indexLOD);
|
87
|
+
}
|
88
|
+
var _loop_2 = function (indexLOD) {
|
89
|
+
var promise = Promise.all(this_2._materialPromiseLODs[indexLOD]).then(function () {
|
90
|
+
if (indexLOD !== 0) {
|
91
|
+
_this._loader.endPerformanceCounter("Material LOD ".concat(indexLOD));
|
92
|
+
_this._loader.log("Loaded material LOD ".concat(indexLOD));
|
93
|
+
}
|
94
|
+
_this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);
|
95
|
+
if (indexLOD !== _this._materialPromiseLODs.length - 1) {
|
96
|
+
_this._loader.startPerformanceCounter("Material LOD ".concat(indexLOD + 1));
|
97
|
+
_this._loadBufferLOD(_this._materialBufferLODs, indexLOD + 1);
|
98
|
+
if (_this._materialSignalLODs[indexLOD]) {
|
99
|
+
_this._materialSignalLODs[indexLOD].resolve();
|
100
|
+
}
|
101
|
+
}
|
102
|
+
});
|
103
|
+
this_2._loader._completePromises.push(promise);
|
104
|
+
};
|
105
|
+
var this_2 = this;
|
106
|
+
for (var indexLOD = 0; indexLOD < this._materialPromiseLODs.length; indexLOD++) {
|
107
|
+
_loop_2(indexLOD);
|
108
|
+
}
|
109
|
+
};
|
110
|
+
/**
|
111
|
+
* @param context
|
112
|
+
* @param scene
|
113
|
+
* @hidden
|
114
|
+
*/
|
115
|
+
MSFT_lod.prototype.loadSceneAsync = function (context, scene) {
|
116
|
+
var promise = this._loader.loadSceneAsync(context, scene);
|
117
|
+
this._loadBufferLOD(this._bufferLODs, 0);
|
118
|
+
return promise;
|
119
|
+
};
|
120
|
+
/**
|
121
|
+
* @param context
|
122
|
+
* @param node
|
123
|
+
* @param assign
|
124
|
+
* @hidden
|
125
|
+
*/
|
126
|
+
MSFT_lod.prototype.loadNodeAsync = function (context, node, assign) {
|
127
|
+
var _this = this;
|
128
|
+
return GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) {
|
129
|
+
var firstPromise;
|
130
|
+
var nodeLODs = _this._getLODs(extensionContext, node, _this._loader.gltf.nodes, extension.ids);
|
131
|
+
_this._loader.logOpen("".concat(extensionContext));
|
132
|
+
var _loop_3 = function (indexLOD) {
|
133
|
+
var nodeLOD = nodeLODs[indexLOD];
|
134
|
+
if (indexLOD !== 0) {
|
135
|
+
_this._nodeIndexLOD = indexLOD;
|
136
|
+
_this._nodeSignalLODs[indexLOD] = _this._nodeSignalLODs[indexLOD] || new Deferred();
|
137
|
+
}
|
138
|
+
var assignWrap = function (babylonTransformNode) {
|
139
|
+
assign(babylonTransformNode);
|
140
|
+
babylonTransformNode.setEnabled(false);
|
141
|
+
};
|
142
|
+
var promise = _this._loader.loadNodeAsync("/nodes/".concat(nodeLOD.index), nodeLOD, assignWrap).then(function (babylonMesh) {
|
143
|
+
if (indexLOD !== 0) {
|
144
|
+
// TODO: should not rely on _babylonTransformNode
|
145
|
+
var previousNodeLOD = nodeLODs[indexLOD - 1];
|
146
|
+
if (previousNodeLOD._babylonTransformNode) {
|
147
|
+
_this._disposeTransformNode(previousNodeLOD._babylonTransformNode);
|
148
|
+
delete previousNodeLOD._babylonTransformNode;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
babylonMesh.setEnabled(true);
|
152
|
+
return babylonMesh;
|
153
|
+
});
|
154
|
+
_this._nodePromiseLODs[indexLOD] = _this._nodePromiseLODs[indexLOD] || [];
|
155
|
+
if (indexLOD === 0) {
|
156
|
+
firstPromise = promise;
|
157
|
+
}
|
158
|
+
else {
|
159
|
+
_this._nodeIndexLOD = null;
|
160
|
+
_this._nodePromiseLODs[indexLOD].push(promise);
|
161
|
+
}
|
162
|
+
};
|
163
|
+
for (var indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) {
|
164
|
+
_loop_3(indexLOD);
|
165
|
+
}
|
166
|
+
_this._loader.logClose();
|
167
|
+
return firstPromise;
|
168
|
+
});
|
169
|
+
};
|
170
|
+
/**
|
171
|
+
* @param context
|
172
|
+
* @param material
|
173
|
+
* @param babylonMesh
|
174
|
+
* @param babylonDrawMode
|
175
|
+
* @param assign
|
176
|
+
* @hidden
|
177
|
+
*/
|
178
|
+
MSFT_lod.prototype._loadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) {
|
179
|
+
var _this = this;
|
180
|
+
// Don't load material LODs if already loading a node LOD.
|
181
|
+
if (this._nodeIndexLOD) {
|
182
|
+
return null;
|
183
|
+
}
|
184
|
+
return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
|
185
|
+
var firstPromise;
|
186
|
+
var materialLODs = _this._getLODs(extensionContext, material, _this._loader.gltf.materials, extension.ids);
|
187
|
+
_this._loader.logOpen("".concat(extensionContext));
|
188
|
+
var _loop_4 = function (indexLOD) {
|
189
|
+
var materialLOD = materialLODs[indexLOD];
|
190
|
+
if (indexLOD !== 0) {
|
191
|
+
_this._materialIndexLOD = indexLOD;
|
192
|
+
}
|
193
|
+
var promise = _this._loader
|
194
|
+
._loadMaterialAsync("/materials/".concat(materialLOD.index), materialLOD, babylonMesh, babylonDrawMode, function (babylonMaterial) {
|
195
|
+
if (indexLOD === 0) {
|
196
|
+
assign(babylonMaterial);
|
197
|
+
}
|
198
|
+
})
|
199
|
+
.then(function (babylonMaterial) {
|
200
|
+
if (indexLOD !== 0) {
|
201
|
+
assign(babylonMaterial);
|
202
|
+
// TODO: should not rely on _data
|
203
|
+
var previousDataLOD = materialLODs[indexLOD - 1]._data;
|
204
|
+
if (previousDataLOD[babylonDrawMode]) {
|
205
|
+
_this._disposeMaterials([previousDataLOD[babylonDrawMode].babylonMaterial]);
|
206
|
+
delete previousDataLOD[babylonDrawMode];
|
207
|
+
}
|
208
|
+
}
|
209
|
+
return babylonMaterial;
|
210
|
+
});
|
211
|
+
_this._materialPromiseLODs[indexLOD] = _this._materialPromiseLODs[indexLOD] || [];
|
212
|
+
if (indexLOD === 0) {
|
213
|
+
firstPromise = promise;
|
214
|
+
}
|
215
|
+
else {
|
216
|
+
_this._materialIndexLOD = null;
|
217
|
+
_this._materialPromiseLODs[indexLOD].push(promise);
|
218
|
+
}
|
219
|
+
};
|
220
|
+
for (var indexLOD = 0; indexLOD < materialLODs.length; indexLOD++) {
|
221
|
+
_loop_4(indexLOD);
|
222
|
+
}
|
223
|
+
_this._loader.logClose();
|
224
|
+
return firstPromise;
|
225
|
+
});
|
226
|
+
};
|
227
|
+
/**
|
228
|
+
* @param context
|
229
|
+
* @param property
|
230
|
+
* @param uri
|
231
|
+
* @hidden
|
232
|
+
*/
|
233
|
+
MSFT_lod.prototype._loadUriAsync = function (context, property, uri) {
|
234
|
+
var _this = this;
|
235
|
+
// Defer the loading of uris if loading a node or material LOD.
|
236
|
+
if (this._nodeIndexLOD !== null) {
|
237
|
+
this._loader.log("deferred");
|
238
|
+
var previousIndexLOD = this._nodeIndexLOD - 1;
|
239
|
+
this._nodeSignalLODs[previousIndexLOD] = this._nodeSignalLODs[previousIndexLOD] || new Deferred();
|
240
|
+
return this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(function () {
|
241
|
+
return _this._loader.loadUriAsync(context, property, uri);
|
242
|
+
});
|
243
|
+
}
|
244
|
+
else if (this._materialIndexLOD !== null) {
|
245
|
+
this._loader.log("deferred");
|
246
|
+
var previousIndexLOD = this._materialIndexLOD - 1;
|
247
|
+
this._materialSignalLODs[previousIndexLOD] = this._materialSignalLODs[previousIndexLOD] || new Deferred();
|
248
|
+
return this._materialSignalLODs[previousIndexLOD].promise.then(function () {
|
249
|
+
return _this._loader.loadUriAsync(context, property, uri);
|
250
|
+
});
|
251
|
+
}
|
252
|
+
return null;
|
253
|
+
};
|
254
|
+
/**
|
255
|
+
* @param context
|
256
|
+
* @param buffer
|
257
|
+
* @param byteOffset
|
258
|
+
* @param byteLength
|
259
|
+
* @hidden
|
260
|
+
*/
|
261
|
+
MSFT_lod.prototype.loadBufferAsync = function (context, buffer, byteOffset, byteLength) {
|
262
|
+
if (this._loader.parent.useRangeRequests && !buffer.uri) {
|
263
|
+
if (!this._loader.bin) {
|
264
|
+
throw new Error("".concat(context, ": Uri is missing or the binary glTF is missing its binary chunk"));
|
265
|
+
}
|
266
|
+
var loadAsync = function (bufferLODs, indexLOD) {
|
267
|
+
var start = byteOffset;
|
268
|
+
var end = start + byteLength - 1;
|
269
|
+
var bufferLOD = bufferLODs[indexLOD];
|
270
|
+
if (bufferLOD) {
|
271
|
+
bufferLOD.start = Math.min(bufferLOD.start, start);
|
272
|
+
bufferLOD.end = Math.max(bufferLOD.end, end);
|
273
|
+
}
|
274
|
+
else {
|
275
|
+
bufferLOD = { start: start, end: end, loaded: new Deferred() };
|
276
|
+
bufferLODs[indexLOD] = bufferLOD;
|
277
|
+
}
|
278
|
+
return bufferLOD.loaded.promise.then(function (data) {
|
279
|
+
return new Uint8Array(data.buffer, data.byteOffset + byteOffset - bufferLOD.start, byteLength);
|
280
|
+
});
|
281
|
+
};
|
282
|
+
this._loader.log("deferred");
|
283
|
+
if (this._nodeIndexLOD !== null) {
|
284
|
+
return loadAsync(this._nodeBufferLODs, this._nodeIndexLOD);
|
285
|
+
}
|
286
|
+
else if (this._materialIndexLOD !== null) {
|
287
|
+
return loadAsync(this._materialBufferLODs, this._materialIndexLOD);
|
288
|
+
}
|
289
|
+
else {
|
290
|
+
return loadAsync(this._bufferLODs, 0);
|
291
|
+
}
|
292
|
+
}
|
293
|
+
return null;
|
294
|
+
};
|
295
|
+
MSFT_lod.prototype._loadBufferLOD = function (bufferLODs, indexLOD) {
|
296
|
+
var bufferLOD = bufferLODs[indexLOD];
|
297
|
+
if (bufferLOD) {
|
298
|
+
this._loader.log("Loading buffer range [".concat(bufferLOD.start, "-").concat(bufferLOD.end, "]"));
|
299
|
+
this._loader.bin.readAsync(bufferLOD.start, bufferLOD.end - bufferLOD.start + 1).then(function (data) {
|
300
|
+
bufferLOD.loaded.resolve(data);
|
301
|
+
}, function (error) {
|
302
|
+
bufferLOD.loaded.reject(error);
|
303
|
+
});
|
304
|
+
}
|
305
|
+
};
|
306
|
+
/**
|
307
|
+
* Gets an array of LOD properties from lowest to highest.
|
308
|
+
* @param context
|
309
|
+
* @param property
|
310
|
+
* @param array
|
311
|
+
* @param ids
|
312
|
+
*/
|
313
|
+
MSFT_lod.prototype._getLODs = function (context, property, array, ids) {
|
314
|
+
if (this.maxLODsToLoad <= 0) {
|
315
|
+
throw new Error("maxLODsToLoad must be greater than zero");
|
316
|
+
}
|
317
|
+
var properties = new Array();
|
318
|
+
for (var i = ids.length - 1; i >= 0; i--) {
|
319
|
+
properties.push(ArrayItem.Get("".concat(context, "/ids/").concat(ids[i]), array, ids[i]));
|
320
|
+
if (properties.length === this.maxLODsToLoad) {
|
321
|
+
return properties;
|
322
|
+
}
|
323
|
+
}
|
324
|
+
properties.push(property);
|
325
|
+
return properties;
|
326
|
+
};
|
327
|
+
MSFT_lod.prototype._disposeTransformNode = function (babylonTransformNode) {
|
328
|
+
var _this = this;
|
329
|
+
var babylonMaterials = new Array();
|
330
|
+
var babylonMaterial = babylonTransformNode.material;
|
331
|
+
if (babylonMaterial) {
|
332
|
+
babylonMaterials.push(babylonMaterial);
|
333
|
+
}
|
334
|
+
for (var _i = 0, _a = babylonTransformNode.getChildMeshes(); _i < _a.length; _i++) {
|
335
|
+
var babylonMesh = _a[_i];
|
336
|
+
if (babylonMesh.material) {
|
337
|
+
babylonMaterials.push(babylonMesh.material);
|
338
|
+
}
|
339
|
+
}
|
340
|
+
babylonTransformNode.dispose();
|
341
|
+
var babylonMaterialsToDispose = babylonMaterials.filter(function (babylonMaterial) { return _this._loader.babylonScene.meshes.every(function (mesh) { return mesh.material != babylonMaterial; }); });
|
342
|
+
this._disposeMaterials(babylonMaterialsToDispose);
|
343
|
+
};
|
344
|
+
MSFT_lod.prototype._disposeMaterials = function (babylonMaterials) {
|
345
|
+
var babylonTextures = {};
|
346
|
+
for (var _i = 0, babylonMaterials_1 = babylonMaterials; _i < babylonMaterials_1.length; _i++) {
|
347
|
+
var babylonMaterial = babylonMaterials_1[_i];
|
348
|
+
for (var _a = 0, _b = babylonMaterial.getActiveTextures(); _a < _b.length; _a++) {
|
349
|
+
var babylonTexture = _b[_a];
|
350
|
+
babylonTextures[babylonTexture.uniqueId] = babylonTexture;
|
351
|
+
}
|
352
|
+
babylonMaterial.dispose();
|
353
|
+
}
|
354
|
+
for (var uniqueId in babylonTextures) {
|
355
|
+
for (var _c = 0, _d = this._loader.babylonScene.materials; _c < _d.length; _c++) {
|
356
|
+
var babylonMaterial = _d[_c];
|
357
|
+
if (babylonMaterial.hasTexture(babylonTextures[uniqueId])) {
|
358
|
+
delete babylonTextures[uniqueId];
|
359
|
+
}
|
360
|
+
}
|
361
|
+
}
|
362
|
+
for (var uniqueId in babylonTextures) {
|
363
|
+
babylonTextures[uniqueId].dispose();
|
364
|
+
}
|
365
|
+
};
|
366
|
+
return MSFT_lod;
|
367
|
+
}());
|
368
|
+
export { MSFT_lod };
|
369
|
+
GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_lod(loader); });
|
334
370
|
//# sourceMappingURL=MSFT_lod.js.map
|