egametang/ET · error · Exception
Invalid number of face vertices: 3 coordinates expected, fou
Error message
Invalid number of face vertices: 3 coordinates expected, found {v.Length} What it means
Thrown by ObjImporter.ReadFace when a face ('f') line, after splitting, has fewer than 4 tokens — i.e., fewer than 3 vertex references. A valid polygonal face needs at least 3 vertices; the OBJ line is incomplete.
Source
Thrown at Packages/cn.etetet.recast/Scripts/Core/Share/Recast/ObjImporter.cs:103
{
throw new Exception("Invalid vector, expected 3 coordinates, found " + (v.Length - 1));
}
// fix - https://github.com/ikpil/DotRecast/issues/7
return new float[]
{
float.Parse(v[1], CultureInfo.InvariantCulture),
float.Parse(v[2], CultureInfo.InvariantCulture),
float.Parse(v[3], CultureInfo.InvariantCulture)
};
}
private static void ReadFace(string line, ObjImporterContext context)
{
string[] v = line.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (v.Length < 4)
{
throw new Exception("Invalid number of face vertices: 3 coordinates expected, found " + v.Length);
}
for (int j = 0; j < v.Length - 3; j++)
{
context.meshFaces.Add(ReadFaceVertex(v[1], context));
for (int i = 0; i < 2; i++)
{
context.meshFaces.Add(ReadFaceVertex(v[2 + j + i], context));
}
}
}
private static int ReadFaceVertex(string face, ObjImporterContext context)
{
string[] v = face.Split("/");
return GetIndex(int.Parse(v[0]), context.vertexPositions.Count);
}
View on GitHub (pinned to 5cab01f7a8)
Solutions
- Find the offending 'f' line in the OBJ and ensure it lists at least 3 vertices.
- Re-export the mesh from the source DCC tool.
- Pre-validate that every 'f' line has >= 3 vertex references before importing.
Example fix
// before f 1 2 // after f 1 2 3
Defensive patterns
Strategy: validation
Validate before calling
foreach (var line in lines)
if (line.StartsWith("f "))
{
var t = line.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (t.Length < 4) throw new InvalidDataException($"Degenerate face: {line}");
} Type guard
static bool IsValidFaceLine(string line)
{ var t = line.Split(' ', StringSplitOptions.RemoveEmptyEntries); return t.Length >= 4; } Try / catch
try { ObjImporter.Load(chunk); }
catch (Exception e) when (e.Message.Contains("Invalid number of face vertices"))
{ /* fix offending 'f' line */ } Prevention
- Ensure every 'f' line has >= 3 vertex references.
- Re-export from the DCC tool.
- Pre-validate face lines before import.
When it happens
Trigger: An 'f' line with only two references (e.g., 'f 1 2'); a degenerate face; a face line truncated by editing/export.
Common situations: Malformed OBJs from broken exporters; manual edits that dropped a vertex index; edge-case meshes with degenerate faces.
Related errors
- Invalid vector, expected 3 coordinates, found {v.Length - 1}
- 0 vertex index
- {e.Message}
- 如果项非string类型,则必需设置解析器
- condition number parse error: {text}
AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13).
Data as JSON: /api/errors/a50e8ef95bddede5.
Report an issue: GitHub.