{"record":{"id":"75a4841fa5f5c67f","repo":"BabylonJS/Babylon.js","slug":"offset-invalid-values","errorCode":null,"errorMessage":"OFFSET: Invalid values","messagePattern":"OFFSET: Invalid values","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/BVH/bvhLoader.ts","lineNumber":280,"sourceCode":"\n    // parse OFFSET\n    const tokensSplit = lines.shift()?.trim().split(/\\s+/);\n    if (!tokensSplit) {\n        throw new Error(\"Unexpected end of file: missing OFFSET\");\n    }\n    tokens = tokensSplit;\n\n    if (tokens[0].toUpperCase() != \"OFFSET\") {\n        throw new Error(\"Expected OFFSET, but got: \" + tokens[0]);\n    }\n    if (tokens.length != 4) {\n        throw new Error(\"OFFSET: Invalid number of values\");\n    }\n\n    const offset = new Vector3(parseFloat(tokens[1]), parseFloat(tokens[2]), parseFloat(tokens[3]));\n\n    if (isNaN(offset.x) || isNaN(offset.y) || isNaN(offset.z)) {\n        throw new Error(\"OFFSET: Invalid values\");\n    }\n\n    node.offset = offset;\n\n    // parse CHANNELS definitions\n    if (node.type != \"ENDSITE\") {\n        tokens = lines.shift()?.trim().split(/\\s+/);\n        if (!tokens) {\n            throw new Error(\"Unexpected end of file: missing CHANNELS\");\n        }\n\n        if (tokens[0].toUpperCase() != \"CHANNELS\") {\n            throw new Error(\"Expected CHANNELS definition\");\n        }\n\n        const numChannels = parseInt(tokens[1]);\n        // Skip CHANNELS and the number of channels\n        node.channels = tokens.splice(2, numChannels);","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/BVH/bvhLoader.ts#L262-L298","documentation":"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\".","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\nOFFSET 0,0 12,5 0,0\n// after\nOFFSET 0.0 12.5 0.0","handlingStrategy":"validation","validationCode":"function assertOffsetNumbers(text: string): void {\n  for (const line of text.split(/\\r?\\n/)) {\n    const t = line.trim();\n    if (t.toUpperCase().startsWith(\"OFFSET\")) {\n      const v = t.split(/\\s+/).slice(1);\n      if (v.some((s) => s === \"\" || isNaN(Number(s.replace(\",\", \".\"))))) {\n        throw new Error(`Non-numeric OFFSET value in: \"${t}\"`);\n      }\n    }\n  }\n}","typeGuard":"function hasNumericOffset(line: string): boolean {\n  const [, x, y, z] = line.trim().split(/\\s+/);\n  return [x, y, z].every((s) => s !== undefined && !isNaN(parseFloat(s)));\n}","tryCatchPattern":"try {\n  const skeleton = ReadBvh(text, scene, null, options);\n} catch (e) {\n  if (e instanceof Error && e.message === \"OFFSET: Invalid values\") {\n    console.error(\"An OFFSET line contains non-numeric values (check decimal separators).\" );\n  } else { throw e; }\n}","preventionTips":["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."],"tags":["bvh","parser","numeric-values","locale"],"backgroundTag":"malformed-bvh-structure","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}