BabylonJS/Babylon.js · error · Error
OFFSET: Invalid values
Error message
OFFSET: Invalid values
What it means
The three values after the OFFSET keyword must parse as finite floats. The loader constructs a Vector3 with parseFloat and, if any component is NaN (non-numeric text, empty token, wrong decimal separator like a comma), throws "OFFSET: Invalid values".
Source
Thrown at packages/dev/loaders/src/BVH/bvhLoader.ts:280
// parse OFFSET
const tokensSplit = lines.shift()?.trim().split(/\s+/);
if (!tokensSplit) {
throw new Error("Unexpected end of file: missing OFFSET");
}
tokens = tokensSplit;
if (tokens[0].toUpperCase() != "OFFSET") {
throw new Error("Expected OFFSET, but got: " + tokens[0]);
}
if (tokens.length != 4) {
throw new Error("OFFSET: Invalid number of values");
}
const offset = new Vector3(parseFloat(tokens[1]), parseFloat(tokens[2]), parseFloat(tokens[3]));
if (isNaN(offset.x) || isNaN(offset.y) || isNaN(offset.z)) {
throw new Error("OFFSET: Invalid values");
}
node.offset = offset;
// parse CHANNELS definitions
if (node.type != "ENDSITE") {
tokens = lines.shift()?.trim().split(/\s+/);
if (!tokens) {
throw new Error("Unexpected end of file: missing CHANNELS");
}
if (tokens[0].toUpperCase() != "CHANNELS") {
throw new Error("Expected CHANNELS definition");
}
const numChannels = parseInt(tokens[1]);
// Skip CHANNELS and the number of channels
node.channels = tokens.splice(2, numChannels);View on GitHub (pinned to 0592b347b8)
Solutions
- Inspect the OFFSET lines and replace non-numeric or comma-decimal values with dot-decimal floats (e.g. "0,5" -> "0.5").
- Search the file for 'OFFSET' and eyeball all three numbers per line for stray characters.
- Re-export the BVH with an English/neutral locale in the source tool.
- If you generate BVH programmatically, use invariant number formatting (toFixed/String, never toLocaleString).
Example fix
// before OFFSET 0,0 12,5 0,0 // after OFFSET 0.0 12.5 0.0
Defensive patterns
Strategy: validation
Validate before calling
function assertOffsetNumbers(text: string): void {
for (const line of text.split(/\r?\n/)) {
const t = line.trim();
if (t.toUpperCase().startsWith("OFFSET")) {
const v = t.split(/\s+/).slice(1);
if (v.some((s) => s === "" || isNaN(Number(s.replace(",", "."))))) {
throw new Error(`Non-numeric OFFSET value in: "${t}"`);
}
}
}
} Type guard
function hasNumericOffset(line: string): boolean {
const [, x, y, z] = line.trim().split(/\s+/);
return [x, y, z].every((s) => s !== undefined && !isNaN(parseFloat(s)));
} Try / catch
try {
const skeleton = ReadBvh(text, scene, null, options);
} catch (e) {
if (e instanceof Error && e.message === "OFFSET: Invalid values") {
console.error("An OFFSET line contains non-numeric values (check decimal separators)." );
} else { throw e; }
} Prevention
- Export BVH with a neutral (dot-decimal) locale.
- Scan OFFSET lines for commas or letters before loading.
- Use invariant number formatting in any custom BVH writer.
When it happens
Trigger: OFFSET lines like "OFFSET 0.0 , 0.0" or "OFFSET a b c"; locale-formatted numbers using commas ("0,0"); scientific notation in a form parseFloat rejects (rare); OFFSET lines whose extra tokens shifted positions after an earlier merged-line corruption.
Common situations: Files exported with locale-dependent decimal separators (European tools writing commas); OCR or copy/paste corruption of numeric data; corrupted sectors in a damaged file; template placeholders ("%f") left unsubstituted by a generator.
Related errors
- OFFSET: Invalid number of values
- Expected opening { after type & name
- Unexpected end of file: missing OFFSET
- Expected OFFSET, but got:
- Unexpected end of file: missing CHANNELS
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/75a4841fa5f5c67f.
Report an issue: GitHub.