{"record":{"id":"9d9340554bb4675b","repo":"BabylonJS/Babylon.js","slug":"offset-invalid-number-of-values","errorCode":null,"errorMessage":"OFFSET: Invalid number of values","messagePattern":"OFFSET: Invalid number of values","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/BVH/bvhLoader.ts","lineNumber":274,"sourceCode":"    }\n\n    // opening bracket\n    if (lines.shift()?.trim() != \"{\") {\n        throw new Error(\"Expected opening { after type & name\");\n    }\n\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\") {","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/BVH/bvhLoader.ts#L256-L292","documentation":"An OFFSET line in BVH must contain exactly four whitespace-separated tokens: the keyword OFFSET plus three numeric components. When the parser counts a token list whose length is not 4, it throws, rejecting the offset declaration as structurally invalid.","triggerScenarios":"OFFSET lines with missing or extra components, e.g. \"OFFSET 0 0\" (one value dropped), \"OFFSET 0.0 0.0 0.0 0.0\" (extra value), or an OFFSET line accidentally merged with the following CHANNELS line by a text-processing step that collapsed newlines.","commonSituations":"Files edited in spreadsheet tools that drop trailing zeros/columns; custom exporters writing wrong column counts; scripts joining lines (CRLF/CR-only line endings that the split(\"\\n\") parser mishandles, merging OFFSET and CHANNELS into one line).","solutions":["Locate the OFFSET line (the message gives no token, so search each node body) and make it read exactly \"OFFSET x y z\" with three floats.","Check for CR-only (old Mac) line endings — normalize the file to LF/CRLF so each directive stays on its own line.","Re-export from the original tool rather than editing in spreadsheet/word-processor software.","If a converter produced the file, fix its OFFSET writer to always emit three values."],"exampleFix":"// before\nOFFSET 0.0 0.0 0.0 CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation\n// after\nOFFSET 0.0 0.0 0.0\nCHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation","handlingStrategy":"validation","validationCode":"function assertOffsetTokenCounts(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 n = t.split(/\\s+/).length;\n      if (n !== 4) throw new Error(`Bad OFFSET (expected 4 tokens, got ${n}): \"${t}\"`);\n    }\n  }\n}","typeGuard":"function isValidOffsetLine(line: string): boolean {\n  const t = line.trim().split(/\\s+/);\n  return t.length === 4 && t[0].toUpperCase() === \"OFFSET\";\n}","tryCatchPattern":"try {\n  const skeleton = ReadBvh(text, scene, null, options);\n} catch (e) {\n  if (e instanceof Error && e.message === \"OFFSET: Invalid number of values\") {\n    console.error(\"An OFFSET line does not have exactly 3 coordinates.\");\n  } else { throw e; }\n}","preventionTips":["Normalize line endings (convert CR-only files to LF) before parsing.","Avoid spreadsheet tools when editing BVH data.","Run a pre-parse scan of all OFFSET lines for token count."],"tags":["bvh","parser","numeric-values","malformed-input"],"backgroundTag":"malformed-bvh-structure","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}