@babylonjs/loaders 9.7.0 → 9.8.0
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/glTFLoader.d.ts +2 -3
- package/glTF/2.0/glTFLoader.js +9 -26
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/2.0/materialLoadingAdapter.d.ts +8 -10
- package/glTF/2.0/materialLoadingAdapter.js.map +1 -1
- package/glTF/2.0/openpbrMaterialLoadingAdapter.d.ts +3 -3
- package/glTF/2.0/openpbrMaterialLoadingAdapter.js +17 -18
- package/glTF/2.0/openpbrMaterialLoadingAdapter.js.map +1 -1
- package/glTF/2.0/pbrMaterialLoadingAdapter.d.ts +6 -0
- package/glTF/2.0/pbrMaterialLoadingAdapter.js +5 -0
- package/glTF/2.0/pbrMaterialLoadingAdapter.js.map +1 -1
- package/package.json +3 -3
package/glTF/2.0/glTFLoader.d.ts
CHANGED
|
@@ -72,8 +72,6 @@ type PBRMaterialImplementation = {
|
|
|
72
72
|
export declare class GLTFLoader implements IGLTFLoader {
|
|
73
73
|
/** @internal */
|
|
74
74
|
readonly _completePromises: Promise<unknown>[];
|
|
75
|
-
/** AbortController used to cancel in-flight finalizeAsync() calls when dispose() is called. */
|
|
76
|
-
private _finalizeController;
|
|
77
75
|
/** @internal */
|
|
78
76
|
_assetContainer: Nullable<AssetContainer>;
|
|
79
77
|
/** Storage */
|
|
@@ -86,7 +84,8 @@ export declare class GLTFLoader implements IGLTFLoader {
|
|
|
86
84
|
_skipStartAnimationStep: boolean;
|
|
87
85
|
private readonly _parent;
|
|
88
86
|
private readonly _extensions;
|
|
89
|
-
|
|
87
|
+
/** @internal */
|
|
88
|
+
_disposed: boolean;
|
|
90
89
|
private _rootUrl;
|
|
91
90
|
private _fileName;
|
|
92
91
|
private _uniqueRootUrl;
|
package/glTF/2.0/glTFLoader.js
CHANGED
|
@@ -10,6 +10,7 @@ import { Material } from "@babylonjs/core/Materials/material.js";
|
|
|
10
10
|
import { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
|
|
11
11
|
import { TransformNode } from "@babylonjs/core/Meshes/transformNode.js";
|
|
12
12
|
import { Buffer, VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
|
|
13
|
+
import { VertexBufferForEach, VertexBufferGetTypeByteLength } from "@babylonjs/core/Buffers/buffer.pure.js";
|
|
13
14
|
import { Geometry } from "@babylonjs/core/Meshes/geometry.js";
|
|
14
15
|
import { AbstractMesh } from "@babylonjs/core/Meshes/abstractMesh.js";
|
|
15
16
|
import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
|
@@ -181,8 +182,6 @@ export class GLTFLoader {
|
|
|
181
182
|
constructor(parent) {
|
|
182
183
|
/** @internal */
|
|
183
184
|
this._completePromises = new Array();
|
|
184
|
-
/** AbortController used to cancel in-flight finalizeAsync() calls when dispose() is called. */
|
|
185
|
-
this._finalizeController = null;
|
|
186
185
|
/** @internal */
|
|
187
186
|
this._assetContainer = null;
|
|
188
187
|
/** Storage */
|
|
@@ -194,6 +193,7 @@ export class GLTFLoader {
|
|
|
194
193
|
/** @internal */
|
|
195
194
|
this._skipStartAnimationStep = false;
|
|
196
195
|
this._extensions = new Array();
|
|
196
|
+
/** @internal */
|
|
197
197
|
this._disposed = false;
|
|
198
198
|
this._rootUrl = null;
|
|
199
199
|
this._fileName = null;
|
|
@@ -235,8 +235,6 @@ export class GLTFLoader {
|
|
|
235
235
|
return;
|
|
236
236
|
}
|
|
237
237
|
this._disposed = true;
|
|
238
|
-
this._finalizeController?.abort();
|
|
239
|
-
this._finalizeController = null;
|
|
240
238
|
this._completePromises.length = 0;
|
|
241
239
|
this._extensions.forEach((extension) => extension.dispose && extension.dispose());
|
|
242
240
|
this._extensions.length = 0;
|
|
@@ -377,25 +375,10 @@ export class GLTFLoader {
|
|
|
377
375
|
}
|
|
378
376
|
}
|
|
379
377
|
// Finalize all material adapters. finalizeAsync() may return a Promise for async
|
|
380
|
-
// work (e.g. GPU texture processing);
|
|
381
|
-
// _completePromises so
|
|
382
|
-
// Fall back to the deprecated finalize() for third-party adapters that have not
|
|
383
|
-
// yet migrated, logging a warning so authors know to update.
|
|
384
|
-
// An AbortController is created here and aborted in dispose() so that adapters
|
|
385
|
-
// can detect mid-flight disposal and clean up intermediate resources early.
|
|
386
|
-
this._finalizeController = new AbortController();
|
|
387
|
-
const finalizeSignal = this._finalizeController.signal;
|
|
378
|
+
// work (e.g. GPU texture processing); any returned Promise is pushed into
|
|
379
|
+
// _completePromises so it is awaited before the COMPLETE state is reached.
|
|
388
380
|
for (const adapter of Array.from(this._materialAdapters)) {
|
|
389
|
-
|
|
390
|
-
const finalizePromise = adapter.finalizeAsync(finalizeSignal);
|
|
391
|
-
if (finalizePromise) {
|
|
392
|
-
this._completePromises.push(finalizePromise);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
else if (adapter.finalize) {
|
|
396
|
-
Logger.Warn("GLTFLoader: IMaterialLoadingAdapter.finalize() is deprecated. Implement finalizeAsync() instead.");
|
|
397
|
-
adapter.finalize();
|
|
398
|
-
}
|
|
381
|
+
this._completePromises.push(adapter.finalizeAsync(this));
|
|
399
382
|
}
|
|
400
383
|
this._extensionsOnReady();
|
|
401
384
|
this._parent._setState(GLTFLoaderState.READY);
|
|
@@ -1621,7 +1604,7 @@ export class GLTFLoader {
|
|
|
1621
1604
|
return accessor._data;
|
|
1622
1605
|
}
|
|
1623
1606
|
const numComponents = GLTFLoader._GetNumComponents(context, accessor.type);
|
|
1624
|
-
const byteStride = numComponents *
|
|
1607
|
+
const byteStride = numComponents * VertexBufferGetTypeByteLength(accessor.componentType);
|
|
1625
1608
|
const length = numComponents * accessor.count;
|
|
1626
1609
|
if (accessor.bufferView == undefined) {
|
|
1627
1610
|
accessor._data = Promise.resolve(new constructor(length));
|
|
@@ -1634,7 +1617,7 @@ export class GLTFLoader {
|
|
|
1634
1617
|
}
|
|
1635
1618
|
else {
|
|
1636
1619
|
const typedArray = new constructor(length);
|
|
1637
|
-
|
|
1620
|
+
VertexBufferForEach(data, accessor.byteOffset || 0, bufferView.byteStride || byteStride, numComponents, accessor.componentType, typedArray.length, accessor.normalized || false, (value, index) => {
|
|
1638
1621
|
typedArray[index] = value;
|
|
1639
1622
|
});
|
|
1640
1623
|
return typedArray;
|
|
@@ -1660,7 +1643,7 @@ export class GLTFLoader {
|
|
|
1660
1643
|
else {
|
|
1661
1644
|
const sparseData = GLTFLoader._GetTypedArray(`${context}/sparse/values`, accessor.componentType, valuesData, sparse.values.byteOffset, sparseLength);
|
|
1662
1645
|
values = new constructor(sparseLength);
|
|
1663
|
-
|
|
1646
|
+
VertexBufferForEach(sparseData, 0, byteStride, numComponents, accessor.componentType, values.length, accessor.normalized || false, (value, index) => {
|
|
1664
1647
|
values[index] = value;
|
|
1665
1648
|
});
|
|
1666
1649
|
}
|
|
@@ -2219,7 +2202,7 @@ export class GLTFLoader {
|
|
|
2219
2202
|
const buffer = bufferView.buffer;
|
|
2220
2203
|
byteOffset = bufferView.byteOffset + (byteOffset || 0);
|
|
2221
2204
|
const constructor = GLTFLoader._GetTypedArrayConstructor(`${context}/componentType`, componentType);
|
|
2222
|
-
const componentTypeLength =
|
|
2205
|
+
const componentTypeLength = VertexBufferGetTypeByteLength(componentType);
|
|
2223
2206
|
if (byteOffset % componentTypeLength !== 0) {
|
|
2224
2207
|
// HACK: Copy the buffer if byte offset is not a multiple of component type byte length.
|
|
2225
2208
|
Logger.Warn(`${context}: Copying buffer as byte offset (${byteOffset}) is not a multiple of component type byte length (${componentTypeLength})`);
|