How to use the babylonjs-gltf2interface.AnimationSamplerInterpolation.LINEAR 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 / loaders / src / glTF / 2.0 / glTFLoader.ts View on Github external
private _loadAnimationSamplerAsync(context: string, sampler: IAnimationSampler): Promise<_IAnimationSamplerData> {
        if (sampler._data) {
            return sampler._data;
        }

        const interpolation = sampler.interpolation || AnimationSamplerInterpolation.LINEAR;
        switch (interpolation) {
            case AnimationSamplerInterpolation.STEP:
            case AnimationSamplerInterpolation.LINEAR:
            case AnimationSamplerInterpolation.CUBICSPLINE: {
                break;
            }
            default: {
                throw new Error(`${context}/interpolation: Invalid value (${sampler.interpolation})`);
            }
        }

        const inputAccessor = ArrayItem.Get(`${context}/input`, this._gltf.accessors, sampler.input);
        const outputAccessor = ArrayItem.Get(`${context}/output`, this._gltf.accessors, sampler.output);
        sampler._data = Promise.all([
            this._loadFloatAccessorAsync(`/accessors/${inputAccessor.index}`, inputAccessor),
            this._loadFloatAccessorAsync(`/accessors/${outputAccessor.index}`, outputAccessor)
github BabylonJS / Babylon.js / serializers / src / glTF / 2.0 / glTFAnimation.ts View on Github external
private static _DeduceInterpolation(keyFrames: IAnimationKey[], animationChannelTargetPath: AnimationChannelTargetPath, useQuaternion: boolean): { interpolationType: AnimationSamplerInterpolation, shouldBakeAnimation: boolean } {
        let interpolationType: AnimationSamplerInterpolation | undefined;
        let shouldBakeAnimation = false;
        let key: IAnimationKey;

        if (animationChannelTargetPath === AnimationChannelTargetPath.ROTATION && !useQuaternion) {
            return { interpolationType: AnimationSamplerInterpolation.LINEAR, shouldBakeAnimation: true };
        }

        for (let i = 0, length = keyFrames.length; i < length; ++i) {
            key = keyFrames[i];
            if (key.inTangent || key.outTangent) {
                if (interpolationType) {
                    if (interpolationType !== AnimationSamplerInterpolation.CUBICSPLINE) {
                        interpolationType = AnimationSamplerInterpolation.LINEAR;
                        shouldBakeAnimation = true;
                        break;
                    }
                }
                else {
                    interpolationType = AnimationSamplerInterpolation.CUBICSPLINE;
                }
            }
github BabylonJS / Babylon.js / serializers / src / glTF / 2.0 / glTFAnimation.ts View on Github external
shouldBakeAnimation = true;
                        break;
                    }
                }
                else {
                    if (key.interpolation && (key.interpolation === AnimationKeyInterpolation.STEP)) {
                        interpolationType = AnimationSamplerInterpolation.STEP;
                    }
                    else {
                        interpolationType = AnimationSamplerInterpolation.LINEAR;
                    }
                }
            }
        }
        if (!interpolationType) {
            interpolationType = AnimationSamplerInterpolation.LINEAR;
        }

        return { interpolationType: interpolationType, shouldBakeAnimation: shouldBakeAnimation };
    }
github BabylonJS / Babylon.js / loaders / src / glTF / 2.0 / glTFLoader.ts View on Github external
};
                    break;
                }
            }

            let getNextKey: (frameIndex: number) => IAnimationKey;
            switch (data.interpolation) {
                case AnimationSamplerInterpolation.STEP: {
                    getNextKey = (frameIndex) => ({
                        frame: data.input[frameIndex],
                        value: getNextOutputValue(),
                        interpolation: AnimationKeyInterpolation.STEP
                    });
                    break;
                }
                case AnimationSamplerInterpolation.LINEAR: {
                    getNextKey = (frameIndex) => ({
                        frame: data.input[frameIndex],
                        value: getNextOutputValue()
                    });
                    break;
                }
                case AnimationSamplerInterpolation.CUBICSPLINE: {
                    getNextKey = (frameIndex) => ({
                        frame: data.input[frameIndex],
                        inTangent: getNextOutputValue(),
                        value: getNextOutputValue(),
                        outTangent: getNextOutputValue()
                    });
                    break;
                }
            }
github BabylonJS / Babylon.js / loaders / src / glTF / 2.0 / glTFLoader.ts View on Github external
private _loadAnimationSamplerAsync(context: string, sampler: IAnimationSampler): Promise<_IAnimationSamplerData> {
        if (sampler._data) {
            return sampler._data;
        }

        const interpolation = sampler.interpolation || AnimationSamplerInterpolation.LINEAR;
        switch (interpolation) {
            case AnimationSamplerInterpolation.STEP:
            case AnimationSamplerInterpolation.LINEAR:
            case AnimationSamplerInterpolation.CUBICSPLINE: {
                break;
            }
            default: {
                throw new Error(`${context}/interpolation: Invalid value (${sampler.interpolation})`);
            }
        }

        const inputAccessor = ArrayItem.Get(`${context}/input`, this._gltf.accessors, sampler.input);
        const outputAccessor = ArrayItem.Get(`${context}/output`, this._gltf.accessors, sampler.output);
        sampler._data = Promise.all([
            this._loadFloatAccessorAsync(`/accessors/${inputAccessor.index}`, inputAccessor),
            this._loadFloatAccessorAsync(`/accessors/${outputAccessor.index}`, outputAccessor)
github BabylonJS / Babylon.js / loaders / src / glTF / 2.0 / glTFLoader.ts View on Github external
};
                    break;
                }
            }

            let getNextKey: (frameIndex: number) => IAnimationKey;
            switch (data.interpolation) {
                case AnimationSamplerInterpolation.STEP: {
                    getNextKey = (frameIndex) => ({
                        frame: data.input[frameIndex],
                        value: getNextOutputValue(),
                        interpolation: AnimationKeyInterpolation.STEP
                    });
                    break;
                }
                case AnimationSamplerInterpolation.LINEAR: {
                    getNextKey = (frameIndex) => ({
                        frame: data.input[frameIndex],
                        value: getNextOutputValue()
                    });
                    break;
                }
                case AnimationSamplerInterpolation.CUBICSPLINE: {
                    getNextKey = (frameIndex) => ({
                        frame: data.input[frameIndex],
                        inTangent: getNextOutputValue(),
                        value: getNextOutputValue(),
                        outTangent: getNextOutputValue()
                    });
                    break;
                }
            }
github BabylonJS / Babylon.js / serializers / src / glTF / 2.0 / glTFAnimation.ts View on Github external
private static _DeduceInterpolation(keyFrames: IAnimationKey[], animationChannelTargetPath: AnimationChannelTargetPath, useQuaternion: boolean): { interpolationType: AnimationSamplerInterpolation, shouldBakeAnimation: boolean } {
        let interpolationType: AnimationSamplerInterpolation | undefined;
        let shouldBakeAnimation = false;
        let key: IAnimationKey;

        if (animationChannelTargetPath === AnimationChannelTargetPath.ROTATION && !useQuaternion) {
            return { interpolationType: AnimationSamplerInterpolation.LINEAR, shouldBakeAnimation: true };
        }

        for (let i = 0, length = keyFrames.length; i < length; ++i) {
            key = keyFrames[i];
            if (key.inTangent || key.outTangent) {
                if (interpolationType) {
                    if (interpolationType !== AnimationSamplerInterpolation.CUBICSPLINE) {
                        interpolationType = AnimationSamplerInterpolation.LINEAR;
                        shouldBakeAnimation = true;
                        break;
                    }
                }
                else {
                    interpolationType = AnimationSamplerInterpolation.CUBICSPLINE;
                }
            }
            else {
                if (interpolationType) {
                    if (interpolationType === AnimationSamplerInterpolation.CUBICSPLINE ||
                        (key.interpolation && (key.interpolation === AnimationKeyInterpolation.STEP) && interpolationType !== AnimationSamplerInterpolation.STEP)) {
                        interpolationType = AnimationSamplerInterpolation.LINEAR;
                        shouldBakeAnimation = true;
                        break;
                    }
github BabylonJS / Babylon.js / serializers / src / glTF / 2.0 / glTFAnimation.ts View on Github external
}
            else {
                if (interpolationType) {
                    if (interpolationType === AnimationSamplerInterpolation.CUBICSPLINE ||
                        (key.interpolation && (key.interpolation === AnimationKeyInterpolation.STEP) && interpolationType !== AnimationSamplerInterpolation.STEP)) {
                        interpolationType = AnimationSamplerInterpolation.LINEAR;
                        shouldBakeAnimation = true;
                        break;
                    }
                }
                else {
                    if (key.interpolation && (key.interpolation === AnimationKeyInterpolation.STEP)) {
                        interpolationType = AnimationSamplerInterpolation.STEP;
                    }
                    else {
                        interpolationType = AnimationSamplerInterpolation.LINEAR;
                    }
                }
            }
        }
        if (!interpolationType) {
            interpolationType = AnimationSamplerInterpolation.LINEAR;
        }

        return { interpolationType: interpolationType, shouldBakeAnimation: shouldBakeAnimation };
    }