@onerjs/loaders 8.51.5 → 8.51.6
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
|
@@ -11,6 +11,7 @@ import { Material } from "@onerjs/core/Materials/material.js";
|
|
|
11
11
|
import { Texture } from "@onerjs/core/Materials/Textures/texture.js";
|
|
12
12
|
import { TransformNode } from "@onerjs/core/Meshes/transformNode.js";
|
|
13
13
|
import { Buffer, VertexBuffer } from "@onerjs/core/Buffers/buffer.js";
|
|
14
|
+
import { VertexBufferForEach, VertexBufferGetTypeByteLength } from "@onerjs/core/Buffers/buffer.pure.js";
|
|
14
15
|
import { Geometry } from "@onerjs/core/Meshes/geometry.js";
|
|
15
16
|
import { AbstractMesh } from "@onerjs/core/Meshes/abstractMesh.js";
|
|
16
17
|
import { Mesh } from "@onerjs/core/Meshes/mesh.js";
|
|
@@ -182,8 +183,6 @@ export class GLTFLoader {
|
|
|
182
183
|
constructor(parent) {
|
|
183
184
|
/** @internal */
|
|
184
185
|
this._completePromises = new Array();
|
|
185
|
-
/** AbortController used to cancel in-flight finalizeAsync() calls when dispose() is called. */
|
|
186
|
-
this._finalizeController = null;
|
|
187
186
|
/** @internal */
|
|
188
187
|
this._assetContainer = null;
|
|
189
188
|
/** Storage */
|
|
@@ -195,6 +194,7 @@ export class GLTFLoader {
|
|
|
195
194
|
/** @internal */
|
|
196
195
|
this._skipStartAnimationStep = false;
|
|
197
196
|
this._extensions = new Array();
|
|
197
|
+
/** @internal */
|
|
198
198
|
this._disposed = false;
|
|
199
199
|
this._rootUrl = null;
|
|
200
200
|
this._fileName = null;
|
|
@@ -236,8 +236,6 @@ export class GLTFLoader {
|
|
|
236
236
|
return;
|
|
237
237
|
}
|
|
238
238
|
this._disposed = true;
|
|
239
|
-
this._finalizeController?.abort();
|
|
240
|
-
this._finalizeController = null;
|
|
241
239
|
this._completePromises.length = 0;
|
|
242
240
|
this._extensions.forEach((extension) => extension.dispose && extension.dispose());
|
|
243
241
|
this._extensions.length = 0;
|
|
@@ -380,25 +378,10 @@ export class GLTFLoader {
|
|
|
380
378
|
}
|
|
381
379
|
}
|
|
382
380
|
// Finalize all material adapters. finalizeAsync() may return a Promise for async
|
|
383
|
-
// work (e.g. GPU texture processing);
|
|
384
|
-
// _completePromises so
|
|
385
|
-
// Fall back to the deprecated finalize() for third-party adapters that have not
|
|
386
|
-
// yet migrated, logging a warning so authors know to update.
|
|
387
|
-
// An AbortController is created here and aborted in dispose() so that adapters
|
|
388
|
-
// can detect mid-flight disposal and clean up intermediate resources early.
|
|
389
|
-
this._finalizeController = new AbortController();
|
|
390
|
-
const finalizeSignal = this._finalizeController.signal;
|
|
381
|
+
// work (e.g. GPU texture processing); any returned Promise is pushed into
|
|
382
|
+
// _completePromises so it is awaited before the COMPLETE state is reached.
|
|
391
383
|
for (const adapter of Array.from(this._materialAdapters)) {
|
|
392
|
-
|
|
393
|
-
const finalizePromise = adapter.finalizeAsync(finalizeSignal);
|
|
394
|
-
if (finalizePromise) {
|
|
395
|
-
this._completePromises.push(finalizePromise);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
else if (adapter.finalize) {
|
|
399
|
-
Logger.Warn("GLTFLoader: IMaterialLoadingAdapter.finalize() is deprecated. Implement finalizeAsync() instead.");
|
|
400
|
-
adapter.finalize();
|
|
401
|
-
}
|
|
384
|
+
this._completePromises.push(adapter.finalizeAsync(this));
|
|
402
385
|
}
|
|
403
386
|
this._extensionsOnReady();
|
|
404
387
|
this._parent._setState(GLTFLoaderState.READY);
|
|
@@ -1652,7 +1635,7 @@ export class GLTFLoader {
|
|
|
1652
1635
|
return accessor._data;
|
|
1653
1636
|
}
|
|
1654
1637
|
const numComponents = GLTFLoader._GetNumComponents(context, accessor.type);
|
|
1655
|
-
const byteStride = numComponents *
|
|
1638
|
+
const byteStride = numComponents * VertexBufferGetTypeByteLength(accessor.componentType);
|
|
1656
1639
|
const length = numComponents * accessor.count;
|
|
1657
1640
|
if (accessor.bufferView == undefined) {
|
|
1658
1641
|
accessor._data = Promise.resolve(new constructor(length));
|
|
@@ -1665,7 +1648,7 @@ export class GLTFLoader {
|
|
|
1665
1648
|
}
|
|
1666
1649
|
else {
|
|
1667
1650
|
const typedArray = new constructor(length);
|
|
1668
|
-
|
|
1651
|
+
VertexBufferForEach(data, accessor.byteOffset || 0, bufferView.byteStride || byteStride, numComponents, accessor.componentType, typedArray.length, accessor.normalized || false, (value, index) => {
|
|
1669
1652
|
typedArray[index] = value;
|
|
1670
1653
|
});
|
|
1671
1654
|
return typedArray;
|
|
@@ -1691,7 +1674,7 @@ export class GLTFLoader {
|
|
|
1691
1674
|
else {
|
|
1692
1675
|
const sparseData = GLTFLoader._GetTypedArray(`${context}/sparse/values`, accessor.componentType, valuesData, sparse.values.byteOffset, sparseLength);
|
|
1693
1676
|
values = new constructor(sparseLength);
|
|
1694
|
-
|
|
1677
|
+
VertexBufferForEach(sparseData, 0, byteStride, numComponents, accessor.componentType, values.length, accessor.normalized || false, (value, index) => {
|
|
1695
1678
|
values[index] = value;
|
|
1696
1679
|
});
|
|
1697
1680
|
}
|
|
@@ -2249,7 +2232,7 @@ export class GLTFLoader {
|
|
|
2249
2232
|
const buffer = bufferView.buffer;
|
|
2250
2233
|
byteOffset = bufferView.byteOffset + (byteOffset || 0);
|
|
2251
2234
|
const constructor = GLTFLoader._GetTypedArrayConstructor(`${context}/componentType`, componentType);
|
|
2252
|
-
const componentTypeLength =
|
|
2235
|
+
const componentTypeLength = VertexBufferGetTypeByteLength(componentType);
|
|
2253
2236
|
if (byteOffset % componentTypeLength !== 0) {
|
|
2254
2237
|
// HACK: Copy the buffer if byte offset is not a multiple of component type byte length.
|
|
2255
2238
|
Logger.Warn(`${context}: Copying buffer as byte offset (${byteOffset}) is not a multiple of component type byte length (${componentTypeLength})`);
|