本文整理汇总了TypeScript中babylonjs/Maths/math.Quaternion.Identity方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Quaternion.Identity方法的具体用法?TypeScript Quaternion.Identity怎么用?TypeScript Quaternion.Identity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类babylonjs/Maths/math.Quaternion
的用法示例。
在下文中一共展示了Quaternion.Identity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _GetBasePositionRotationOrScale
private static _GetBasePositionRotationOrScale(babylonTransformNode: TransformNode, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean) {
let basePositionRotationOrScale: number[];
if (animationChannelTargetPath === AnimationChannelTargetPath.ROTATION) {
if (useQuaternion) {
if (babylonTransformNode.rotationQuaternion) {
basePositionRotationOrScale = babylonTransformNode.rotationQuaternion.asArray();
if (convertToRightHandedSystem) {
_GLTFUtilities._GetRightHandedQuaternionArrayFromRef(basePositionRotationOrScale);
if (!babylonTransformNode.parent) {
basePositionRotationOrScale = Quaternion.FromArray([0, 1, 0, 0]).multiply(Quaternion.FromArray(basePositionRotationOrScale)).asArray();
}
}
}
else {
basePositionRotationOrScale = Quaternion.Identity().asArray();
}
}
else {
basePositionRotationOrScale = babylonTransformNode.rotation.asArray();
_GLTFUtilities._GetRightHandedNormalArray3FromRef(basePositionRotationOrScale);
}
}
else if (animationChannelTargetPath === AnimationChannelTargetPath.TRANSLATION) {
basePositionRotationOrScale = babylonTransformNode.position.asArray();
if (convertToRightHandedSystem) {
_GLTFUtilities._GetRightHandedPositionArray3FromRef(basePositionRotationOrScale);
}
}
else { // scale
basePositionRotationOrScale = babylonTransformNode.scaling.asArray();
}
return basePositionRotationOrScale;
}
示例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;
}
}