{"record":{"id":"e676d4f50cda497d","repo":"BabylonJS/Babylon.js","slug":"motion-expected","errorCode":null,"errorMessage":"MOTION expected","messagePattern":"MOTION expected","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/BVH/bvhLoader.ts","lineNumber":353,"sourceCode":"    const context = new LoaderContext(skeleton);\n    context.loopMode = loopMode;\n\n    // read model structure\n    const firstLine = lines.shift();\n    if (!firstLine || firstLine.trim().toUpperCase() !== _HierarchyNode) {\n        throw new Error(\"HIERARCHY expected\");\n    }\n\n    const nodeLine = lines.shift();\n    if (!nodeLine) {\n        throw new Error(\"Unexpected end of file after HIERARCHY\");\n    }\n    const root = ReadNode(lines, nodeLine.trim(), null, context);\n\n    // read motion data\n    const motionLine = lines.shift();\n    if (!motionLine || motionLine.trim().toUpperCase() !== _MotionNode) {\n        throw new Error(\"MOTION expected\");\n    }\n\n    const framesLine = lines.shift();\n    if (!framesLine) {\n        throw new Error(\"Unexpected end of file before frame count\");\n    }\n    const framesTokens = framesLine.trim().split(/[\\s]+/);\n    if (framesTokens.length < 2) {\n        throw new Error(\"Invalid frame count line\");\n    }\n\n    // number of frames\n    const numFrames = parseInt(framesTokens[1]);\n    if (isNaN(numFrames)) {\n        throw new Error(\"Failed to read number of frames.\");\n    }\n    context.numFrames = numFrames;\n","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/BVH/bvhLoader.ts#L335-L371","documentation":"After parsing the HIERARCHY section and the root node tree via ReadNode, ReadBvh requires the next line to be the 'MOTION' keyword, which begins the animation frame section. This error is thrown when the line following the hierarchy's closing brace is missing or is not 'MOTION'. It indicates the BVH file has a skeleton description but no valid motion-section header.","triggerScenarios":"Calling ReadBvh with a file where 'MOTION' is misspelled or has stray tokens on the line (e.g. 'MOTION Section'), a hierarchy-only BVH (skeleton exported without animation), or an extra line (comment/blank with content) inserted between the closing '}' and 'MOTION' that gets consumed as the root/next node line and shifts the expected position.","commonSituations":"Exporting skeleton-only BVH from a DCC tool (Blender/Maya exporter options with 'no animation' checked), hand-edited BVH files where the MOTION block was deleted or reordered, files from tools that emit 'Motion' followed by extra text or lowercase variants with appended tokens, or concatenating two BVH files incorrectly.","solutions":["Inspect the file right after the hierarchy's final closing brace: ensure the exact line 'MOTION' (case-insensitive first token alone) appears; re-export with animation/motion data enabled.","Check the exporter settings (e.g. Blender BVH export: keep 'Animation' enabled) so the MOTION section is written.","Remove or comment-free any junk between the last '}' of the hierarchy and the MOTION line.","If the intent is skeleton-only loading, switch to a format/loader that supports it — this BVH parser requires the MOTION section.","Pre-validate with a regex like /\\bMOTION\\b/i before calling ReadBvh to fail fast with your own message."],"exampleFix":"// before (skeleton-only export)\nHIERARCHY\nROOT Hips\n{\n...\n}\n// (file ends)\n\n// after (re-export with animation)\nHIERARCHY\nROOT Hips\n{\n...\n}\nMOTION\nFrames: 120\nFrame Time: 0.033333","handlingStrategy":"validation","validationCode":"function hasMotionSection(text: string): boolean {\n    return /\\n\\s*MOTION\\s*(\\n|$)/i.test(text);\n}\nif (!hasMotionSection(bvhText)) {\n    throw new Error(\"BVH file has no MOTION section: re-export with animation enabled\");\n}\nconst skeleton = ReadBvh(bvhText, scene, null, options);","typeGuard":null,"tryCatchPattern":"let skeleton: Skeleton;\ntry {\n    skeleton = ReadBvh(bvhText, scene, null, options);\n} catch (e) {\n    if (e instanceof Error && e.message === \"MOTION expected\") {\n        console.error(\"BVH hierarchy-only file (no MOTION section)\", e);\n        skeleton = buildSkeletonWithoutAnimation(scene);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Enable animation export in your DCC BVH exporter settings (e.g. Blender's Animation checkbox).","Sanity-check exported BVH files with a script that asserts the presence of HIERARCHY, ROOT, MOTION, Frames, and Frame Time lines.","Avoid hand-editing the MOTION header; keep it immediately after the hierarchy's closing brace.","Don't concatenate BVH files manually; merge motion data with a proper tool."],"tags":["bvh","parser","mocap","missing-section"],"backgroundTag":"bvh-malformed-file","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}