BabylonJS/Babylon.js · error · Error
${context}/interpolation: Invalid value (${sampler.interpola
Error message
${context}/interpolation: Invalid value (${sampler.interpolation}) What it means
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.
Source
Thrown at packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts:2016
}
}
});
}
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),
]).then(([inputData, outputData]) => {
return {
input: inputData,
interpolation: interpolation,
output: outputData,
};
});
return sampler._data;
}
View on GitHub (pinned to 0592b347b8)
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.
Example fix
// before
"samplers": [{ "input": 0, "output": 1, "interpolation": "CUBIC" }]
// after
"samplers": [{ "input": 0, "output": 1, "interpolation": "CUBICSPLINE" }] Defensive patterns
Strategy: validation
Validate before calling
const VALID = ["LINEAR", "STEP", "CUBICSPLINE"];
for (const s of gltf.animations?.flatMap(a => a.samplers) ?? []) {
if (s.interpolation !== undefined && !VALID.includes(s.interpolation)) {
throw new Error(`Invalid sampler interpolation: ${s.interpolation}`);
}
} Type guard
function isValidInterpolation(i: string | undefined): i is "LINEAR" | "STEP" | "CUBICSPLINE" | undefined {
return i === undefined || ["LINEAR", "STEP", "CUBICSPLINE"].includes(i);
} Try / catch
try { await loadAsset(); } catch (e) {
if (/interpolation: Invalid value/.test((e as Error).message)) {
// sanitize interpolation fields to LINEAR and retry
}
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: Custom converters emitting non-standard interpolation names, hand-edited files, or assets from tools using legacy casing conventions.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- ${context}/target/path: Invalid value (${channel.target.path
- ${context}: Invalid camera type (${camera.type})
- ${context}/target/path: Could not find interpolation propert
- ${extensionContext}: Pointer is missing
- ${extensionContext}/pointer: Interpolation is missing
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/e1a55d07b1c14a18.
Report an issue: GitHub.