{"record":{"id":"43edf89c7a097129","repo":"BabylonJS/Babylon.js","slug":"expected-opening-after-type-name","errorCode":null,"errorMessage":"Expected opening { after type & name","messagePattern":"Expected opening \\{ after type & name","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/BVH/bvhLoader.ts","lineNumber":260,"sourceCode":"function ReadNode(lines: string[], firstLine: string, parent: Nullable<IBVHNode>, context: LoaderContext): IBVHNode {\n    const node = CreateBVHNode();\n    node.parent = parent;\n    context.list.push(node);\n\n    // parse node type and name.\n    let tokens: string[] | undefined = firstLine.trim().split(/\\s+/);\n\n    if (tokens[0].toUpperCase() === \"END\" && tokens[1].toUpperCase() === \"SITE\") {\n        node.type = \"ENDSITE\";\n        node.name = \"ENDSITE\"; // bvh end sites have no name\n    } else {\n        node.name = tokens[1];\n        node.type = tokens[0].toUpperCase();\n    }\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","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/BVH/bvhLoader.ts#L242-L278","documentation":"ReadNode parses the BVH HIERARCHY section recursively. Immediately after a node's type/name line (e.g. \"JOINT hip\" or \"ROOT spine\"), the BVH format requires an opening \"{\" on its own line. If the next line consumed from the file is not exactly \"{\" after trimming, this error is thrown, meaning the file's structure is malformed.","triggerScenarios":"Calling the BVH loader (ReadBvh / skeleton loading) on a file where a ROOT/JOINT/ENDSITE (or MOTION placeholder) header line is followed by anything other than a bare \"{\" line — e.g. missing brace, brace on the same line as the name, or stray content between the name and the brace.","commonSituations":"Hand-edited BVH files; files exported by tools that omit braces; files mangled by line-ending/encoding conversion (e.g. single-line-flattened files); truncated or partially downloaded .bvh files; attempting to load a non-BVH (e.g. BVH with CRLF handled fine, but JSON or FBX) file through the BVH loader.","solutions":["Open the .bvh in a text editor and verify every ROOT/JOINT line is followed by a line containing only \"{\".","Re-export the BVH from the original motion-capture tool with default settings.","Check the file was not truncated or corrupted in transfer (compare byte size with source).","Ensure you are loading a BVH file, not another skeleton format, into the BVH loader.","Normalize line endings (CRLF vs LF) if the file came from Windows tooling and appears flattened."],"exampleFix":"// before (malformed BVH)\nROOT Hips\n  OFFSET 0 0 0\n// after (valid BVH)\nROOT Hips\n{\n  OFFSET 0 0 0","handlingStrategy":"validation","validationCode":"function assertBvhNodeBraces(text: string): void {\n  const lines = text.split(/\\r?\\n/).map((l) => l.trim());\n  for (let i = 0; i < lines.length; i++) {\n    const t = lines[i].toUpperCase();\n    if (t.startsWith(\"ROOT \") || t.startsWith(\"JOINT \") || t === \"END SITE\") {\n      if (lines[i + 1] !== \"{\") {\n        throw new Error(`Line ${i + 2}: expected \"{\" after \"${lines[i]}\"`);\n      }\n    }\n  }\n}\n// run before ReadBvh: assertBvhNodeBraces(bvhText);","typeGuard":"function isOpenBraceLine(line: string | undefined): boolean {\n  return line?.trim() === \"{\";\n}","tryCatchPattern":"try {\n  const skeleton = ReadBvh(text, scene, null, options);\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"Expected opening {\")) {\n    console.error(\"BVH hierarchy is malformed: a node is missing its opening brace.\");\n  } else { throw e; }\n}","preventionTips":["Never hand-edit BVH files; re-export from the source tool.","Keep every node header line followed by a standalone \"{\" line.","Sanity-check brace balance before loading."],"tags":["bvh","parser","file-format","malformed-input"],"backgroundTag":"malformed-bvh-structure","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}