{"record":{"id":"e1a55d07b1c14a18","repo":"BabylonJS/Babylon.js","slug":"context-interpolation-invalid-value-sampler","errorCode":null,"errorMessage":"${context}/interpolation: Invalid value (${sampler.interpolation})","messagePattern":"(.+?)/interpolation: Invalid value \\((.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts","lineNumber":2016,"sourceCode":"                }\r\n            }\r\n        });\r\n    }\r\n\r\n    private _loadAnimationSamplerAsync(context: string, sampler: IAnimationSampler): Promise<_IAnimationSamplerData> {\r\n        if (sampler._data) {\r\n            return sampler._data;\r\n        }\r\n\r\n        const interpolation = sampler.interpolation || AnimationSamplerInterpolation.LINEAR;\r\n        switch (interpolation) {\r\n            case AnimationSamplerInterpolation.STEP:\r\n            case AnimationSamplerInterpolation.LINEAR:\r\n            case AnimationSamplerInterpolation.CUBICSPLINE: {\r\n                break;\r\n            }\r\n            default: {\r\n                throw new Error(`${context}/interpolation: Invalid value (${sampler.interpolation})`);\r\n            }\r\n        }\r\n\r\n        const inputAccessor = ArrayItem.Get(`${context}/input`, this._gltf.accessors, sampler.input);\r\n        const outputAccessor = ArrayItem.Get(`${context}/output`, this._gltf.accessors, sampler.output);\r\n        sampler._data = Promise.all([\r\n            this._loadFloatAccessorAsync(`/accessors/${inputAccessor.index}`, inputAccessor),\r\n            this._loadFloatAccessorAsync(`/accessors/${outputAccessor.index}`, outputAccessor),\r\n        ]).then(([inputData, outputData]) => {\r\n            return {\r\n                input: inputData,\r\n                interpolation: interpolation,\r\n                output: outputData,\r\n            };\r\n        });\r\n\r\n        return sampler._data;\r\n    }\r","sourceCodeStart":1998,"sourceCodeEnd":2034,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts#L1998-L2034","documentation":"glTF 2.0 allows animation sampler interpolation values of LINEAR, STEP, and CUBICSPLINE. If sampler.interpolation holds any other value, this error is thrown during animation sampler loading. An absent interpolation is legal (defaults to LINEAR) — only an explicitly invalid string triggers this.","triggerScenarios":"Loading a glTF where animations[i].samplers[j].interpolation is a non-spec string such as \"CUBIC\" or \"cubic-spline\" (wrong case also fails since the check is exact).","commonSituations":"Custom converters emitting non-standard interpolation names, hand-edited files, or assets from tools using legacy casing conventions.","solutions":["Set sampler.interpolation to \"LINEAR\", \"STEP\", or \"CUBICSPLINE\".","Remove the interpolation field entirely to accept the LINEAR default.","Re-export with a compliant exporter.","Validate with glTF-Validator before loading."],"exampleFix":"// before\n\"samplers\": [{ \"input\": 0, \"output\": 1, \"interpolation\": \"CUBIC\" }]\n// after\n\"samplers\": [{ \"input\": 0, \"output\": 1, \"interpolation\": \"CUBICSPLINE\" }]","handlingStrategy":"validation","validationCode":"const VALID = [\"LINEAR\", \"STEP\", \"CUBICSPLINE\"];\nfor (const s of gltf.animations?.flatMap(a => a.samplers) ?? []) {\n  if (s.interpolation !== undefined && !VALID.includes(s.interpolation)) {\n    throw new Error(`Invalid sampler interpolation: ${s.interpolation}`);\n  }\n}","typeGuard":"function isValidInterpolation(i: string | undefined): i is \"LINEAR\" | \"STEP\" | \"CUBICSPLINE\" | undefined {\n  return i === undefined || [\"LINEAR\", \"STEP\", \"CUBICSPLINE\"].includes(i);\n}","tryCatchPattern":"try { await loadAsset(); } catch (e) {\n  if (/interpolation: Invalid value/.test((e as Error).message)) {\n    // sanitize interpolation fields to LINEAR and retry\n  }\n}","preventionTips":["Normalize exporter output: uppercase, exact spec strings.","Omit the field when LINEAR (the default) is intended.","Add a glTF-Validator gate in CI for animated assets."],"tags":["gltf","animation","enum-validation","asset-loading"],"backgroundTag":"invalid-enum-value","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}