BabylonJS/Babylon.js · error · Error

Failed to read frame time.

Error message

Failed to read frame time.

What it means

After extracting the third token of the frame-time line, ReadBvh parses it with parseFloat and throws this error when the result is NaN, meaning the token in the value position is not a valid number.

Source

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

    // 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]+/) || [];
        ReadFrameData(tokens, i, root, { i: 0 });
    }

    context.root = root;

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Check the frame-time value in the file and replace it with a plain decimal number using a dot separator, e.g. 'Frame Time: 0.033333'
  2. Convert comma decimal separators to dots if the file came from a locale that formats numbers with commas
  3. Re-export the BVH from the source application if the header value is corrupted
  4. Validate the Frame Time line with a regex like /^Frame Time:\s+[0-9.]+e?-?[0-9]*$/i before parsing

Example fix

// before
Frame Time: 0,033333
// after
Frame Time: 0.033333
Defensive patterns

Strategy: validation

Validate before calling

function validateFrameTimeValue(text) {
  const m = text.match(/^Frame Time:\s*([^\s]+)\s*$/im);
  if (!m || isNaN(parseFloat(m[1]))) {
    throw new Error('Frame Time value is not a valid decimal number');
  }
}

Type guard

function isParsableFrameTime(text: string): boolean {
  const m = text.match(/^Frame Time:\s*([^\s]+)\s*$/im);
  return !!m && !isNaN(parseFloat(m[1]));
}

Try / catch

try {
  skeleton.readBvh(text);
} catch (e) {
  if (e instanceof Error && e.message === 'Failed to read frame time.') {
    console.error('Frame Time value is not numeric; use dot-decimal like 0.033333');
  } else throw e;
}

Prevention

When it happens

Trigger: A frame-time line like 'Frame Time: abc' or 'Frame Time: 1/30' where the third token cannot be parsed as a float; also occurs when a stray non-numeric token sits in the value position after whitespace splitting.

Common situations: Files corrupted by find-and-replace, locale-formatted values ('0,033' with comma decimal separator in some exports), manually typed garbage in the header, or templated BVH files with unfilled placeholders.

Related errors


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