BabylonJS/Babylon.js · error · Error

Expected identifier for node name, got '${identTok.value}' a

Error message

Expected identifier for node name, got '${identTok.value}' at pos ${identTok.pos}

What it means

The ASCII FBX parser's token-driven node reader expects a node name token (an Identifier) after whitespace; whatever token it found (a number, punctuation, or EOF artifact) cannot be a valid FBX node name, so it aborts with the offending token value and position. This guards against structurally malformed ASCII FBX text rather than silently producing a node with a garbage name.

Source

Thrown at packages/dev/loaders/src/FBX/parsers/fbxAsciiParser.ts:247

    }

    private isIdentChar(ch: string): boolean {
        return this.isIdentStart(ch) || this.isDigit(ch) || ch === "|";
    }
}

// ── Node Parsing ───────────────────────────────────────────────────────────────

function parseNodeFromTokens(tokenizer: Tokenizer): FBXNode | null {
    const nameTok = tokenizer.peek();
    if (nameTok.type === TokenType.CloseBrace || nameTok.type === TokenType.EOF) {
        return null;
    }

    // Node name
    const identTok = tokenizer.next();
    if (identTok.type !== TokenType.Identifier) {
        throw new Error(`Expected identifier for node name, got '${identTok.value}' at pos ${identTok.pos}`);
    }
    const name = identTok.value;
    tokenizer.expect(TokenType.Colon);

    // Parse properties until we hit '{' or end-of-line content
    const properties: FBXProperty[] = [];
    const children: FBXNode[] = [];

    // Check for array shorthand: *count { a: ... }
    let peek = tokenizer.peek();
    if (peek.type === TokenType.Star) {
        // Array node like "Vertices: *25959 {"
        tokenizer.next(); // consume *
        const countTok = tokenizer.expect(TokenType.Number);
        const count = parseInt(countTok.value);
        tokenizer.expect(TokenType.OpenBrace);

        // Expect "a:" followed by comma-separated values

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Open the file at the reported pos and fix the malformed node so it reads `NodeType: "Name" { ... }`
  2. Re-export the FBX from the source DCC tool (Blender/Maya/3ds Max) instead of hand-editing
  3. Check the file is actually ASCII FBX (starts with `; FBX ...` or `FBXHeaderExtension:`), not binary — binary files must go through the binary parser
  4. Verify no earlier parse error shifted tokenization; inspect tokens preceding pos

Example fix

// before (malformed ASCII FBX)
Model: {
// after
Model: "Cube" {
Defensive patterns

Strategy: validation

Validate before calling

function isLikelyAsciiFbx(text) {
  const head = text.slice(0, 512);
  if (/Kaydara FBX Binary/.test(head)) return false;
  // every node line should look like: Name: ... or Name: "Name" {
  return /^[A-Za-z_][\w ]*:/m.test(head);
}
if (!isLikelyAsciiFbx(fbxText)) throw new Error("Not ASCII FBX");

Try / catch

try {
  const doc = parseAsciiFbx(text);
} catch (e) {
  if (e.message.includes("Expected identifier for node name")) {
    const m = e.message.match(/pos (\d+)/);
    console.error(`Malformed FBX near char ${m?.[1]}; fix the node or re-export the file`);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling the loader's parse/entry functions (via `node`/`child` in parseNodeFromTokens) on ASCII FBX text where the token after optional properties is not an identifier — e.g. a stray number, ':' or '{' where 'Model: 12345' expects a name, or a syntax error earlier in the file shifted token boundaries.

Common situations: Hand-edited or truncated .fbx ASCII files; files exported by tools producing non-standard ASCII FBX; copying/pasting FBX snippets with missing node names; files that are actually binary FBX being fed through the ASCII parser path.

Related errors


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