本文整理汇总了TypeScript中babylonjs/Animations/animation.Animation.getKeys方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Animation.getKeys方法的具体用法?TypeScript Animation.getKeys怎么用?TypeScript Animation.getKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类babylonjs/Animations/animation.Animation
的用法示例。
在下文中一共展示了Animation.getKeys方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _CreateCubicSplineAnimation
/**
* Creates cubic spline animation from the animation key frames
* @param babylonTransformNode BabylonJS mesh
* @param animation BabylonJS animation
* @param animationChannelTargetPath The target animation channel
* @param frameDelta The difference between the last and first frame of the animation
* @param inputs Array to store the key frame times
* @param outputs Array to store the key frame data
* @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
* @param useQuaternion Specifies if quaternions are used in the animation
*/
private static _CreateCubicSplineAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, frameDelta: number, inputs: number[], outputs: number[][], convertToRightHandedSystem: boolean, useQuaternion: boolean) {
animation.getKeys().forEach(function(keyFrame) {
inputs.push(keyFrame.frame / animation.framePerSecond); // keyframes in seconds.
_GLTFAnimation.AddSplineTangent(
babylonTransformNode,
_TangentType.INTANGENT,
outputs,
animationChannelTargetPath,
AnimationSamplerInterpolation.CUBICSPLINE,
keyFrame,
frameDelta,
useQuaternion,
convertToRightHandedSystem
);
_GLTFAnimation._AddKeyframeValue(keyFrame, animation, outputs, animationChannelTargetPath, babylonTransformNode, convertToRightHandedSystem, useQuaternion);
_GLTFAnimation.AddSplineTangent(
babylonTransformNode,
_TangentType.OUTTANGENT,
outputs,
animationChannelTargetPath,
AnimationSamplerInterpolation.CUBICSPLINE,
keyFrame,
frameDelta,
useQuaternion,
convertToRightHandedSystem
);
});
}
示例2: _CreateBakedAnimation
/**
* Create a baked animation
* @param babylonTransformNode BabylonJS mesh
* @param animation BabylonJS animation corresponding to the BabylonJS mesh
* @param animationChannelTargetPath animation target channel
* @param minFrame minimum animation frame
* @param maxFrame maximum animation frame
* @param fps frames per second of the animation
* @param inputs input key frames of the animation
* @param outputs output key frame data of the animation
* @param convertToRightHandedSystem converts the values to right-handed
* @param useQuaternion specifies if quaternions should be used
*/
private static _CreateBakedAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, minFrame: number, maxFrame: number, fps: number, sampleRate: number, inputs: number[], outputs: number[][], minMaxFrames: { min: number, max: number }, convertToRightHandedSystem: boolean, useQuaternion: boolean) {
let value: number | Vector3 | Quaternion;
let quaternionCache: Quaternion = Quaternion.Identity();
let previousTime: Nullable<number> = null;
let time: number;
let maxUsedFrame: Nullable<number> = null;
let currKeyFrame: Nullable<IAnimationKey> = null;
let nextKeyFrame: Nullable<IAnimationKey> = null;
let prevKeyFrame: Nullable<IAnimationKey> = null;
let endFrame: Nullable<number> = null;
minMaxFrames.min = Tools.FloatRound(minFrame / fps);
let keyFrames = animation.getKeys();
for (let i = 0, length = keyFrames.length; i < length; ++i) {
endFrame = null;
currKeyFrame = keyFrames[i];
if (i + 1 < length) {
nextKeyFrame = keyFrames[i + 1];
if (currKeyFrame.value.equals(nextKeyFrame.value)) {
if (i === 0) { // set the first frame to itself
endFrame = currKeyFrame.frame;
}
else {
continue;
}
}
else {
endFrame = nextKeyFrame.frame;
}
}
else {
// at the last key frame
prevKeyFrame = keyFrames[i - 1];
if (currKeyFrame.value.equals(prevKeyFrame.value)) {
continue;
}
else {
endFrame = maxFrame;
}
}
if (endFrame) {
for (let f = currKeyFrame.frame; f <= endFrame; f += sampleRate) {
time = Tools.FloatRound(f / fps);
if (time === previousTime) {
continue;
}
previousTime = time;
maxUsedFrame = time;
value = animation._interpolate(f, 0, undefined, animation.loopMode);
_GLTFAnimation._SetInterpolatedValue(babylonTransformNode, value, time, animation, animationChannelTargetPath, quaternionCache, inputs, outputs, convertToRightHandedSystem, useQuaternion);
}
}
}
if (maxUsedFrame) {
minMaxFrames.max = maxUsedFrame;
}
}
示例3: _CreateNodeAnimation
/**
* @ignore
*
* Creates glTF channel animation from BabylonJS animation.
* @param babylonTransformNode - BabylonJS mesh.
* @param animation - animation.
* @param animationChannelTargetPath - The target animation channel.
* @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
* @param useQuaternion - Specifies if quaternions are used.
* @returns nullable IAnimationData
*/
public static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData> {
const inputs: number[] = [];
const outputs: number[][] = [];
const keyFrames = animation.getKeys();
const minMaxKeyFrames = _GLTFAnimation.calculateMinMaxKeyFrames(keyFrames);
const interpolationOrBake = _GLTFAnimation._DeduceInterpolation(keyFrames, animationChannelTargetPath, useQuaternion);
const frameDelta = minMaxKeyFrames.max - minMaxKeyFrames.min;
const interpolation = interpolationOrBake.interpolationType;
const shouldBakeAnimation = interpolationOrBake.shouldBakeAnimation;
if (shouldBakeAnimation) {
_GLTFAnimation._CreateBakedAnimation(babylonTransformNode, animation, animationChannelTargetPath, minMaxKeyFrames.min, minMaxKeyFrames.max, animation.framePerSecond, animationSampleRate, inputs, outputs, minMaxKeyFrames, convertToRightHandedSystem, useQuaternion);
}
else {
if (interpolation === AnimationSamplerInterpolation.LINEAR || interpolation === AnimationSamplerInterpolation.STEP) {
_GLTFAnimation._CreateLinearOrStepAnimation(babylonTransformNode, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
}
else if (interpolation === AnimationSamplerInterpolation.CUBICSPLINE) {
_GLTFAnimation._CreateCubicSplineAnimation(babylonTransformNode, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
}
else {
_GLTFAnimation._CreateBakedAnimation(babylonTransformNode, animation, animationChannelTargetPath, minMaxKeyFrames.min, minMaxKeyFrames.max, animation.framePerSecond, animationSampleRate, inputs, outputs, minMaxKeyFrames, convertToRightHandedSystem, useQuaternion);
}
}
if (inputs.length && outputs.length) {
const result: _IAnimationData = {
inputs: inputs,
outputs: outputs,
samplerInterpolation: interpolation,
inputsMin: shouldBakeAnimation ? minMaxKeyFrames.min : Tools.FloatRound(minMaxKeyFrames.min / animation.framePerSecond),
inputsMax: shouldBakeAnimation ? minMaxKeyFrames.max : Tools.FloatRound(minMaxKeyFrames.max / animation.framePerSecond)
};
return result;
}
return null;
}
示例4: _CreateLinearOrStepAnimation
/**
* Creates linear animation from the animation key frames
* @param babylonTransformNode BabylonJS mesh
* @param animation BabylonJS animation
* @param animationChannelTargetPath The target animation channel
* @param frameDelta The difference between the last and first frame of the animation
* @param inputs Array to store the key frame times
* @param outputs Array to store the key frame data
* @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
* @param useQuaternion Specifies if quaternions are used in the animation
*/
private static _CreateLinearOrStepAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, frameDelta: number, inputs: number[], outputs: number[][], convertToRightHandedSystem: boolean, useQuaternion: boolean) {
for (let keyFrame of animation.getKeys()) {
inputs.push(keyFrame.frame / animation.framePerSecond); // keyframes in seconds.
_GLTFAnimation._AddKeyframeValue(keyFrame, animation, outputs, animationChannelTargetPath, babylonTransformNode, convertToRightHandedSystem, useQuaternion);
}
}