babylonjs-loaders 6.21.1 → 6.21.2
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/babylon.glTF2FileLoader.js +27 -4
- package/babylon.glTF2FileLoader.js.map +1 -1
- package/babylon.glTF2FileLoader.min.js +1 -1
- package/babylon.glTF2FileLoader.min.js.map +1 -1
- package/babylon.glTFFileLoader.js +27 -4
- package/babylon.glTFFileLoader.js.map +1 -1
- package/babylon.glTFFileLoader.min.js +1 -1
- package/babylon.glTFFileLoader.min.js.map +1 -1
- package/babylon.stlFileLoader.js +1 -6
- package/babylon.stlFileLoader.js.map +1 -1
- package/babylon.stlFileLoader.min.js +1 -1
- package/babylon.stlFileLoader.min.js.map +1 -1
- package/babylonjs.loaders.d.ts +11 -0
- package/babylonjs.loaders.js +28 -10
- package/babylonjs.loaders.js.map +1 -1
- package/babylonjs.loaders.min.js +1 -1
- package/babylonjs.loaders.min.js.map +1 -1
- package/babylonjs.loaders.module.d.ts +22 -0
- package/package.json +3 -3
|
@@ -3304,6 +3304,10 @@ var KHR_draco_mesh_compression = /** @class */ (function () {
|
|
|
3304
3304
|
* The name of this extension.
|
|
3305
3305
|
*/
|
|
3306
3306
|
this.name = NAME;
|
|
3307
|
+
/**
|
|
3308
|
+
* Defines whether to use the normalized flag from the glTF accessor instead of the Draco data. Defaults to true.
|
|
3309
|
+
*/
|
|
3310
|
+
this.useNormalizedFlagFromAccessor = true;
|
|
3307
3311
|
this._loader = loader;
|
|
3308
3312
|
this.enabled = babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME);
|
|
3309
3313
|
}
|
|
@@ -3328,6 +3332,7 @@ var KHR_draco_mesh_compression = /** @class */ (function () {
|
|
|
3328
3332
|
}
|
|
3329
3333
|
}
|
|
3330
3334
|
var attributes = {};
|
|
3335
|
+
var normalized = {};
|
|
3331
3336
|
var loadAttribute = function (name, kind) {
|
|
3332
3337
|
var uniqueId = extension.attributes[name];
|
|
3333
3338
|
if (uniqueId == undefined) {
|
|
@@ -3338,6 +3343,12 @@ var KHR_draco_mesh_compression = /** @class */ (function () {
|
|
|
3338
3343
|
babylonMesh._delayInfo.push(kind);
|
|
3339
3344
|
}
|
|
3340
3345
|
attributes[kind] = uniqueId;
|
|
3346
|
+
if (_this.useNormalizedFlagFromAccessor) {
|
|
3347
|
+
var accessor = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.TryGet(_this._loader.gltf.accessors, primitive.attributes[name]);
|
|
3348
|
+
if (accessor) {
|
|
3349
|
+
normalized[kind] = accessor.normalized || false;
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3341
3352
|
};
|
|
3342
3353
|
loadAttribute("POSITION", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind);
|
|
3343
3354
|
loadAttribute("NORMAL", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind);
|
|
@@ -3355,7 +3366,7 @@ var KHR_draco_mesh_compression = /** @class */ (function () {
|
|
|
3355
3366
|
if (!bufferView._dracoBabylonGeometry) {
|
|
3356
3367
|
bufferView._dracoBabylonGeometry = _this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) {
|
|
3357
3368
|
var dracoCompression = _this.dracoCompression || babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.DracoCompression.Default;
|
|
3358
|
-
return dracoCompression.
|
|
3369
|
+
return dracoCompression._decodeMeshToGeometryForGltfAsync(babylonMesh.name, _this._loader.babylonScene, data, attributes, normalized).catch(function (error) {
|
|
3359
3370
|
throw new Error("".concat(context, ": ").concat(error.message));
|
|
3360
3371
|
});
|
|
3361
3372
|
});
|
|
@@ -6175,6 +6186,18 @@ var ArrayItem = /** @class */ (function () {
|
|
|
6175
6186
|
}
|
|
6176
6187
|
return array[index];
|
|
6177
6188
|
};
|
|
6189
|
+
/**
|
|
6190
|
+
* Gets an item from the given array or returns null if not available.
|
|
6191
|
+
* @param array The array to get the item from
|
|
6192
|
+
* @param index The index to the array
|
|
6193
|
+
* @returns The array item or null
|
|
6194
|
+
*/
|
|
6195
|
+
ArrayItem.TryGet = function (array, index) {
|
|
6196
|
+
if (!array || index == undefined || !array[index]) {
|
|
6197
|
+
return null;
|
|
6198
|
+
}
|
|
6199
|
+
return array[index];
|
|
6200
|
+
};
|
|
6178
6201
|
/**
|
|
6179
6202
|
* Assign an `index` field to each item of the given array.
|
|
6180
6203
|
* @param array The array of items
|
|
@@ -6945,15 +6968,15 @@ var GLTFLoader = /** @class */ (function () {
|
|
|
6945
6968
|
babylonGeometry.setIndices(data);
|
|
6946
6969
|
}));
|
|
6947
6970
|
}
|
|
6948
|
-
var loadAttribute = function (
|
|
6949
|
-
if (attributes[
|
|
6971
|
+
var loadAttribute = function (name, kind, callback) {
|
|
6972
|
+
if (attributes[name] == undefined) {
|
|
6950
6973
|
return;
|
|
6951
6974
|
}
|
|
6952
6975
|
babylonMesh._delayInfo = babylonMesh._delayInfo || [];
|
|
6953
6976
|
if (babylonMesh._delayInfo.indexOf(kind) === -1) {
|
|
6954
6977
|
babylonMesh._delayInfo.push(kind);
|
|
6955
6978
|
}
|
|
6956
|
-
var accessor = ArrayItem.Get("".concat(context, "/attributes/").concat(
|
|
6979
|
+
var accessor = ArrayItem.Get("".concat(context, "/attributes/").concat(name), _this._gltf.accessors, attributes[name]);
|
|
6957
6980
|
promises.push(_this._loadVertexAccessorAsync("/accessors/".concat(accessor.index), accessor, kind).then(function (babylonVertexBuffer) {
|
|
6958
6981
|
var _a, _b;
|
|
6959
6982
|
if (babylonVertexBuffer.getKind() === babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind && !_this.parent.alwaysComputeBoundingBox && !babylonMesh.skeleton) {
|