Bug with reversed triangle winding order with imported .model files
importerbugneeds repro
When I imported a .glb model via flutter_scene_importer and rendered it with `Node.fromAsset()`, all front facing surfaces were invisible, the model appeared inside out. The root cause seemed to the the `ParseGLTF` function in `importer_gltf.cc` where the scene root transform is set to scale (1,1,-1) to convert from gLTF's coordinate system to flutter_scene's. This matrix is a negative determinant which reverses the handedness of the coordinate system and flips the triangle winding order from counter clock wise to clock wise. And then since the `Material.bind()` sets the `WindingOrder::counterClockwise` with backface culling, the camera facing tri's are classified as back faces and culled.
In the attached .patch I compensate for this by swapping the second and third index of every triangle in the index buffer during asset imports so front faces remain using CCW after zflip. I tested this with a multi material car model (18 prims, mixed opaque/transp) and the surfaces rendered properly without me having to call `pass.setWindingOrder(gpu.WindingOrder.clockwise)` after every `Material.bind()`
[fix-winding-order.patch](https://github.com/user-attachments/files/28115878/fix-winding-order.patch)
Ran into this using flutter_scene_importer version 0.9.0-0
关闭于 2026-05-23 2 条评论