@babylonjs/loaders 5.0.0-beta.3 → 5.0.0-beta.7
Sign up to get free protection for your applications and to get access to all the features.
- package/OBJ/objFileLoader.js +2 -2
- package/OBJ/objFileLoader.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_lights_image_based.js +8 -8
- package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +4 -4
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js +2 -2
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.js +2 -2
- package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +27 -7
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +7 -7
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.js +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +5 -5
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +5 -5
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.js +5 -5
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_translucency.js +2 -2
- package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +2 -2
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +3 -3
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_variants.js +6 -6
- package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.js +2 -2
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_basisu.js +2 -2
- package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.js +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js +13 -13
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_lod.d.ts +0 -1
- package/glTF/2.0/Extensions/MSFT_lod.js +17 -54
- package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +1 -1
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +1 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
- package/glTF/2.0/glTFLoader.js +141 -141
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/glTFFileLoader.js +13 -13
- package/glTF/glTFFileLoader.js.map +1 -1
- package/glTF/glTFValidation.js +1 -1
- package/glTF/glTFValidation.js.map +1 -1
- package/package.json +3 -3
@@ -64,12 +64,12 @@ var MSFT_lod = /** @class */ (function () {
|
|
64
64
|
var _loop_1 = function (indexLOD) {
|
65
65
|
var promise = Promise.all(this_1._nodePromiseLODs[indexLOD]).then(function () {
|
66
66
|
if (indexLOD !== 0) {
|
67
|
-
_this._loader.endPerformanceCounter("Node LOD "
|
68
|
-
_this._loader.log("Loaded node LOD "
|
67
|
+
_this._loader.endPerformanceCounter("Node LOD ".concat(indexLOD));
|
68
|
+
_this._loader.log("Loaded node LOD ".concat(indexLOD));
|
69
69
|
}
|
70
70
|
_this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);
|
71
71
|
if (indexLOD !== _this._nodePromiseLODs.length - 1) {
|
72
|
-
_this._loader.startPerformanceCounter("Node LOD "
|
72
|
+
_this._loader.startPerformanceCounter("Node LOD ".concat(indexLOD + 1));
|
73
73
|
_this._loadBufferLOD(_this._nodeBufferLODs, indexLOD + 1);
|
74
74
|
if (_this._nodeSignalLODs[indexLOD]) {
|
75
75
|
_this._nodeSignalLODs[indexLOD].resolve();
|
@@ -85,12 +85,12 @@ var MSFT_lod = /** @class */ (function () {
|
|
85
85
|
var _loop_2 = function (indexLOD) {
|
86
86
|
var promise = Promise.all(this_2._materialPromiseLODs[indexLOD]).then(function () {
|
87
87
|
if (indexLOD !== 0) {
|
88
|
-
_this._loader.endPerformanceCounter("Material LOD "
|
89
|
-
_this._loader.log("Loaded material LOD "
|
88
|
+
_this._loader.endPerformanceCounter("Material LOD ".concat(indexLOD));
|
89
|
+
_this._loader.log("Loaded material LOD ".concat(indexLOD));
|
90
90
|
}
|
91
91
|
_this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);
|
92
92
|
if (indexLOD !== _this._materialPromiseLODs.length - 1) {
|
93
|
-
_this._loader.startPerformanceCounter("Material LOD "
|
93
|
+
_this._loader.startPerformanceCounter("Material LOD ".concat(indexLOD + 1));
|
94
94
|
_this._loadBufferLOD(_this._materialBufferLODs, indexLOD + 1);
|
95
95
|
if (_this._materialSignalLODs[indexLOD]) {
|
96
96
|
_this._materialSignalLODs[indexLOD].resolve();
|
@@ -116,50 +116,19 @@ var MSFT_lod = /** @class */ (function () {
|
|
116
116
|
return GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) {
|
117
117
|
var firstPromise;
|
118
118
|
var nodeLODs = _this._getLODs(extensionContext, node, _this._loader.gltf.nodes, extension.ids);
|
119
|
-
_this._loader.logOpen(""
|
120
|
-
var transformNodes = [];
|
121
|
-
for (var indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) {
|
122
|
-
transformNodes.push(null);
|
123
|
-
}
|
119
|
+
_this._loader.logOpen("".concat(extensionContext));
|
124
120
|
var _loop_3 = function (indexLOD) {
|
125
121
|
var nodeLOD = nodeLODs[indexLOD];
|
126
122
|
if (indexLOD !== 0) {
|
127
123
|
_this._nodeIndexLOD = indexLOD;
|
128
124
|
_this._nodeSignalLODs[indexLOD] = _this._nodeSignalLODs[indexLOD] || new Deferred();
|
129
125
|
}
|
130
|
-
var
|
131
|
-
|
126
|
+
var assignWrap = function (babylonTransformNode) {
|
127
|
+
assign(babylonTransformNode);
|
132
128
|
babylonTransformNode.setEnabled(false);
|
133
|
-
transformNodes[index] = babylonTransformNode;
|
134
|
-
var fullArray = true;
|
135
|
-
for (var i = 0; i < transformNodes.length; i++) {
|
136
|
-
if (!transformNodes[i]) {
|
137
|
-
fullArray = false;
|
138
|
-
}
|
139
|
-
}
|
140
|
-
var lod0 = transformNodes[transformNodes.length - 1];
|
141
|
-
if (fullArray && lod0 && _this._isMesh(lod0)) {
|
142
|
-
var screenCoverages = (_c = (_b = (_a = lod0.metadata) === null || _a === void 0 ? void 0 : _a.gltf) === null || _b === void 0 ? void 0 : _b.extras) === null || _c === void 0 ? void 0 : _c.MSFT_screencoverage;
|
143
|
-
if (screenCoverages && screenCoverages.length) {
|
144
|
-
screenCoverages.reverse();
|
145
|
-
lod0.useLODScreenCoverage = true;
|
146
|
-
for (var i = 0; i < transformNodes.length - 1; i++) {
|
147
|
-
var transformNode = transformNodes[i];
|
148
|
-
if (transformNode && _this._isMesh(transformNode)) {
|
149
|
-
lod0.addLODLevel(screenCoverages[i + 1], transformNode);
|
150
|
-
}
|
151
|
-
}
|
152
|
-
if (screenCoverages[0] > 0) {
|
153
|
-
// Adding empty LOD
|
154
|
-
lod0.addLODLevel(screenCoverages[0], null);
|
155
|
-
}
|
156
|
-
}
|
157
|
-
}
|
158
129
|
};
|
159
|
-
var promise = _this._loader.loadNodeAsync("/nodes/"
|
160
|
-
|
161
|
-
var screenCoverages = (_c = (_b = (_a = nodeLODs[nodeLODs.length - 1]._babylonTransformNode.metadata) === null || _a === void 0 ? void 0 : _a.gltf) === null || _b === void 0 ? void 0 : _b.extras) === null || _c === void 0 ? void 0 : _c.MSFT_screencoverage;
|
162
|
-
if (indexLOD !== 0 && !screenCoverages) {
|
130
|
+
var promise = _this._loader.loadNodeAsync("/nodes/".concat(nodeLOD.index), nodeLOD, assignWrap).then(function (babylonMesh) {
|
131
|
+
if (indexLOD !== 0) {
|
163
132
|
// TODO: should not rely on _babylonTransformNode
|
164
133
|
var previousNodeLOD = nodeLODs[indexLOD - 1];
|
165
134
|
if (previousNodeLOD._babylonTransformNode) {
|
@@ -167,7 +136,6 @@ var MSFT_lod = /** @class */ (function () {
|
|
167
136
|
delete previousNodeLOD._babylonTransformNode;
|
168
137
|
}
|
169
138
|
}
|
170
|
-
assign(babylonMesh);
|
171
139
|
babylonMesh.setEnabled(true);
|
172
140
|
return babylonMesh;
|
173
141
|
});
|
@@ -197,19 +165,17 @@ var MSFT_lod = /** @class */ (function () {
|
|
197
165
|
return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
|
198
166
|
var firstPromise;
|
199
167
|
var materialLODs = _this._getLODs(extensionContext, material, _this._loader.gltf.materials, extension.ids);
|
200
|
-
_this._loader.logOpen(""
|
168
|
+
_this._loader.logOpen("".concat(extensionContext));
|
201
169
|
var _loop_4 = function (indexLOD) {
|
202
170
|
var materialLOD = materialLODs[indexLOD];
|
203
171
|
if (indexLOD !== 0) {
|
204
172
|
_this._materialIndexLOD = indexLOD;
|
205
173
|
}
|
206
|
-
var promise = _this._loader
|
207
|
-
._loadMaterialAsync("/materials/" + materialLOD.index, materialLOD, babylonMesh, babylonDrawMode, function (babylonMaterial) {
|
174
|
+
var promise = _this._loader._loadMaterialAsync("/materials/".concat(materialLOD.index), materialLOD, babylonMesh, babylonDrawMode, function (babylonMaterial) {
|
208
175
|
if (indexLOD === 0) {
|
209
176
|
assign(babylonMaterial);
|
210
177
|
}
|
211
|
-
})
|
212
|
-
.then(function (babylonMaterial) {
|
178
|
+
}).then(function (babylonMaterial) {
|
213
179
|
if (indexLOD !== 0) {
|
214
180
|
assign(babylonMaterial);
|
215
181
|
// TODO: should not rely on _data
|
@@ -263,7 +229,7 @@ var MSFT_lod = /** @class */ (function () {
|
|
263
229
|
MSFT_lod.prototype.loadBufferAsync = function (context, buffer, byteOffset, byteLength) {
|
264
230
|
if (this._loader.parent.useRangeRequests && !buffer.uri) {
|
265
231
|
if (!this._loader.bin) {
|
266
|
-
throw new Error(context
|
232
|
+
throw new Error("".concat(context, ": Uri is missing or the binary glTF is missing its binary chunk"));
|
267
233
|
}
|
268
234
|
var loadAsync = function (bufferLODs, indexLOD) {
|
269
235
|
var start = byteOffset;
|
@@ -294,13 +260,10 @@ var MSFT_lod = /** @class */ (function () {
|
|
294
260
|
}
|
295
261
|
return null;
|
296
262
|
};
|
297
|
-
MSFT_lod.prototype._isMesh = function (mesh) {
|
298
|
-
return !!mesh.addLODLevel;
|
299
|
-
};
|
300
263
|
MSFT_lod.prototype._loadBufferLOD = function (bufferLODs, indexLOD) {
|
301
264
|
var bufferLOD = bufferLODs[indexLOD];
|
302
265
|
if (bufferLOD) {
|
303
|
-
this._loader.log("Loading buffer range ["
|
266
|
+
this._loader.log("Loading buffer range [".concat(bufferLOD.start, "-").concat(bufferLOD.end, "]"));
|
304
267
|
this._loader.bin.readAsync(bufferLOD.start, bufferLOD.end - bufferLOD.start + 1).then(function (data) {
|
305
268
|
bufferLOD.loaded.resolve(data);
|
306
269
|
}, function (error) {
|
@@ -317,7 +280,7 @@ var MSFT_lod = /** @class */ (function () {
|
|
317
280
|
}
|
318
281
|
var properties = new Array();
|
319
282
|
for (var i = ids.length - 1; i >= 0; i--) {
|
320
|
-
properties.push(ArrayItem.Get(context
|
283
|
+
properties.push(ArrayItem.Get("".concat(context, "/ids/").concat(ids[i]), array, ids[i]));
|
321
284
|
if (properties.length === this.maxLODsToLoad) {
|
322
285
|
return properties;
|
323
286
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"MSFT_lod.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAOzD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGtD,IAAM,IAAI,GAAG,UAAU,CAAC;AAQxB;;GAEG;AACH;IAiDI,cAAc;IACd,kBAAY,MAAkB;QAjD9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAEnB;;WAEG;QACI,kBAAa,GAAG,EAAE,CAAC;QAE1B;;;;WAIG;QACI,+BAA0B,GAAG,IAAI,UAAU,EAAU,CAAC;QAE7D;;;;WAIG;QACI,mCAA8B,GAAG,IAAI,UAAU,EAAU,CAAC;QAIzD,gBAAW,GAAG,IAAI,KAAK,EAAe,CAAC;QAEvC,kBAAa,GAAqB,IAAI,CAAC;QACvC,oBAAe,GAAG,IAAI,KAAK,EAAkB,CAAC;QAC9C,qBAAgB,GAAG,IAAI,KAAK,EAAuB,CAAC;QACpD,oBAAe,GAAG,IAAI,KAAK,EAAe,CAAC;QAE3C,sBAAiB,GAAqB,IAAI,CAAC;QAC3C,wBAAmB,GAAG,IAAI,KAAK,EAAkB,CAAC;QAClD,yBAAoB,GAAG,IAAI,KAAK,EAAuB,CAAC;QACxD,wB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,IAAI,eAAe,EAAhC,CAAgC,CAAC,EAAlF,CAAkF,CAAC,CAAC;QACnK,IAAI,CAAC,iBAAiB,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAEO,oCAAiB,GAAzB,UAA0B,gBAA4B;QAClD,IAAM,eAAe,GAAwC,EAAE,CAAC;QAEhE,KAA8B,UAAgB,EAAhB,qCAAgB,EAAhB,8BAAgB,EAAhB,IAAgB,EAAE;YAA3C,IAAM,eAAe,yBAAA;YACtB,KAA6B,UAAmC,EAAnC,KAAA,eAAe,CAAC,iBAAiB,EAAE,EAAnC,cAAmC,EAAnC,IAAmC,EAAE;gBAA7D,IAAM,cAAc,SAAA;gBACrB,eAAe,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC;aAC7D;YAED,eAAe,CAAC,OAAO,EAAE,CAAC;SAC7B;QAED,KAAK,IAAM,QAAQ,IAAI,eAAe,EAAE;YACpC,KAA8B,UAAmC,EAAnC,KAAA,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,EAAnC,cAAmC,EAAnC,IAAmC,EAAE;gBAA9D,IAAM,eAAe,SAAA;gBACtB,IAAI,eAAe,CAAC,UAAU,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,EAAE;oBACvD,OAAO,eAAe,CAAC,QAAQ,CAAC,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,AA7ZD,IA6ZC;;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 const transformNodes: Nullable<TransformNode>[] = [];\n\n for (let indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) {\n transformNodes.push(null);\n }\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 assignChild = (babylonTransformNode: TransformNode, index: number) => {\n babylonTransformNode.setEnabled(false);\n transformNodes[index] = babylonTransformNode;\n\n let fullArray = true;\n for (let i = 0; i < transformNodes.length; i++) {\n if (!transformNodes[i]) {\n fullArray = false;\n }\n }\n\n const lod0 = transformNodes[transformNodes.length - 1];\n if (fullArray && lod0 && this._isMesh(lod0)) {\n const screenCoverages = lod0.metadata?.gltf?.extras?.MSFT_screencoverage as number[];\n\n if (screenCoverages && screenCoverages.length) {\n screenCoverages.reverse();\n lod0.useLODScreenCoverage = true;\n for (let i = 0; i < transformNodes.length - 1; i++) {\n const transformNode = transformNodes[i];\n if (transformNode && this._isMesh(transformNode)) {\n lod0.addLODLevel(screenCoverages[i + 1], transformNode);\n }\n }\n if (screenCoverages[0] > 0) {\n // Adding empty LOD\n lod0.addLODLevel(screenCoverages[0], null);\n }\n }\n }\n };\n\n const promise = this._loader.loadNodeAsync(`/nodes/${nodeLOD.index}`, nodeLOD, (node: TransformNode) => assignChild(node, indexLOD)).then((babylonMesh) => {\n const screenCoverages = (nodeLODs[nodeLODs.length - 1]._babylonTransformNode as Mesh).metadata?.gltf?.extras?.MSFT_screencoverage;\n\n if (indexLOD !== 0 && !screenCoverages) {\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 assign(babylonMesh);\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(\n context: string,\n material: IMaterial,\n babylonMesh: Nullable<Mesh>,\n babylonDrawMode: number,\n assign: (babylonMaterial: Material) => void\n ): 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\n ._loadMaterialAsync(`/materials/${materialLOD.index}`, materialLOD, babylonMesh, babylonDrawMode, (babylonMaterial) => {\n if (indexLOD === 0) {\n assign(babylonMaterial);\n }\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 _isMesh(mesh: TransformNode | Mesh): mesh is Mesh {\n return !!(mesh as Mesh).addLODLevel;\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(\n (data) => {\n bufferLOD.loaded.resolve(data);\n },\n (error) => {\n bufferLOD.loaded.reject(error);\n }\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
|
+
{"version":3,"file":"MSFT_lod.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAOzD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGtD,IAAM,IAAI,GAAG,UAAU,CAAC;AAQxB;;GAEG;AACH;IAiDI,cAAc;IACd,kBAAY,MAAkB;QAjD9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QA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port { 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"]}
|
@@ -16,7 +16,7 @@ var MSFT_minecraftMesh = /** @class */ (function () {
|
|
16
16
|
return GLTFLoader.LoadExtraAsync(context, material, this.name, function (extraContext, extra) {
|
17
17
|
if (extra) {
|
18
18
|
if (!(babylonMaterial instanceof PBRMaterial)) {
|
19
|
-
throw new Error(extraContext
|
19
|
+
throw new Error("".concat(extraContext, ": Material type not supported"));
|
20
20
|
}
|
21
21
|
var promise = _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial);
|
22
22
|
if (babylonMaterial.needAlphaBlending()) {
|
@@ -1 +1 @@
|
|
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,
|
1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,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));"]}
|
@@ -16,7 +16,7 @@ var MSFT_sRGBFactors = /** @class */ (function () {
|
|
16
16
|
return GLTFLoader.LoadExtraAsync(context, material, this.name, function (extraContext, extra) {
|
17
17
|
if (extra) {
|
18
18
|
if (!(babylonMaterial instanceof PBRMaterial)) {
|
19
|
-
throw new Error(extraContext
|
19
|
+
throw new Error("".concat(extraContext, ": Material type not supported"));
|
20
20
|
}
|
21
21
|
var promise = _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial);
|
22
22
|
if (!babylonMaterial.albedoTexture) {
|
@@ -1 +1 @@
|
|
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,YAA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iB,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));"]}
|