@onerjs/loaders 8.46.6 → 8.46.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js +2 -2
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +7 -4
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.js +3 -6
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume_scatter.js +25 -19
- package/glTF/2.0/Extensions/KHR_materials_volume_scatter.js.map +1 -1
- package/glTF/2.0/glTFLoader.d.ts +1 -0
- package/glTF/2.0/glTFLoader.js +10 -28
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/2.0/materialLoadingAdapter.d.ts +21 -10
- package/glTF/2.0/materialLoadingAdapter.js.map +1 -1
- package/glTF/2.0/openpbrMaterialLoadingAdapter.d.ts +31 -17
- package/glTF/2.0/openpbrMaterialLoadingAdapter.js +106 -48
- package/glTF/2.0/openpbrMaterialLoadingAdapter.js.map +1 -1
- package/glTF/2.0/pbrMaterialLoadingAdapter.d.ts +18 -14
- package/glTF/2.0/pbrMaterialLoadingAdapter.js +26 -19
- package/glTF/2.0/pbrMaterialLoadingAdapter.js.map +1 -1
- package/package.json +3 -3
package/glTF/2.0/glTFLoader.js
CHANGED
|
@@ -202,6 +202,7 @@ export class GLTFLoader {
|
|
|
202
202
|
this._defaultBabylonMaterialData = {};
|
|
203
203
|
this._postSceneLoadActions = new Array();
|
|
204
204
|
this._materialAdapterCache = new WeakMap();
|
|
205
|
+
this._materialAdapters = new Set();
|
|
205
206
|
/** @internal */
|
|
206
207
|
this._pbrMaterialImpl = null;
|
|
207
208
|
this._parent = parent;
|
|
@@ -221,7 +222,9 @@ export class GLTFLoader {
|
|
|
221
222
|
else {
|
|
222
223
|
throw new Error(`Appropriate material adapter class not found`);
|
|
223
224
|
}
|
|
224
|
-
|
|
225
|
+
const createdAdapter = adapter;
|
|
226
|
+
this._materialAdapterCache.set(material, createdAdapter);
|
|
227
|
+
this._materialAdapters.add(createdAdapter);
|
|
225
228
|
}
|
|
226
229
|
return adapter;
|
|
227
230
|
}
|
|
@@ -234,6 +237,10 @@ export class GLTFLoader {
|
|
|
234
237
|
this._completePromises.length = 0;
|
|
235
238
|
this._extensions.forEach((extension) => extension.dispose && extension.dispose());
|
|
236
239
|
this._extensions.length = 0;
|
|
240
|
+
for (const adapter of Array.from(this._materialAdapters)) {
|
|
241
|
+
adapter.finalize?.();
|
|
242
|
+
}
|
|
243
|
+
this._materialAdapters.clear();
|
|
237
244
|
this._gltf = null; // TODO
|
|
238
245
|
this._bin = null;
|
|
239
246
|
this._babylonScene = null; // TODO
|
|
@@ -246,7 +253,6 @@ export class GLTFLoader {
|
|
|
246
253
|
* @internal
|
|
247
254
|
*/
|
|
248
255
|
async importMeshAsync(meshesNames, scene, container, data, rootUrl, onProgress, fileName = "") {
|
|
249
|
-
// eslint-disable-next-line github/no-then
|
|
250
256
|
return await Promise.resolve().then(async () => {
|
|
251
257
|
this._babylonScene = scene;
|
|
252
258
|
this._assetContainer = container;
|
|
@@ -496,7 +502,6 @@ export class GLTFLoader {
|
|
|
496
502
|
if (this._parent.customRootNode !== undefined) {
|
|
497
503
|
this._rootBabylonMesh = this._parent.customRootNode;
|
|
498
504
|
return {
|
|
499
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
500
505
|
_babylonTransformNode: this._rootBabylonMesh === null ? undefined : this._rootBabylonMesh,
|
|
501
506
|
index: -1,
|
|
502
507
|
};
|
|
@@ -508,7 +513,6 @@ export class GLTFLoader {
|
|
|
508
513
|
this._babylonScene._blockEntityCollection = false;
|
|
509
514
|
this._rootBabylonMesh.setEnabled(false);
|
|
510
515
|
const rootNode = {
|
|
511
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
512
516
|
_babylonTransformNode: this._rootBabylonMesh,
|
|
513
517
|
index: -1,
|
|
514
518
|
};
|
|
@@ -544,7 +548,6 @@ export class GLTFLoader {
|
|
|
544
548
|
* @param scene The glTF scene property
|
|
545
549
|
* @returns A promise that resolves when the load is complete
|
|
546
550
|
*/
|
|
547
|
-
// eslint-disable-next-line no-restricted-syntax, @typescript-eslint/promise-function-async
|
|
548
551
|
loadSceneAsync(context, scene) {
|
|
549
552
|
const extensionPromise = this._extensionsLoadSceneAsync(context, scene);
|
|
550
553
|
if (extensionPromise) {
|
|
@@ -677,7 +680,6 @@ export class GLTFLoader {
|
|
|
677
680
|
* @param assign A function called synchronously after parsing the glTF properties
|
|
678
681
|
* @returns A promise that resolves with the loaded Babylon mesh when the load is complete
|
|
679
682
|
*/
|
|
680
|
-
// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax
|
|
681
683
|
loadNodeAsync(context, node, assign = () => { }) {
|
|
682
684
|
const extensionPromise = this._extensionsLoadNodeAsync(context, node, assign);
|
|
683
685
|
if (extensionPromise) {
|
|
@@ -791,7 +793,6 @@ export class GLTFLoader {
|
|
|
791
793
|
return node._babylonTransformNode;
|
|
792
794
|
});
|
|
793
795
|
}
|
|
794
|
-
// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax
|
|
795
796
|
_loadMeshAsync(context, node, mesh, assign) {
|
|
796
797
|
const primitives = mesh.primitives;
|
|
797
798
|
if (!primitives || !primitives.length) {
|
|
@@ -839,7 +840,6 @@ export class GLTFLoader {
|
|
|
839
840
|
* @param assign A function called synchronously after parsing the glTF properties
|
|
840
841
|
* @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
|
|
841
842
|
*/
|
|
842
|
-
// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax
|
|
843
843
|
_loadMeshPrimitiveAsync(context, name, node, mesh, primitive, assign) {
|
|
844
844
|
const extensionPromise = this._extensionsLoadMeshPrimitiveAsync(context, name, node, mesh, primitive, assign);
|
|
845
845
|
if (extensionPromise) {
|
|
@@ -917,7 +917,6 @@ export class GLTFLoader {
|
|
|
917
917
|
return babylonAbstractMesh;
|
|
918
918
|
});
|
|
919
919
|
}
|
|
920
|
-
// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax
|
|
921
920
|
_loadVertexDataAsync(context, primitive, babylonMesh) {
|
|
922
921
|
const extensionPromise = this._extensionsLoadVertexDataAsync(context, primitive, babylonMesh);
|
|
923
922
|
if (extensionPromise) {
|
|
@@ -1009,7 +1008,6 @@ export class GLTFLoader {
|
|
|
1009
1008
|
// TODO: tell the target whether it has positions, normals, tangents
|
|
1010
1009
|
}
|
|
1011
1010
|
}
|
|
1012
|
-
// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax
|
|
1013
1011
|
_loadMorphTargetsAsync(context, primitive, babylonMesh, babylonGeometry) {
|
|
1014
1012
|
if (!primitive.targets || !this._parent.loadMorphTargets) {
|
|
1015
1013
|
return Promise.resolve();
|
|
@@ -1139,7 +1137,6 @@ export class GLTFLoader {
|
|
|
1139
1137
|
babylonNode.setPivotPoint(Vector3.FromArray(node.pivotPoint));
|
|
1140
1138
|
}
|
|
1141
1139
|
}
|
|
1142
|
-
// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax
|
|
1143
1140
|
_loadSkinAsync(context, node, skin, assign) {
|
|
1144
1141
|
if (!this._parent.loadSkins) {
|
|
1145
1142
|
return Promise.resolve();
|
|
@@ -2362,66 +2359,51 @@ export class GLTFLoader {
|
|
|
2362
2359
|
_extensionsOnReady() {
|
|
2363
2360
|
this._forEachExtensions((extension) => extension.onReady && extension.onReady());
|
|
2364
2361
|
}
|
|
2365
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
2366
2362
|
_extensionsLoadSceneAsync(context, scene) {
|
|
2367
2363
|
return this._applyExtensions(scene, "loadScene", (extension) => extension.loadSceneAsync && extension.loadSceneAsync(context, scene));
|
|
2368
2364
|
}
|
|
2369
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
2370
2365
|
_extensionsLoadNodeAsync(context, node, assign) {
|
|
2371
2366
|
return this._applyExtensions(node, "loadNode", (extension) => extension.loadNodeAsync && extension.loadNodeAsync(context, node, assign));
|
|
2372
2367
|
}
|
|
2373
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
2374
2368
|
_extensionsLoadCameraAsync(context, camera, assign) {
|
|
2375
2369
|
return this._applyExtensions(camera, "loadCamera", (extension) => extension.loadCameraAsync && extension.loadCameraAsync(context, camera, assign));
|
|
2376
2370
|
}
|
|
2377
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
2378
2371
|
_extensionsLoadVertexDataAsync(context, primitive, babylonMesh) {
|
|
2379
2372
|
return this._applyExtensions(primitive, "loadVertexData", (extension) => extension._loadVertexDataAsync && extension._loadVertexDataAsync(context, primitive, babylonMesh));
|
|
2380
2373
|
}
|
|
2381
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
2382
2374
|
_extensionsLoadMeshPrimitiveAsync(context, name, node, mesh, primitive, assign) {
|
|
2383
2375
|
return this._applyExtensions(primitive, "loadMeshPrimitive", (extension) => extension._loadMeshPrimitiveAsync && extension._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, assign));
|
|
2384
2376
|
}
|
|
2385
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
2386
2377
|
_extensionsLoadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign) {
|
|
2387
2378
|
return this._applyExtensions(material, "loadMaterial", (extension) => extension._loadMaterialAsync && extension._loadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign));
|
|
2388
2379
|
}
|
|
2389
2380
|
_extensionsCreateMaterial(context, material, babylonDrawMode) {
|
|
2390
2381
|
return this._applyExtensions(material, "createMaterial", (extension) => extension.createMaterial && extension.createMaterial(context, material, babylonDrawMode));
|
|
2391
2382
|
}
|
|
2392
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
2393
2383
|
_extensionsLoadMaterialPropertiesAsync(context, material, babylonMaterial) {
|
|
2394
2384
|
return this._applyExtensions(material, "loadMaterialProperties", (extension) => extension.loadMaterialPropertiesAsync && extension.loadMaterialPropertiesAsync(context, material, babylonMaterial));
|
|
2395
2385
|
}
|
|
2396
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
2397
2386
|
_extensionsLoadTextureInfoAsync(context, textureInfo, assign) {
|
|
2398
2387
|
return this._applyExtensions(textureInfo, "loadTextureInfo", (extension) => extension.loadTextureInfoAsync && extension.loadTextureInfoAsync(context, textureInfo, assign));
|
|
2399
2388
|
}
|
|
2400
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
2401
2389
|
_extensionsLoadTextureAsync(context, texture, assign) {
|
|
2402
2390
|
return this._applyExtensions(texture, "loadTexture", (extension) => extension._loadTextureAsync && extension._loadTextureAsync(context, texture, assign));
|
|
2403
2391
|
}
|
|
2404
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
2405
2392
|
_extensionsLoadAnimationAsync(context, animation) {
|
|
2406
2393
|
return this._applyExtensions(animation, "loadAnimation", (extension) => extension.loadAnimationAsync && extension.loadAnimationAsync(context, animation));
|
|
2407
2394
|
}
|
|
2408
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
2409
2395
|
_extensionsLoadAnimationChannelAsync(context, animationContext, animation, channel, onLoad) {
|
|
2410
2396
|
return this._applyExtensions(animation, "loadAnimationChannel", (extension) => extension._loadAnimationChannelAsync && extension._loadAnimationChannelAsync(context, animationContext, animation, channel, onLoad));
|
|
2411
2397
|
}
|
|
2412
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
2413
2398
|
_extensionsLoadSkinAsync(context, node, skin) {
|
|
2414
2399
|
return this._applyExtensions(skin, "loadSkin", (extension) => extension._loadSkinAsync && extension._loadSkinAsync(context, node, skin));
|
|
2415
2400
|
}
|
|
2416
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
2417
2401
|
_extensionsLoadUriAsync(context, property, uri) {
|
|
2418
2402
|
return this._applyExtensions(property, "loadUri", (extension) => extension._loadUriAsync && extension._loadUriAsync(context, property, uri));
|
|
2419
2403
|
}
|
|
2420
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
2421
2404
|
_extensionsLoadBufferViewAsync(context, bufferView) {
|
|
2422
2405
|
return this._applyExtensions(bufferView, "loadBufferView", (extension) => extension.loadBufferViewAsync && extension.loadBufferViewAsync(context, bufferView));
|
|
2423
2406
|
}
|
|
2424
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
2425
2407
|
_extensionsLoadBufferAsync(context, buffer, byteOffset, byteLength) {
|
|
2426
2408
|
return this._applyExtensions(buffer, "loadBuffer", (extension) => extension.loadBufferAsync && extension.loadBufferAsync(context, buffer, byteOffset, byteLength));
|
|
2427
2409
|
}
|
|
@@ -2433,7 +2415,7 @@ export class GLTFLoader {
|
|
|
2433
2415
|
* @param actionAsync The action to run
|
|
2434
2416
|
* @returns The promise returned by actionAsync or null if the extension does not exist
|
|
2435
2417
|
*/
|
|
2436
|
-
// eslint-disable-next-line
|
|
2418
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2437
2419
|
static LoadExtensionAsync(context, property, extensionName, actionAsync) {
|
|
2438
2420
|
if (!property.extensions) {
|
|
2439
2421
|
return null;
|
|
@@ -2453,7 +2435,7 @@ export class GLTFLoader {
|
|
|
2453
2435
|
* @param actionAsync The action to run
|
|
2454
2436
|
* @returns The promise returned by actionAsync or null if the extra does not exist
|
|
2455
2437
|
*/
|
|
2456
|
-
// eslint-disable-next-line
|
|
2438
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2457
2439
|
static LoadExtraAsync(context, property, extensionName, actionAsync) {
|
|
2458
2440
|
if (!property.extras) {
|
|
2459
2441
|
return null;
|