1 |
- {"ast":null,"code":"import { Animation } from \"@babylonjs/core/Animations/animation.js\";\nimport { Quaternion, Vector3 } from \"@babylonjs/core/Maths/math.vector.js\";\n/** @internal */\nexport function getVector3(_target, source, offset, scale) {\n return Vector3.FromArray(source, offset).scaleInPlace(scale);\n}\n/** @internal */\nexport function getQuaternion(_target, source, offset, scale) {\n return Quaternion.FromArray(source, offset).scaleInPlace(scale);\n}\n/** @internal */\nexport function getWeights(target, source, offset, scale) {\n const value = new Array(target._numMorphTargets);\n for (let i = 0; i < value.length; i++) {\n value[i] = source[offset++] * scale;\n }\n return value;\n}\n/** @internal */\nexport class AnimationPropertyInfo {\n /** @internal */\n constructor(type, name, getValue, getStride) {\n this.type = type;\n this.name = name;\n this.getValue = getValue;\n this.getStride = getStride;\n }\n _buildAnimation(name, fps, keys) {\n const babylonAnimation = new Animation(name, this.name, fps, this.type);\n babylonAnimation.setKeys(keys);\n return babylonAnimation;\n }\n}\n/** @internal */\nexport class TransformNodeAnimationPropertyInfo extends AnimationPropertyInfo {\n /** @internal */\n buildAnimations(target, name, fps, keys, callback) {\n callback(target._babylonTransformNode, this._buildAnimation(name, fps, keys));\n }\n}\n/** @internal */\nexport class WeightAnimationPropertyInfo extends AnimationPropertyInfo {\n buildAnimations(target, name, fps, keys, callback) {\n if (target._numMorphTargets) {\n for (let targetIndex = 0; targetIndex < target._numMorphTargets; targetIndex++) {\n const babylonAnimation = new Animation(`${name}_${targetIndex}`, this.name, fps, this.type);\n babylonAnimation.setKeys(keys.map(key => ({\n frame: key.frame,\n inTangent: key.inTangent ? key.inTangent[targetIndex] : undefined,\n value: key.value[targetIndex],\n outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined,\n interpolation: key.interpolation\n })));\n if (target._primitiveBabylonMeshes) {\n for (const babylonMesh of target._primitiveBabylonMeshes) {\n if (babylonMesh.morphTargetManager) {\n const morphTarget = babylonMesh.morphTargetManager.getTarget(targetIndex);\n const babylonAnimationClone = babylonAnimation.clone();\n morphTarget.animations.push(babylonAnimationClone);\n callback(morphTarget, babylonAnimationClone);\n }\n }\n }\n }\n }\n }\n}\n/** @internal */\nexport const nodeAnimationData = {\n translation: [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_VECTOR3, \"position\", getVector3, () => 3)],\n rotation: [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_QUATERNION, \"rotationQuaternion\", getQuaternion, () => 4)],\n scale: [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_VECTOR3, \"scaling\", getVector3, () => 3)],\n weights: [new WeightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, \"influence\", getWeights, target => target._numMorphTargets)]\n};","map":{"version":3,"names":["Animation","Quaternion","Vector3","getVector3","_target","source","offset","scale","FromArray","scaleInPlace","getQuaternion","getWeights","target","value","Array","_numMorphTargets","i","length","AnimationPropertyInfo","constructor","type","name","getValue","getStride","_buildAnimation","fps","keys","babylonAnimation","setKeys","TransformNodeAnimationPropertyInfo","buildAnimations","callback","_babylonTransformNode","WeightAnimationPropertyInfo","targetIndex","map","key","frame","inTangent","undefined","outTangent","interpolation","_primitiveBabylonMeshes","babylonMesh","morphTargetManager","morphTarget","getTarget","babylonAnimationClone","clone","animations","push","nodeAnimationData","translation","ANIMATIONTYPE_VECTOR3","rotation","ANIMATIONTYPE_QUATERNION","weights","ANIMATIONTYPE_FLOAT"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/loaders/glTF/2.0/glTFLoaderAnimation.js"],"sourcesContent":["import { Animation } from \"@babylonjs/core/Animations/animation.js\";\nimport { Quaternion, Vector3 } from \"@babylonjs/core/Maths/math.vector.js\";\n/** @internal */\nexport function getVector3(_target, source, offset, scale) {\n return Vector3.FromArray(source, offset).scaleInPlace(scale);\n}\n/** @internal */\nexport function getQuaternion(_target, source, offset, scale) {\n return Quaternion.FromArray(source, offset).scaleInPlace(scale);\n}\n/** @internal */\nexport function getWeights(target, source, offset, scale) {\n const value = new Array(target._numMorphTargets);\n for (let i = 0; i < value.length; i++) {\n value[i] = source[offset++] * scale;\n }\n return value;\n}\n/** @internal */\nexport class AnimationPropertyInfo {\n /** @internal */\n constructor(type, name, getValue, getStride) {\n this.type = type;\n this.name = name;\n this.getValue = getValue;\n this.getStride = getStride;\n }\n _buildAnimation(name, fps, keys) {\n const babylonAnimation = new Animation(name, this.name, fps, this.type);\n babylonAnimation.setKeys(keys);\n return babylonAnimation;\n }\n}\n/** @internal */\nexport class TransformNodeAnimationPropertyInfo extends AnimationPropertyInfo {\n /** @internal */\n buildAnimations(target, name, fps, keys, callback) {\n callback(target._babylonTransformNode, this._buildAnimation(name, fps, keys));\n }\n}\n/** @internal */\nexport class WeightAnimationPropertyInfo extends AnimationPropertyInfo {\n buildAnimations(target, name, fps, keys, callback) {\n if (target._numMorphTargets) {\n for (let targetIndex = 0; targetIndex < target._numMorphTargets; targetIndex++) {\n const babylonAnimation = new Animation(`${name}_${targetIndex}`, this.name, fps, this.type);\n babylonAnimation.setKeys(keys.map((key) => ({\n frame: key.frame,\n inTangent: key.inTangent ? key.inTangent[targetIndex] : undefined,\n value: key.value[targetIndex],\n outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined,\n interpolation: key.interpolation,\n })));\n if (target._primitiveBabylonMeshes) {\n for (const babylonMesh of target._primitiveBabylonMeshes) {\n if (babylonMesh.morphTargetManager) {\n const morphTarget = babylonMesh.morphTargetManager.getTarget(targetIndex);\n const babylonAnimationClone = babylonAnimation.clone();\n morphTarget.animations.push(babylonAnimationClone);\n callback(morphTarget, babylonAnimationClone);\n }\n }\n }\n }\n }\n }\n}\n/** @internal */\nexport const nodeAnimationData = {\n translation: [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_VECTOR3, \"position\", getVector3, () => 3)],\n rotation: [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_QUATERNION, \"rotationQuaternion\", getQuaternion, () => 4)],\n scale: [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_VECTOR3, \"scaling\", getVector3, () => 3)],\n weights: [new WeightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, \"influence\", getWeights, (target) => target._numMorphTargets)],\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,yCAAyC;AACnE,SAASC,UAAU,EAAEC,OAAO,QAAQ,sCAAsC;AAC1E;AACA,OAAO,SAASC,UAAUA,CAACC,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAE;EACvD,OAAOL,OAAO,CAACM,SAAS,CAACH,MAAM,EAAEC,MAAM,CAAC,CAACG,YAAY,CAACF,KAAK,CAAC;AAChE;AACA;AACA,OAAO,SAASG,aAAaA,CAACN,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAE;EAC1D,OAAON,UAAU,CAACO,SAAS,CAACH,MAAM,EAAEC,MAAM,CAAC,CAACG,YAAY,CAACF,KAAK,CAAC;AACnE;AACA;AACA,OAAO,SAASI,UAAUA,CAACC,MAAM,EAAEP,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAE;EACtD,MAAMM,KAAK,GAAG,IAAIC,KAAK,CAACF,MAAM,CAACG,gBAAgB,CAAC;EAChD,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,KAAK,CAACI,MAAM,EAAED,CAAC,EAAE,EAAE;IACnCH,KAAK,CAACG,CAAC,CAAC,GAAGX,MAAM,CAACC,MAAM,EAAE,CAAC,GAAGC,KAAK;EACvC;EACA,OAAOM,KAAK;AAChB;AACA;AACA,OAAO,MAAMK,qBAAqB,CAAC;EAC/B;EACAC,WAAWA,CAACC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,SAAS,EAAE;IACzC,IAAI,CAACH,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,SAAS,GAAGA,SA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