three.js icon indicating copy to clipboard operation
three.js copied to clipboard

FBXLoader: Incorrect mesh parsing

Open mrdoob opened this issue 6 years ago • 3 comments

Apparently it loads correctly in Unity. Thanks @jcarpenter for the files.

Coordinate tests.zip

unnamed

/cc @looeee

mrdoob avatar Nov 06 '18 01:11 mrdoob

@mrdoob it's on my todo list 👍

looeee avatar Nov 07 '18 07:11 looeee

The issue here is that the polys have greater than 4 sides, which is not currently supported by the loader. Here's the vertex index for one of the letters:

29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, -29, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, -43, 14, 15, 1, -1, 15, 16, 2, -2, 16, 17, 3, -3, 17, 18, 4, -4, 18, 19, 5, -5, 19, 20, 6, -6, 20, 21, 7, -7, 21, 22, 8, -8, 22, 23, 9, -9, 23, 24, 10, -10, 24, 25, 11, -11, 25, 26, 12, -12, 26, 27, 13, -13, 27, 14, 0, -14

Negative numbers indicate the final vertex in a polygon - so the first two polygons here have 14 sides. @mrdoob, @jcarpenter do you know what program this was exported from? When I import the file to 3DS max and then re-export it automatically triangulates these faces, even when I disable the "triangulate" option.

We have two options here: support higher order polygons, or log a warning saying that polygons with more than 4 sides are not supported.

looeee avatar Jul 09 '19 05:07 looeee

or log a warning saying that polygons with more than 4 sides are not supported.

We can start with that.

mrdoob avatar Jul 31 '19 04:07 mrdoob

Maybe this has already been considered but it seems like the Earcut.triangulage function would enable the triangulation of these polygons in the loader fairly easily if someone wants to tackle this.

gkjohnson avatar Nov 28 '22 15:11 gkjohnson

Was that function always there? 😅

It could probably be used in the LWOLoader too

https://github.com/mrdoob/three.js/blob/dev/examples/jsm/loaders/LWOLoader.js#L818

looeee avatar Dec 07 '22 19:12 looeee

I think it's been around for a bit but it seems relatively hidden / unknown 😁

gkjohnson avatar Dec 08 '22 02:12 gkjohnson