BabylonJS/Babylon.js · error · Error

Expected CHANNELS definition

Error message

Expected CHANNELS definition

What it means

Inside a node body, the line after OFFSET must be a CHANNELS declaration. If the parser reads a line whose first token is not CHANNELS (e.g. "}", "JOINT", or garbage), it throws because the channel layout is mandatory for every animated node in the BVH format.

Source

Thrown at packages/dev/loaders/src/BVH/bvhLoader.ts:293

    }

    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");
        }

        if (tokens[0].toUpperCase() != "CHANNELS") {
            throw new Error("Expected CHANNELS definition");
        }

        const numChannels = parseInt(tokens[1]);
        // Skip CHANNELS and the number of channels
        node.channels = tokens.splice(2, numChannels);
        node.children = [];
    }

    // read children
    while (lines.length > 0) {
        const line = lines.shift()?.trim();

        if (line === "}") {
            // Finish reading the node
            return node;
        } else if (line) {
            node.children.push(ReadNode(lines, line, node, context));
        }

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Add the required CHANNELS line after each node's OFFSET, e.g. "CHANNELS 3 Zrotation Xrotation Yrotation" for leaf joints and 6-channel (position+rotation) sets for roots.
  2. Verify ROOT uses CHANNELS 6 with X/Y/Z position plus rotations; JOINTs use CHANNELS 3 with rotations only, per the standard dialect.
  3. Re-export the file from the original mocap/DCC tool instead of hand-editing.
  4. Check that the token reported in the message is not a stray line (e.g. a duplicated "}") that should be removed.

Example fix

// before
JOINT Chest
{
  OFFSET 0.0 8.0 0.0
}
// after
JOINT Chest
{
  OFFSET 0.0 8.0 0.0
  CHANNELS 3 Zrotation Xrotation Yrotation
}
Defensive patterns

Strategy: validation

Validate before calling

function assertChannelsAfterOffset(text: string): void {
  const lines = text.split(/\r?\n/).map((l) => l.trim());
  for (let i = 0; i < lines.length; i++) {
    if (lines[i].toUpperCase().startsWith("OFFSET")) {
      const next = lines[i + 1];
      // for non-ENDSITE nodes the next line inside the body must be CHANNELS
      if (next && next !== "}" && !next.toUpperCase().startsWith("CHANNELS") && !next.toUpperCase().startsWith("JOINT")) {
        throw new Error(`Line ${i + 2}: expected CHANNELS after OFFSET, got "${next.split(/\s+/)[0]}"`);
      }
    }
  }
}

Try / catch

try {
  const skeleton = ReadBvh(text, scene, null, options);
} catch (e) {
  if (e instanceof Error && e.message === "Expected CHANNELS definition") {
    console.error("A non-ENDSITE node is missing its CHANNELS declaration.");
  } else { throw e; }
}

Prevention

When it happens

Trigger: A JOINT/ROOT whose body goes straight from OFFSET to "}" (channels omitted), or from OFFSET to a child JOINT line; END-node content pasted into a normal joint; a node incorrectly typed as END SITE earlier causing brace/line misalignment downstream.

Common situations: Hand-written or hand-trimmed BVH files; custom exporters that skip CHANNELS for leaf joints (spec requires CHANNELS even with 0..3 entries for non-ENDSITE nodes); files from tools using slightly different dialects.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/9acf8bb959ad6f23. Report an issue: GitHub.