当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Quaternion.Identity方法代码示例

本文整理汇总了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;
 }
开发者ID:Pryme8,项目名称:Babylon.js,代码行数:33,代码来源:glTFAnimation.ts

示例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;
        }
    }
开发者ID:Pryme8,项目名称:Babylon.js,代码行数:73,代码来源:glTFAnimation.ts


注:本文中的babylonjs/Maths/math.Quaternion.Identity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。