Custom mesh, depth rendering problem

Hi all. Please see this playground:

https://playground.babylonjs.com/#JSR8SF#2

I’m creating a mesh from a VRML/WRL string. My goal isn’t to make a general VRML loader, but just a function to load VRML strings formatted exactly like the example in that playground.

It generally works well, but the front of the mesh is sometimes rendered behind the back of the mesh. Any ideas how to correct this?

Also, I know VRML uses a right-handed coordinate system. But Babylon.js is left handed. How can I modify the coordinates from the VRML file to be right handed? I know about scene.useRightHandedSystem, but I want to load in babylon files that are also left handed, so I don’t think changing the handedness of the whole scene is the right approach.

As always, thanks for all your help with this!

This is because you set

customMesh.hasVertexAlpha = true;

while i guess it’s either not supposed to have it, or it just translates badly to babylon,
secondly, the sideOrientation seems wrong,

mat.sideOrientation = BABYLON.Mesh.DOUBLESIDE;
with BABYLON.Mesh.FRONTSIDE; the mesh now seems to render correctly

https://playground.babylonjs.com/#JSR8SF#4

As for right-handed -> left-handed, i do not know, but if you do manage to convert it, remember to set sideOrientation to BABYLON.Mesh.BACKSIDE; aswell.

last thought, please use github or other third-party sites to host mesh data of that size, each PG version is a new copy of the code which has to be stored. :slight_smile:

1 Like

Much thanks for your help! That’s exactly what I was looking for. All the best.