Jose Vicente Posted June 12, 2018 Share Posted June 12, 2018 Hello. I'm having a problem mixing BackFace culling and mesh cloning. I generate meshes from a server code, and because of my coordinate system (which I can't change) the triangles are not property oriented. This is fixed used instances with a negative scaling and this works. At some point, after user action, I clone one of the the meshes which has wrong triangles, and then I apply the same transformation that fixes the orientation for the instanced meshes, but the cloned mesh triangles are not property orientated and thus the cloned mesh is not visible. This code worked for me on Babylon 2.5. This can be checked here : https://playground.babylonjs.com/indexStable.html#VI428J#3 Mesh named 'test' is not visible because triangles are not property orientated -> OK Instanced mesh 'testI' is visible because the scaling fixes the orientation -> OK Cloned Mesh is not visible and I don't know why. If backface culling is disabled, all three meshes are visible. Any ideas ? Thanks in advance Quote Link to comment Share on other sites More sharing options...
Amarth2Estel Posted June 12, 2018 Share Posted June 12, 2018 Hello Jose Vicente ! I don't know why your code doesn't have the expected behaviour. BUT, to deal with your face orientation issue, I think you should use the flipFaces method on your mesh. Here is a PG : https://playground.babylonjs.com/indexStable.html#VI428J#4 Because cloned mesh uses the same vertexData as the "original" mesh it has been cloned from, flipping the faces of the clone will flip the faces of the original mesh as well. The same thing apply for the instanced mesh. To change the orientation of the cloned mesh only, you should try to use makeGeometryUnique on it to un-link its vertexData and the vertexData of the original mesh.. but it will loose the interest of cloning. You can comment line 42 to see this behaviour To apply a change (scaling, rotation or position) in the vertexData directly, then you can use bakeCurrentTransformIntoVertices. Keep in mind that if you call this method on a mesh, all the meshes sharing its geometry (instances and clones) will also be affected. Hope it will help ! GameMonetize and Jose Vicente 1 1 Quote Link to comment Share on other sites More sharing options...
Jose Vicente Posted June 13, 2018 Author Share Posted June 13, 2018 Thanks Amarth2Estel, I still doesn't know why the cloned mesh is not visible but with your help I've been able to find a workaround. Kind Regards. Amarth2Estel 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.