babylonjs-loaders 6.21.1 → 6.21.3
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
|
@@ -817,6 +817,10 @@ var KHR_draco_mesh_compression = /** @class */ (function () {
|
|
|
817
817
|
* The name of this extension.
|
|
818
818
|
*/
|
|
819
819
|
this.name = NAME;
|
|
820
|
+
/**
|
|
821
|
+
* Defines whether to use the normalized flag from the glTF accessor instead of the Draco data. Defaults to true.
|
|
822
|
+
*/
|
|
823
|
+
this.useNormalizedFlagFromAccessor = true;
|
|
820
824
|
this._loader = loader;
|
|
821
825
|
this.enabled = babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME);
|
|
822
826
|
}
|
|
@@ -841,6 +845,7 @@ var KHR_draco_mesh_compression = /** @class */ (function () {
|
|
|
841
845
|
}
|
|
842
846
|
}
|
|
843
847
|
var attributes = {};
|
|
848
|
+
var normalized = {};
|
|
844
849
|
var loadAttribute = function (name, kind) {
|
|
845
850
|
var uniqueId = extension.attributes[name];
|
|
846
851
|
if (uniqueId == undefined) {
|
|
@@ -851,6 +856,12 @@ var KHR_draco_mesh_compression = /** @class */ (function () {
|
|
|
851
856
|
babylonMesh._delayInfo.push(kind);
|
|
852
857
|
}
|
|
853
858
|
attributes[kind] = uniqueId;
|
|
859
|
+
if (_this.useNormalizedFlagFromAccessor) {
|
|
860
|
+
var accessor = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.TryGet(_this._loader.gltf.accessors, primitive.attributes[name]);
|
|
861
|
+
if (accessor) {
|
|
862
|
+
normalized[kind] = accessor.normalized || false;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
854
865
|
};
|
|
855
866
|
loadAttribute("POSITION", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind);
|
|
856
867
|
loadAttribute("NORMAL", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind);
|
|
@@ -868,7 +879,7 @@ var KHR_draco_mesh_compression = /** @class */ (function () {
|
|
|
868
879
|
if (!bufferView._dracoBabylonGeometry) {
|
|
869
880
|
bufferView._dracoBabylonGeometry = _this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) {
|
|
870
881
|
var dracoCompression = _this.dracoCompression || babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.DracoCompression.Default;
|
|
871
|
-
return dracoCompression.
|
|
882
|
+
return dracoCompression._decodeMeshToGeometryForGltfAsync(babylonMesh.name, _this._loader.babylonScene, data, attributes, normalized).catch(function (error) {
|
|
872
883
|
throw new Error("".concat(context, ": ").concat(error.message));
|
|
873
884
|
});
|
|
874
885
|
});
|
|
@@ -3688,6 +3699,18 @@ var ArrayItem = /** @class */ (function () {
|
|
|
3688
3699
|
}
|
|
3689
3700
|
return array[index];
|
|
3690
3701
|
};
|
|
3702
|
+
/**
|
|
3703
|
+
* Gets an item from the given array or returns null if not available.
|
|
3704
|
+
* @param array The array to get the item from
|
|
3705
|
+
* @param index The index to the array
|
|
3706
|
+
* @returns The array item or null
|
|
3707
|
+
*/
|
|
3708
|
+
ArrayItem.TryGet = function (array, index) {
|
|
3709
|
+
if (!array || index == undefined || !array[index]) {
|
|
3710
|
+
return null;
|
|
3711
|
+
}
|
|
3712
|
+
return array[index];
|
|
3713
|
+
};
|
|
3691
3714
|
/**
|
|
3692
3715
|
* Assign an `index` field to each item of the given array.
|
|
3693
3716
|
* @param array The array of items
|
|
@@ -4458,15 +4481,15 @@ var GLTFLoader = /** @class */ (function () {
|
|
|
4458
4481
|
babylonGeometry.setIndices(data);
|
|
4459
4482
|
}));
|
|
4460
4483
|
}
|
|
4461
|
-
var loadAttribute = function (
|
|
4462
|
-
if (attributes[
|
|
4484
|
+
var loadAttribute = function (name, kind, callback) {
|
|
4485
|
+
if (attributes[name] == undefined) {
|
|
4463
4486
|
return;
|
|
4464
4487
|
}
|
|
4465
4488
|
babylonMesh._delayInfo = babylonMesh._delayInfo || [];
|
|
4466
4489
|
if (babylonMesh._delayInfo.indexOf(kind) === -1) {
|
|
4467
4490
|
babylonMesh._delayInfo.push(kind);
|
|
4468
4491
|
}
|
|
4469
|
-
var accessor = ArrayItem.Get("".concat(context, "/attributes/").concat(
|
|
4492
|
+
var accessor = ArrayItem.Get("".concat(context, "/attributes/").concat(name), _this._gltf.accessors, attributes[name]);
|
|
4470
4493
|
promises.push(_this._loadVertexAccessorAsync("/accessors/".concat(accessor.index), accessor, kind).then(function (babylonVertexBuffer) {
|
|
4471
4494
|
var _a, _b;
|
|
4472
4495
|
if (babylonVertexBuffer.getKind() === babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind && !_this.parent.alwaysComputeBoundingBox && !babylonMesh.skeleton) {
|