BabylonJS/Babylon.js · error · Error
ASCII FBX array declared ${count} values but parsed ${values
Error message
ASCII FBX array declared ${count} values but parsed ${values.length} What it means
ASCII FBX array properties (`*N { a: v1,v2,... }`) declare the exact number of values N in the header. After consuming tokens the parser counts what it actually parsed; if the count mismatches the declared N the file is corrupt/inconsistent, so it throws rather than returning a mis-shaped typed array.
Source
Thrown at packages/dev/loaders/src/FBX/parsers/fbxAsciiParser.ts:351
const values: number[] = [];
while (true) {
const peek = tokenizer.peek();
if (peek.type === TokenType.CloseBrace || peek.type === TokenType.EOF) {
break;
}
if (peek.type === TokenType.Comma) {
tokenizer.next();
continue;
}
if (peek.type === TokenType.Number) {
const tok = tokenizer.next();
values.push(Number(tok.value));
} else {
break;
}
}
if (values.length !== count) {
throw new Error(`ASCII FBX array declared ${count} values but parsed ${values.length}`);
}
return values;
}
function parseNumericValue(str: string): number {
return Number(str);
}
function isInt32(value: number): boolean {
return value >= -2147483648 && value <= 2147483647;
}
View on GitHub (pinned to 0592b347b8)
Solutions
- Fix the declared count to match the number of values (`*23` if 23 values follow) or restore the missing values
- Re-export the FBX from the original tool to regenerate a consistent file
- Check for truncated/corrupted transfer — re-download or re-copy the file
- Look for unparseable tokens (e.g. `NaN`, stray characters) right after the last parsed value
Example fix
// before (ASCII FBX)
Vertices: *3 {
a: 1,2
}
// after
Vertices: *3 {
a: 1,2,3
} Defensive patterns
Strategy: try-catch
Validate before calling
// cheap pre-check: array headers and value counts
for (const m of text.matchAll(/\*(\d+)\s*\{([^}]*)\}/g)) {
const declared = Number(m[1]);
const actual = m[2].split(',').filter(s => s.trim() !== '').length;
if (declared !== actual) throw new Error(`Array declares ${declared} but has ${actual}`);
} Try / catch
try {
const doc = parseAsciiFbx(text);
} catch (e) {
if (/declared \d+ values but parsed/.test(e.message)) {
console.error("FBX array count mismatch — file likely truncated or hand-edited; re-export it");
} else throw e;
} Prevention
- Verify file size/checksum after download before parsing
- Avoid manual edits to `*N {...}` blocks; if editing, update N
- Prefer binary FBX export over ASCII for pipeline assets
- Reject empty/overshort files early (size sanity check)
When it happens
Trigger: Parsing an ASCII FBX via `values` (parseArrayValues) where the `*N` declared count differs from the comma-separated values actually present — e.g. declared `*24` but only 23 numbers before the closing brace, or trailing garbage breaks token consumption early.
Common situations: Truncated downloads of .fbx files; manual edits removing/adding values without updating the `*N` count; third-party exporters that write wrong array counts; float values containing characters the tokenizer rejects, ending value parsing early.
Related errors
- Expected identifier for node name, got '${identTok.value}' a
- Truncated binary FBX header
- Unsupported FBX array encoding: ${encoding}
- Error in HufUnpackEncTable
- Expected opening { after type & name
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/83b2c174f1963e3c.
Report an issue: GitHub.