BabylonJS/Babylon.js · error · Error
Expected OFFSET, but got:
Error message
Expected OFFSET, but got:
What it means
Each BVH node's first line inside its brace must start with the keyword OFFSET. When the parser reads a line that is not OFFSET (it echoes the offending token into the message), it throws, because the required channel-offset declaration is missing or out of order.
Source
Thrown at packages/dev/loaders/src/BVH/bvhLoader.ts:271
} else {
node.name = tokens[1];
node.type = tokens[0].toUpperCase();
}
// opening bracket
if (lines.shift()?.trim() != "{") {
throw new Error("Expected opening { after type & name");
}
// 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");View on GitHub (pinned to 0592b347b8)
Solutions
- Open the .bvh and confirm each node body starts with "OFFSET x y z" before any CHANNELS line — move misplaced lines into position.
- Re-export the BVH from the source DCC/mocap tool instead of hand-editing.
- Check the reported offending token in the message to locate the bad line quickly.
- If a script transforms your BVH, fix its line ordering or validate output against the BVH spec.
Example fix
// before (malformed)
ROOT Hips
{
CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
OFFSET 0.0 0.0 0.0
// after (valid)
ROOT Hips
{
OFFSET 0.0 0.0 0.0
CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation Defensive patterns
Strategy: validation
Validate before calling
function assertOffsetFirstInsideNodes(text: string): void {
const lines = text.split(/\r?\n/).map((l) => l.trim());
let expectOffset = false;
lines.forEach((line, i) => {
const t = line.toUpperCase();
if (/^(ROOT|JOINT)\s/.test(t) || t === "END SITE") { expectOffset = true; return; }
if (expectOffset) {
if (line !== "{") throw new Error(`Line ${i + 1}: expected {`);
expectOffset = false;
// next non-brace line must be OFFSET
const next = lines[i + 1];
if (next && !next.toUpperCase().startsWith("OFFSET")) {
throw new Error(`Line ${i + 2}: expected OFFSET, got "${next.split(/\s+/)[0]}"`);
}
}
});
} Try / catch
try {
const skeleton = ReadBvh(text, scene, null, options);
} catch (e) {
if (e instanceof Error && e.message.startsWith("Expected OFFSET")) {
console.error("BVH node body is out of order: OFFSET must come first inside each node.");
} else { throw e; }
} Prevention
- Keep node body order fixed: OFFSET then CHANNELS then children.
- Re-export BVH files instead of editing them by hand.
- Use the error's echoed token to find the offending line fast.
When it happens
Trigger: A node body where CHANNELS, JOINT, "}", or any other token appears before OFFSET; swapped lines such as "CHANNELS 6 Xrotation ..." placed before OFFSET; a name line accidentally pasted inside the node body.
Common situations: Hand-edited BVH files with reordered lines; exports from custom/buggy tooling that writes CHANNELS before OFFSET; line-alignment drift when files are processed by scripts that re-sort or dedent lines.
Related errors
- Expected opening { after type & name
- Expected CHANNELS definition
- Unexpected end of file: missing OFFSET
- OFFSET: Invalid number of values
- Unexpected end of file: missing CHANNELS
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/b409cda5ade8b2ad.
Report an issue: GitHub.