babylonjs-serializers 5.13.3 → 5.15.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/babylon.glTF2Serializer.js +68 -53
- package/babylon.glTF2Serializer.js.map +1 -1
- package/babylon.glTF2Serializer.min.js +1 -1
- package/babylon.glTF2Serializer.min.js.map +1 -1
- package/babylonjs.serializers.d.ts +7 -1
- package/babylonjs.serializers.js +68 -53
- package/babylonjs.serializers.js.map +1 -1
- package/babylonjs.serializers.min.js +1 -1
- package/babylonjs.serializers.min.js.map +1 -1
- package/babylonjs.serializers.module.d.ts +14 -3
- package/package.json +3 -3
|
@@ -1591,7 +1591,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1591
1591
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1592
1592
|
/* harmony export */ "_GLTFAnimation": () => (/* binding */ _GLTFAnimation)
|
|
1593
1593
|
/* harmony export */ });
|
|
1594
|
-
/* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/
|
|
1594
|
+
/* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Lights/light */ "core/Maths/math.vector");
|
|
1595
1595
|
/* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
|
|
1596
1596
|
/* harmony import */ var _glTFUtilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFUtilities */ "../../../lts/serializers/dist/glTF/2.0/glTFUtilities.js");
|
|
1597
1597
|
|
|
@@ -1602,6 +1602,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1602
1602
|
|
|
1603
1603
|
|
|
1604
1604
|
|
|
1605
|
+
|
|
1606
|
+
|
|
1605
1607
|
/**
|
|
1606
1608
|
* @hidden
|
|
1607
1609
|
* Enum for handling in tangent and out tangent.
|
|
@@ -1625,6 +1627,14 @@ var _TangentType;
|
|
|
1625
1627
|
var _GLTFAnimation = /** @class */ (function () {
|
|
1626
1628
|
function _GLTFAnimation() {
|
|
1627
1629
|
}
|
|
1630
|
+
/**
|
|
1631
|
+
* Determine if a node is transformable - ie has properties it should be part of animation of transformation.
|
|
1632
|
+
* @param babylonNode the node to test
|
|
1633
|
+
* @returns true if can be animated, false otherwise. False if the parameter is null or undefined.
|
|
1634
|
+
*/
|
|
1635
|
+
_GLTFAnimation._IsTransformable = function (babylonNode) {
|
|
1636
|
+
return babylonNode && (babylonNode instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TransformNode || babylonNode instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Camera || babylonNode instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Light);
|
|
1637
|
+
};
|
|
1628
1638
|
/**
|
|
1629
1639
|
* @ignore
|
|
1630
1640
|
*
|
|
@@ -1637,37 +1647,39 @@ var _GLTFAnimation = /** @class */ (function () {
|
|
|
1637
1647
|
* @returns nullable IAnimationData
|
|
1638
1648
|
*/
|
|
1639
1649
|
_GLTFAnimation._CreateNodeAnimation = function (babylonTransformNode, animation, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion, animationSampleRate) {
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
else {
|
|
1652
|
-
if (interpolation === "LINEAR" /* LINEAR */ || interpolation === "STEP" /* STEP */) {
|
|
1653
|
-
_GLTFAnimation._CreateLinearOrStepAnimation(babylonTransformNode, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
|
|
1654
|
-
}
|
|
1655
|
-
else if (interpolation === "CUBICSPLINE" /* CUBICSPLINE */) {
|
|
1656
|
-
_GLTFAnimation._CreateCubicSplineAnimation(babylonTransformNode, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
|
|
1650
|
+
if (this._IsTransformable(babylonTransformNode)) {
|
|
1651
|
+
var inputs = [];
|
|
1652
|
+
var outputs = [];
|
|
1653
|
+
var keyFrames = animation.getKeys();
|
|
1654
|
+
var minMaxKeyFrames = _GLTFAnimation._CalculateMinMaxKeyFrames(keyFrames);
|
|
1655
|
+
var interpolationOrBake = _GLTFAnimation._DeduceInterpolation(keyFrames, animationChannelTargetPath, useQuaternion);
|
|
1656
|
+
var frameDelta = minMaxKeyFrames.max - minMaxKeyFrames.min;
|
|
1657
|
+
var interpolation = interpolationOrBake.interpolationType;
|
|
1658
|
+
var shouldBakeAnimation = interpolationOrBake.shouldBakeAnimation;
|
|
1659
|
+
if (shouldBakeAnimation) {
|
|
1660
|
+
_GLTFAnimation._CreateBakedAnimation(babylonTransformNode, animation, animationChannelTargetPath, minMaxKeyFrames.min, minMaxKeyFrames.max, animation.framePerSecond, animationSampleRate, inputs, outputs, minMaxKeyFrames, convertToRightHandedSystem, useQuaternion);
|
|
1657
1661
|
}
|
|
1658
1662
|
else {
|
|
1659
|
-
|
|
1663
|
+
if (interpolation === "LINEAR" /* LINEAR */ || interpolation === "STEP" /* STEP */) {
|
|
1664
|
+
_GLTFAnimation._CreateLinearOrStepAnimation(babylonTransformNode, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
|
|
1665
|
+
}
|
|
1666
|
+
else if (interpolation === "CUBICSPLINE" /* CUBICSPLINE */) {
|
|
1667
|
+
_GLTFAnimation._CreateCubicSplineAnimation(babylonTransformNode, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
|
|
1668
|
+
}
|
|
1669
|
+
else {
|
|
1670
|
+
_GLTFAnimation._CreateBakedAnimation(babylonTransformNode, animation, animationChannelTargetPath, minMaxKeyFrames.min, minMaxKeyFrames.max, animation.framePerSecond, animationSampleRate, inputs, outputs, minMaxKeyFrames, convertToRightHandedSystem, useQuaternion);
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
if (inputs.length && outputs.length) {
|
|
1674
|
+
var result = {
|
|
1675
|
+
inputs: inputs,
|
|
1676
|
+
outputs: outputs,
|
|
1677
|
+
samplerInterpolation: interpolation,
|
|
1678
|
+
inputsMin: shouldBakeAnimation ? minMaxKeyFrames.min : core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.FloatRound(minMaxKeyFrames.min / animation.framePerSecond),
|
|
1679
|
+
inputsMax: shouldBakeAnimation ? minMaxKeyFrames.max : core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.FloatRound(minMaxKeyFrames.max / animation.framePerSecond),
|
|
1680
|
+
};
|
|
1681
|
+
return result;
|
|
1660
1682
|
}
|
|
1661
|
-
}
|
|
1662
|
-
if (inputs.length && outputs.length) {
|
|
1663
|
-
var result = {
|
|
1664
|
-
inputs: inputs,
|
|
1665
|
-
outputs: outputs,
|
|
1666
|
-
samplerInterpolation: interpolation,
|
|
1667
|
-
inputsMin: shouldBakeAnimation ? minMaxKeyFrames.min : core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.FloatRound(minMaxKeyFrames.min / animation.framePerSecond),
|
|
1668
|
-
inputsMax: shouldBakeAnimation ? minMaxKeyFrames.max : core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.FloatRound(minMaxKeyFrames.max / animation.framePerSecond),
|
|
1669
|
-
};
|
|
1670
|
-
return result;
|
|
1671
1683
|
}
|
|
1672
1684
|
return null;
|
|
1673
1685
|
};
|
|
@@ -1729,7 +1741,7 @@ var _GLTFAnimation = /** @class */ (function () {
|
|
|
1729
1741
|
*/
|
|
1730
1742
|
_GLTFAnimation._CreateNodeAnimationFromNodeAnimations = function (babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, nodes, binaryWriter, bufferViews, accessors, convertToRightHandedSystem, animationSampleRate) {
|
|
1731
1743
|
var glTFAnimation;
|
|
1732
|
-
if (babylonNode
|
|
1744
|
+
if (_GLTFAnimation._IsTransformable(babylonNode)) {
|
|
1733
1745
|
if (babylonNode.animations) {
|
|
1734
1746
|
for (var _i = 0, _a = babylonNode.animations; _i < _a.length; _i++) {
|
|
1735
1747
|
var animation = _a[_i];
|
|
@@ -1836,12 +1848,14 @@ var _GLTFAnimation = /** @class */ (function () {
|
|
|
1836
1848
|
var targetAnimation = animationGroup.targetedAnimations[i];
|
|
1837
1849
|
var target = targetAnimation.target;
|
|
1838
1850
|
var animation = targetAnimation.animation;
|
|
1839
|
-
if (target
|
|
1851
|
+
if (this_1._IsTransformable(target) || (target.length === 1 && this_1._IsTransformable(target[0]))) {
|
|
1840
1852
|
var animationInfo = _GLTFAnimation._DeduceAnimationInfo(targetAnimation.animation);
|
|
1841
1853
|
if (animationInfo) {
|
|
1842
|
-
var babylonTransformNode = target
|
|
1843
|
-
|
|
1844
|
-
|
|
1854
|
+
var babylonTransformNode = this_1._IsTransformable(target) ? target : this_1._IsTransformable(target[0]) ? target[0] : null;
|
|
1855
|
+
if (babylonTransformNode) {
|
|
1856
|
+
var convertToRightHandedSystem = convertToRightHandedSystemMap[babylonTransformNode.uniqueId];
|
|
1857
|
+
_GLTFAnimation._AddAnimation("".concat(animation.name), glTFAnimation, babylonTransformNode, animation, animationInfo.dataAccessorType, animationInfo.animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, convertToRightHandedSystem, animationInfo.useQuaternion, animationSampleRate);
|
|
1858
|
+
}
|
|
1845
1859
|
}
|
|
1846
1860
|
}
|
|
1847
1861
|
else if (target instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.MorphTarget || (target.length === 1 && target[0] instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.MorphTarget)) {
|
|
@@ -1926,6 +1940,7 @@ var _GLTFAnimation = /** @class */ (function () {
|
|
|
1926
1940
|
glTFAnimations.push(glTFAnimation);
|
|
1927
1941
|
}
|
|
1928
1942
|
};
|
|
1943
|
+
var this_1 = this;
|
|
1929
1944
|
for (var _i = 0, animationGroups_1 = animationGroups; _i < animationGroups_1.length; _i++) {
|
|
1930
1945
|
var animationGroup = animationGroups_1[_i];
|
|
1931
1946
|
_loop_1(animationGroup);
|
|
@@ -2120,10 +2135,14 @@ var _GLTFAnimation = /** @class */ (function () {
|
|
|
2120
2135
|
var animationType = animation.dataType;
|
|
2121
2136
|
var cacheValue;
|
|
2122
2137
|
inputs.push(time);
|
|
2123
|
-
if (typeof value === "number" && babylonTransformNode instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TransformNode) {
|
|
2124
|
-
value = this._ConvertFactorToVector3OrQuaternion(value, babylonTransformNode, animation, animationType, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion);
|
|
2125
|
-
}
|
|
2126
2138
|
if (value) {
|
|
2139
|
+
if (animationChannelTargetPath === "weights" /* WEIGHTS */) {
|
|
2140
|
+
outputs.push([value]);
|
|
2141
|
+
return;
|
|
2142
|
+
}
|
|
2143
|
+
if (typeof value === "number") {
|
|
2144
|
+
value = this._ConvertFactorToVector3OrQuaternion(value, babylonTransformNode, animation, animationType, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion);
|
|
2145
|
+
}
|
|
2127
2146
|
if (animationChannelTargetPath === "rotation" /* ROTATION */) {
|
|
2128
2147
|
if (useQuaternion) {
|
|
2129
2148
|
quaternionCache = value;
|
|
@@ -2140,9 +2159,6 @@ var _GLTFAnimation = /** @class */ (function () {
|
|
|
2140
2159
|
}
|
|
2141
2160
|
outputs.push(quaternionCache.asArray());
|
|
2142
2161
|
}
|
|
2143
|
-
else if (animationChannelTargetPath === "weights" /* WEIGHTS */) {
|
|
2144
|
-
outputs.push([value]);
|
|
2145
|
-
}
|
|
2146
2162
|
else {
|
|
2147
2163
|
// scaling and position animation
|
|
2148
2164
|
cacheValue = value;
|
|
@@ -2198,33 +2214,32 @@ var _GLTFAnimation = /** @class */ (function () {
|
|
|
2198
2214
|
var basePositionRotationOrScale;
|
|
2199
2215
|
if (animationChannelTargetPath === "rotation" /* ROTATION */) {
|
|
2200
2216
|
if (useQuaternion) {
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
}
|
|
2217
|
+
var q = babylonTransformNode.rotationQuaternion;
|
|
2218
|
+
basePositionRotationOrScale = (q !== null && q !== void 0 ? q : core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity()).asArray();
|
|
2219
|
+
if (convertToRightHandedSystem) {
|
|
2220
|
+
_glTFUtilities__WEBPACK_IMPORTED_MODULE_1__._GLTFUtilities._GetRightHandedQuaternionArrayFromRef(basePositionRotationOrScale);
|
|
2221
|
+
if (!babylonTransformNode.parent) {
|
|
2222
|
+
basePositionRotationOrScale = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray([0, 1, 0, 0]).multiply(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(basePositionRotationOrScale)).asArray();
|
|
2208
2223
|
}
|
|
2209
2224
|
}
|
|
2210
|
-
else {
|
|
2211
|
-
basePositionRotationOrScale = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity().asArray();
|
|
2212
|
-
}
|
|
2213
2225
|
}
|
|
2214
2226
|
else {
|
|
2215
|
-
|
|
2227
|
+
var r = babylonTransformNode.rotation;
|
|
2228
|
+
basePositionRotationOrScale = (r !== null && r !== void 0 ? r : core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero()).asArray();
|
|
2216
2229
|
_glTFUtilities__WEBPACK_IMPORTED_MODULE_1__._GLTFUtilities._GetRightHandedNormalArray3FromRef(basePositionRotationOrScale);
|
|
2217
2230
|
}
|
|
2218
2231
|
}
|
|
2219
2232
|
else if (animationChannelTargetPath === "translation" /* TRANSLATION */) {
|
|
2220
|
-
|
|
2233
|
+
var p = babylonTransformNode.position;
|
|
2234
|
+
basePositionRotationOrScale = (p !== null && p !== void 0 ? p : core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero()).asArray();
|
|
2221
2235
|
if (convertToRightHandedSystem) {
|
|
2222
2236
|
_glTFUtilities__WEBPACK_IMPORTED_MODULE_1__._GLTFUtilities._GetRightHandedPositionArray3FromRef(basePositionRotationOrScale);
|
|
2223
2237
|
}
|
|
2224
2238
|
}
|
|
2225
2239
|
else {
|
|
2226
2240
|
// scale
|
|
2227
|
-
|
|
2241
|
+
var s = babylonTransformNode.scaling;
|
|
2242
|
+
basePositionRotationOrScale = (s !== null && s !== void 0 ? s : core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.One()).asArray();
|
|
2228
2243
|
}
|
|
2229
2244
|
return basePositionRotationOrScale;
|
|
2230
2245
|
};
|