How to use the babylonjs-gltf2interface.AnimationChannelTargetPath.SCALE function in babylonjs-gltf2interface

To help you get started, we’ve selected a few babylonjs-gltf2interface examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BabylonJS / Babylon.js / serializers / src / glTF / 2.0 / glTFAnimation.ts View on Github external
if (animationType === Animation.ANIMATIONTYPE_FLOAT) { // handles single component x, y, z or w component animation by using a base property and animating over a component.
            property = animation.targetProperty.split('.');
            componentName = property ? property[1] : ''; // x, y, or z component
            value = useQuaternion ? Quaternion.FromArray(basePositionRotationOrScale).normalize() : Vector3.FromArray(basePositionRotationOrScale);

            switch (componentName) {
                case 'x': {
                    value[componentName] = (convertToRightHandedSystem && useQuaternion && (animationChannelTargetPath !== AnimationChannelTargetPath.SCALE)) ? -factor : factor;
                    break;
                }
                case 'y': {
                    value[componentName] = (convertToRightHandedSystem && useQuaternion && (animationChannelTargetPath !== AnimationChannelTargetPath.SCALE)) ? -factor : factor;
                    break;
                }
                case 'z': {
                    value[componentName] = (convertToRightHandedSystem && !useQuaternion && (animationChannelTargetPath !== AnimationChannelTargetPath.SCALE)) ? -factor : factor;
                    break;
                }
                case 'w': {
                    (value as Quaternion).w = factor;
                    break;
                }
                default: {
                    Tools.Error(`glTFAnimation: Unsupported component type "${componentName}" for scale animation!`);
                }
            }
        }

        return value;
    }
github BabylonJS / Babylon.js / serializers / src / glTF / 2.0 / glTFAnimation.ts View on Github external
private static _DeduceAnimationInfo(animation: Animation): Nullable<_IAnimationInfo> {
        let animationChannelTargetPath: Nullable = null;
        let dataAccessorType = AccessorType.VEC3;
        let useQuaternion: boolean = false;
        let property = animation.targetProperty.split('.');
        switch (property[0]) {
            case 'scaling': {
                animationChannelTargetPath = AnimationChannelTargetPath.SCALE;
                break;
            }
            case 'position': {
                animationChannelTargetPath = AnimationChannelTargetPath.TRANSLATION;
                break;
            }
            case 'rotation': {
                dataAccessorType = AccessorType.VEC4;
                animationChannelTargetPath = AnimationChannelTargetPath.ROTATION;
                break;
            }
            case 'rotationQuaternion': {
                dataAccessorType = AccessorType.VEC4;
                useQuaternion = true;
                animationChannelTargetPath = AnimationChannelTargetPath.ROTATION;
                break;
github BabylonJS / Babylon.js / serializers / src / glTF / 2.0 / glTFAnimation.ts View on Github external
private static _DeduceAnimationInfo(animation: Animation): Nullable<_IAnimationInfo> {
        let animationChannelTargetPath: Nullable = null;
        let dataAccessorType = AccessorType.VEC3;
        let useQuaternion: boolean = false;
        let property = animation.targetProperty.split('.');
        switch (property[0]) {
            case 'scaling': {
                animationChannelTargetPath = AnimationChannelTargetPath.SCALE;
                break;
            }
            case 'position': {
                animationChannelTargetPath = AnimationChannelTargetPath.TRANSLATION;
                break;
            }
            case 'rotation': {
                dataAccessorType = AccessorType.VEC4;
                animationChannelTargetPath = AnimationChannelTargetPath.ROTATION;
                break;
            }
            case 'rotationQuaternion': {
                dataAccessorType = AccessorType.VEC4;
                useQuaternion = true;
                animationChannelTargetPath = AnimationChannelTargetPath.ROTATION;
                break;
github BabylonJS / Babylon.js / loaders / src / glTF / 2.0 / glTFLoader.ts View on Github external
return this._loadAnimationSamplerAsync(`${animationContext}/samplers/${channel.sampler}`, sampler).then((data) => {
            let targetPath: string;
            let animationType: number;
            switch (channel.target.path) {
                case AnimationChannelTargetPath.TRANSLATION: {
                    targetPath = "position";
                    animationType = Animation.ANIMATIONTYPE_VECTOR3;
                    break;
                }
                case AnimationChannelTargetPath.ROTATION: {
                    targetPath = "rotationQuaternion";
                    animationType = Animation.ANIMATIONTYPE_QUATERNION;
                    break;
                }
                case AnimationChannelTargetPath.SCALE: {
                    targetPath = "scaling";
                    animationType = Animation.ANIMATIONTYPE_VECTOR3;
                    break;
                }
                case AnimationChannelTargetPath.WEIGHTS: {
                    targetPath = "influence";
                    animationType = Animation.ANIMATIONTYPE_FLOAT;
                    break;
                }
                default: {
                    throw new Error(`${context}/target/path: Invalid value (${channel.target.path})`);
                }
            }

            let outputBufferOffset = 0;
            let getNextOutputValue: () => Vector3 | Quaternion | Array;
github BabylonJS / Babylon.js / loaders / src / glTF / 2.0 / glTFLoader.ts View on Github external
return this._loadAnimationSamplerAsync(`${animationContext}/samplers/${channel.sampler}`, sampler).then((data) => {
            let targetPath: string;
            let animationType: number;
            switch (channel.target.path) {
                case AnimationChannelTargetPath.TRANSLATION: {
                    targetPath = "position";
                    animationType = Animation.ANIMATIONTYPE_VECTOR3;
                    break;
                }
                case AnimationChannelTargetPath.ROTATION: {
                    targetPath = "rotationQuaternion";
                    animationType = Animation.ANIMATIONTYPE_QUATERNION;
                    break;
                }
                case AnimationChannelTargetPath.SCALE: {
                    targetPath = "scaling";
                    animationType = Animation.ANIMATIONTYPE_VECTOR3;
                    break;
                }
                case AnimationChannelTargetPath.WEIGHTS: {
                    targetPath = "influence";
                    animationType = Animation.ANIMATIONTYPE_FLOAT;
                    break;
                }
                default: {
                    throw new Error(`${context}/target/path: Invalid value (${channel.target.path})`);
                }
            }

            let outputBufferOffset = 0;
            let getNextOutputValue: () => Vector3 | Quaternion | Array;
github BabylonJS / Babylon.js / serializers / src / glTF / 2.0 / glTFAnimation.ts View on Github external
else {
                    cacheValue = value as Vector3;
                    Quaternion.RotationYawPitchRollToRef(cacheValue.y, cacheValue.x, cacheValue.z, quaternionCache);
                }
                if (convertToRightHandedSystem) {
                    _GLTFUtilities._GetRightHandedQuaternionFromRef(quaternionCache);

                    if (!babylonTransformNode.parent) {
                        quaternionCache = Quaternion.FromArray([0, 1, 0, 0]).multiply(quaternionCache);
                    }
                }
                outputs.push(quaternionCache.asArray());
            }
            else {
                cacheValue = value as Vector3;
                if (convertToRightHandedSystem && (animationChannelTargetPath !== AnimationChannelTargetPath.SCALE)) {
                    _GLTFUtilities._GetRightHandedPositionVector3FromRef(cacheValue);
                    if (!babylonTransformNode.parent) {
                        cacheValue.x *= -1;
                        cacheValue.z *= -1;
                    }
                }

                outputs.push(cacheValue.asArray());
            }
        }
    }