babylonjs-serializers 5.51.0 → 5.53.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.
@@ -1760,12 +1760,15 @@ var _GLTFAnimation = /** @class */ (function () {
1760
1760
  * @param convertToRightHandedSystem
1761
1761
  * @param animationSampleRate
1762
1762
  */
1763
- _GLTFAnimation._CreateNodeAnimationFromNodeAnimations = function (babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, nodes, binaryWriter, bufferViews, accessors, convertToRightHandedSystem, animationSampleRate) {
1763
+ _GLTFAnimation._CreateNodeAnimationFromNodeAnimations = function (babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, nodes, binaryWriter, bufferViews, accessors, convertToRightHandedSystem, animationSampleRate, shouldExportAnimation) {
1764
1764
  var glTFAnimation;
1765
1765
  if (_GLTFAnimation._IsTransformable(babylonNode)) {
1766
1766
  if (babylonNode.animations) {
1767
1767
  for (var _i = 0, _a = babylonNode.animations; _i < _a.length; _i++) {
1768
1768
  var animation = _a[_i];
1769
+ if (shouldExportAnimation && !shouldExportAnimation(animation)) {
1770
+ continue;
1771
+ }
1769
1772
  var animationInfo = _GLTFAnimation._DeduceAnimationInfo(animation);
1770
1773
  if (animationInfo) {
1771
1774
  glTFAnimation = {
@@ -1796,7 +1799,7 @@ var _GLTFAnimation = /** @class */ (function () {
1796
1799
  * @param convertToRightHandedSystem
1797
1800
  * @param animationSampleRate
1798
1801
  */
1799
- _GLTFAnimation._CreateMorphTargetAnimationFromMorphTargetAnimations = function (babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, nodes, binaryWriter, bufferViews, accessors, convertToRightHandedSystem, animationSampleRate) {
1802
+ _GLTFAnimation._CreateMorphTargetAnimationFromMorphTargetAnimations = function (babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, nodes, binaryWriter, bufferViews, accessors, convertToRightHandedSystem, animationSampleRate, shouldExportAnimation) {
1800
1803
  var glTFAnimation;
1801
1804
  if (babylonNode instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Mesh) {
1802
1805
  var morphTargetManager = babylonNode.morphTargetManager;
@@ -1805,6 +1808,9 @@ var _GLTFAnimation = /** @class */ (function () {
1805
1808
  var morphTarget = morphTargetManager.getTarget(i);
1806
1809
  for (var _i = 0, _a = morphTarget.animations; _i < _a.length; _i++) {
1807
1810
  var animation = _a[_i];
1811
+ if (shouldExportAnimation && !shouldExportAnimation(animation)) {
1812
+ continue;
1813
+ }
1808
1814
  var combinedAnimation = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Animation("".concat(animation.name), "influence", animation.framePerSecond, animation.dataType, animation.loopMode, animation.enableBlending);
1809
1815
  var combinedAnimationKeys = [];
1810
1816
  var animationKeys = animation.getKeys();
@@ -1850,7 +1856,7 @@ var _GLTFAnimation = /** @class */ (function () {
1850
1856
  * @param convertToRightHandedSystemMap
1851
1857
  * @param animationSampleRate
1852
1858
  */
1853
- _GLTFAnimation._CreateNodeAndMorphAnimationFromAnimationGroups = function (babylonScene, glTFAnimations, nodeMap, nodes, binaryWriter, bufferViews, accessors, convertToRightHandedSystemMap, animationSampleRate) {
1859
+ _GLTFAnimation._CreateNodeAndMorphAnimationFromAnimationGroups = function (babylonScene, glTFAnimations, nodeMap, nodes, binaryWriter, bufferViews, accessors, convertToRightHandedSystemMap, animationSampleRate, shouldExportAnimation) {
1854
1860
  var _a;
1855
1861
  var glTFAnimation;
1856
1862
  if (babylonScene.animationGroups) {
@@ -1869,6 +1875,9 @@ var _GLTFAnimation = /** @class */ (function () {
1869
1875
  var targetAnimation = animationGroup.targetedAnimations[i];
1870
1876
  var target = targetAnimation.target;
1871
1877
  var animation = targetAnimation.animation;
1878
+ if (shouldExportAnimation && !shouldExportAnimation(animation)) {
1879
+ return "continue";
1880
+ }
1872
1881
  if (this_1._IsTransformable(target) || (target.length === 1 && this_1._IsTransformable(target[0]))) {
1873
1882
  var animationInfo = _GLTFAnimation._DeduceAnimationInfo(targetAnimation.animation);
1874
1883
  if (animationInfo) {
@@ -3590,8 +3599,8 @@ var _Exporter = /** @class */ (function () {
3590
3599
  }
3591
3600
  };
3592
3601
  _Exporter.prototype._getVertexBufferFromMesh = function (attributeKind, bufferMesh) {
3593
- if (bufferMesh.isVerticesDataPresent(attributeKind)) {
3594
- var vertexBuffer = bufferMesh.getVertexBuffer(attributeKind);
3602
+ if (bufferMesh.isVerticesDataPresent(attributeKind, true)) {
3603
+ var vertexBuffer = bufferMesh.getVertexBuffer(attributeKind, true);
3595
3604
  if (vertexBuffer) {
3596
3605
  return vertexBuffer;
3597
3606
  }
@@ -3614,8 +3623,8 @@ var _Exporter = /** @class */ (function () {
3614
3623
  ? babylonTransformNode.sourceMesh
3615
3624
  : null;
3616
3625
  if (bufferMesh) {
3617
- var vertexBuffer = bufferMesh.getVertexBuffer(kind);
3618
- var vertexData = bufferMesh.getVerticesData(kind);
3626
+ var vertexBuffer = bufferMesh.getVertexBuffer(kind, true);
3627
+ var vertexData = bufferMesh.getVerticesData(kind, undefined, undefined, true);
3619
3628
  if (vertexBuffer && vertexData) {
3620
3629
  var typeByteLength = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.VertexBuffer.GetTypeByteLength(attributeComponentKind);
3621
3630
  var byteLength = vertexData.length * typeByteLength;
@@ -3639,8 +3648,9 @@ var _Exporter = /** @class */ (function () {
3639
3648
  meshPrimitive.targets = [];
3640
3649
  }
3641
3650
  var target = {};
3651
+ var mesh = babylonSubMesh.getMesh();
3642
3652
  if (babylonMorphTarget.hasNormals) {
3643
- var vertexNormals = babylonSubMesh.getMesh().getVerticesData(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.VertexBuffer.NormalKind);
3653
+ var vertexNormals = mesh.getVerticesData(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.VertexBuffer.NormalKind, undefined, undefined, true);
3644
3654
  var morphNormals = babylonMorphTarget.getNormals();
3645
3655
  var count = babylonSubMesh.verticesCount;
3646
3656
  var byteStride = 12; // 3 x 4 byte floats
@@ -3654,7 +3664,7 @@ var _Exporter = /** @class */ (function () {
3654
3664
  this.writeMorphTargetAttributeData(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.VertexBuffer.NormalKind, 5126 /* AccessorComponentType.FLOAT */, babylonSubMesh, babylonMorphTarget, vertexNormals, morphNormals, byteStride / 4, binaryWriter, convertToRightHandedSystem);
3655
3665
  }
3656
3666
  if (babylonMorphTarget.hasPositions) {
3657
- var vertexPositions = babylonSubMesh.getMesh().getVerticesData(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.VertexBuffer.PositionKind);
3667
+ var vertexPositions = mesh.getVerticesData(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.VertexBuffer.PositionKind, undefined, undefined, true);
3658
3668
  var morphPositions = babylonMorphTarget.getPositions();
3659
3669
  var count = babylonSubMesh.verticesCount;
3660
3670
  var byteStride = 12; // 3 x 4 byte floats
@@ -3671,7 +3681,7 @@ var _Exporter = /** @class */ (function () {
3671
3681
  accessor.max = minMax.max.asArray();
3672
3682
  }
3673
3683
  if (babylonMorphTarget.hasTangents) {
3674
- var vertexTangents = babylonSubMesh.getMesh().getVerticesData(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.VertexBuffer.TangentKind);
3684
+ var vertexTangents = mesh.getVerticesData(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.VertexBuffer.TangentKind, undefined, undefined, true);
3675
3685
  var morphTangents = babylonMorphTarget.getTangents();
3676
3686
  var count = babylonSubMesh.verticesCount;
3677
3687
  var byteStride = 12; // 3 x 4 byte floats
@@ -3832,7 +3842,7 @@ var _Exporter = /** @class */ (function () {
3832
3842
  var attribute = attributeData_1[_i];
3833
3843
  var attributeKind = attribute.kind;
3834
3844
  var attributeComponentKind = attribute.accessorComponentType;
3835
- if (bufferMesh.isVerticesDataPresent(attributeKind)) {
3845
+ if (bufferMesh.isVerticesDataPresent(attributeKind, true)) {
3836
3846
  var vertexBuffer = this._getVertexBufferFromMesh(attributeKind, bufferMesh);
3837
3847
  attribute.byteStride = vertexBuffer
3838
3848
  ? vertexBuffer.getSize() * core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.VertexBuffer.GetTypeByteLength(attribute.accessorComponentType)
@@ -3899,7 +3909,7 @@ var _Exporter = /** @class */ (function () {
3899
3909
  continue;
3900
3910
  }
3901
3911
  }
3902
- var vertexData = bufferMesh.getVerticesData(attributeKind);
3912
+ var vertexData = bufferMesh.getVerticesData(attributeKind, undefined, undefined, true);
3903
3913
  if (vertexData) {
3904
3914
  var vertexBuffer = this._getVertexBufferFromMesh(attributeKind, bufferMesh);
3905
3915
  if (vertexBuffer) {
@@ -3944,7 +3954,7 @@ var _Exporter = /** @class */ (function () {
3944
3954
  else {
3945
3955
  for (var _e = 0, attributeData_3 = attributeData; _e < attributeData_3.length; _e++) {
3946
3956
  var attribute = attributeData_3[_e];
3947
- var vertexData = bufferMesh.getVerticesData(attribute.kind);
3957
+ var vertexData = bufferMesh.getVerticesData(attribute.kind, undefined, undefined, true);
3948
3958
  if (vertexData) {
3949
3959
  var byteOffset_1 = this._bufferViews[vertexAttributeBufferViews[attribute.kind]].byteOffset;
3950
3960
  if (!byteOffset_1) {
@@ -4220,9 +4230,9 @@ var _Exporter = /** @class */ (function () {
4220
4230
  nodeIndex = _this._nodes.length - 1;
4221
4231
  nodeMap[babylonNode.uniqueId] = nodeIndex;
4222
4232
  if (!babylonScene.animationGroups.length) {
4223
- _glTFAnimation__WEBPACK_IMPORTED_MODULE_5__._GLTFAnimation._CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, _this._nodes, binaryWriter, _this._bufferViews, _this._accessors, convertToRightHandedSystem, _this._animationSampleRate);
4233
+ _glTFAnimation__WEBPACK_IMPORTED_MODULE_5__._GLTFAnimation._CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, _this._nodes, binaryWriter, _this._bufferViews, _this._accessors, convertToRightHandedSystem, _this._animationSampleRate, _this._options.shouldExportAnimation);
4224
4234
  if (babylonNode.animations.length) {
4225
- _glTFAnimation__WEBPACK_IMPORTED_MODULE_5__._GLTFAnimation._CreateNodeAnimationFromNodeAnimations(babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, _this._nodes, binaryWriter, _this._bufferViews, _this._accessors, convertToRightHandedSystem, _this._animationSampleRate);
4235
+ _glTFAnimation__WEBPACK_IMPORTED_MODULE_5__._GLTFAnimation._CreateNodeAnimationFromNodeAnimations(babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, _this._nodes, binaryWriter, _this._bufferViews, _this._accessors, convertToRightHandedSystem, _this._animationSampleRate, _this._options.shouldExportAnimation);
4226
4236
  }
4227
4237
  }
4228
4238
  });
@@ -4244,7 +4254,7 @@ var _Exporter = /** @class */ (function () {
4244
4254
  }
4245
4255
  });
4246
4256
  if (babylonScene.animationGroups.length) {
4247
- _glTFAnimation__WEBPACK_IMPORTED_MODULE_5__._GLTFAnimation._CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene, _this._animations, nodeMap, _this._nodes, binaryWriter, _this._bufferViews, _this._accessors, _this._convertToRightHandedSystemMap, _this._animationSampleRate);
4257
+ _glTFAnimation__WEBPACK_IMPORTED_MODULE_5__._GLTFAnimation._CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene, _this._animations, nodeMap, _this._nodes, binaryWriter, _this._bufferViews, _this._accessors, _this._convertToRightHandedSystemMap, _this._animationSampleRate, _this._options.shouldExportAnimation);
4248
4258
  }
4249
4259
  return nodeMap;
4250
4260
  });