BabylonJS/Babylon.js · error · Error

Invalid frame time line

Error message

Invalid frame time line

What it means

ReadBvh splits the frame-time line on whitespace and requires at least 3 tokens (label words plus the numeric value, e.g. 'Frame Time: 0.033333'). This error is thrown when the line exists but has too few whitespace-separated tokens to contain a frame time value.

Source

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

    if (framesTokens.length < 2) {
        throw new Error("Invalid frame count line");
    }

    // number of frames
    const numFrames = parseInt(framesTokens[1]);
    if (isNaN(numFrames)) {
        throw new Error("Failed to read number of frames.");
    }
    context.numFrames = numFrames;

    // frame time
    const frameTimeLine = lines.shift();
    if (!frameTimeLine) {
        throw new Error("Unexpected end of file before frame time");
    }
    const frameTimeTokens = frameTimeLine.trim().split(/[\s]+/);
    if (frameTimeTokens.length < 3) {
        throw new Error("Invalid frame time line");
    }
    const frameTime = parseFloat(frameTimeTokens[2]);
    if (isNaN(frameTime)) {
        throw new Error("Failed to read frame time.");
    }
    if (frameTime <= 0) {
        throw new Error("Failed to read frame time. Invalid value " + frameTime);
    }

    context.frameRate = 1 / frameTime;

    // read frame data line by line
    for (let i = 0; i < numFrames; ++i) {
        const frameLine = lines.shift();
        if (!frameLine) {
            continue;
        }
        const tokens = frameLine.trim().split(/[\s]+/) || [];

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Inspect the line after 'Frames: N' in the BVH file and ensure it reads 'Frame Time: <positive number>'
  2. Fix or restore the frame-time line with the correct value, e.g. 'Frame Time: 0.033333'
  3. Re-export the BVH from the original tool if the header format is nonstandard
  4. If parsing third-party files, validate the MOTION header lines before passing to ReadBvh

Example fix

// before
Frame Time
// after
Frame Time: 0.033333
Defensive patterns

Strategy: validation

Validate before calling

function validateFrameTimeLine(text) {
  const m = text.match(/^Frame Time:\s*(.+)$/im);
  if (!m) throw new Error('No Frame Time: line');
  if (m[1].trim().split(/\s+/).length < 1 || isNaN(parseFloat(m[1]))) {
    throw new Error('Frame Time line lacks a numeric value');
  }
}

Type guard

function hasValidFrameTimeTokens(text: string): boolean {
  const m = text.match(/^Frame Time:\s*(.+)$/im);
  return !!m && m[1].trim().split(/\s+/).length >= 1;
}

Try / catch

try {
  skeleton.readBvh(text);
} catch (e) {
  if (e instanceof Error && e.message === 'Invalid frame time line') {
    console.error("Frame Time line malformed; expected 'Frame Time: <seconds>'");
  } else throw e;
}

Prevention

When it happens

Trigger: A 'Frame Time:' line written as 'FrameTime' (one token), 'Frame Time' (two tokens, no value), an empty/blank line where the frame time should be, or a file using an unexpected label format at that position.

Common situations: Hand-edited BVH files, exporters that write 'Frame Time:' without the numeric value, files where lines were collapsed or the value was accidentally deleted, or locale-exported files with mislabeled headers.

Related errors


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