本文整理汇总了TypeScript中babylonjs/Animations/animation.Animation类的典型用法代码示例。如果您正苦于以下问题:TypeScript Animation类的具体用法?TypeScript Animation怎么用?TypeScript Animation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Animation类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: _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;
}
}
开发者ID:Pryme8,项目名称:Babylon.js,代码行数:73,代码来源:glTFAnimation.ts
示例2: _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
);
});
}
开发者ID:Pryme8,项目名称:Babylon.js,代码行数:40,代码来源:glTFAnimation.ts
示例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;
}
开发者ID:Pryme8,项目名称:Babylon.js,代码行数:52,代码来源:glTFAnimation.ts
示例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);
}
}
开发者ID:Pryme8,项目名称:Babylon.js,代码行数:17,代码来源:glTFAnimation.ts
注:本文中的babylonjs/Animations/animation.Animation类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论