Exported .ply mesh from OF looks different when loaded in three.js

Hello, I’ve exported a mesh of a tree from OF, saving it as .ply format, using mesh.saveMesh("filename.ply");. When loaded into three.js, the junctions of the branches composing the tree look broken. Here is how a junction looks like in openFrameworks

Here the wireframe

and here wireframe and normals.

When I load the mesh into threejs, the junction looks like this:

I do not know if I’m drawing the mesh in a wrong way, or if the OF mesh exporter is broken, or if threejs is not showing the .ply mesh properly.
I think it is most probably the first option :wink:

I’ve opened the .ply file with meshLab, and the mesh looks the same as in openFrameworks, the first picture that I’ve posted.

Any suggestion? also an indication on which direction I should investigate is appreciated.

Normals seem fine, but it looks to me like the z-buffer is not doing it’s job (depth testing is off), the polygons are just all rendered on top of each other in whatever order they appear in the ply file. Can you share a bit of your three.js code?

Thank you @Paul-Jan for your suggestion. This is my js code that loads and render the mesh generated with OF.
In that repository there is also the simple.ply mesh (basically a Y in 3d) generated with OF. As I said, it looks correct when opened with meshLab. Probably you’re right, the problem is in threejs and not in openFrameworks or in the mesh generation.

Ah, sample code always beats a still image. I was wrong, the z-buffer is working fine, it is just rendering the wrong side of the polygons. This is probably a little bug in the .PLY loader (I’m not sure if .PLY specifies a winding order), but it can be easily fixed by specifying

material.side = THREE.BackSide;

in your THREE.js material definition. Result:

Yes, your fix works, thanks. I will open an issue on threejs.