Hello again,
It took me a while to figure this and I had to switch to another problematic mesh to get this understanding. Finally, turned up with this, working the merge of my wheels.
Where the ‘wheel_back’ is a clone of parts of the front wheel, with the added merge of a rear wheel sprocket, already merged together with wheel sprocket bolts… not sure I make myself clear here… told ya this project was a lego game;) In short it’s a triple merge of meshes and clones and merged clones.
Realizing with my suspension debug that the bug was unlikely to be a result of parenting, I focused on the merge and here is my discovery, although I’m not sure how to interprete this:
It appears that if I end my array of merged items (already merged meshes/clones and separate meshes/clones), If I end my array with my already merged “tyre” (in other words with a multimat although I didn’t set it, it comes from the merge), then the result is ok:
‘Project Motorcycle Debug merges’
However, if I end my array with a single mat (non-merged) mesh or clone, the result is this:
‘Project Motorcycle Debug merges 4’
Focus on the tyre and see how the material is applied. Set an alpha of 0 on the tyresidemat and see the difference between the front tyre base (at zero origin) and the back wheel tyre (on top right).
Notice that the count of vertices is the same in both cases, however the bug version displays a ‘ghost’ of the tyre side using the first material of the other merged object in the array (the sprocket with material named ‘aluscratchrustmat03’.
In resume, where ‘wheelsprocket’ and ‘tyre_back’ are already a merge of meshes and clones:
If I pass on this, it shows fine:
const wheel_back = BABYLON.Mesh.MergeMeshes([wheelb, wheelprofileb, wheelraysb, wheelsprocket, (scene.getMeshByName(“cyl_screwclone0”)), (scene.getMeshByName(“bolt_basic_clone2”)), tyre_back], true, true, undefined, false, true);
As opposed to this that shows fine with cdn but wrong with preview:
const wheel_back = BABYLON.Mesh.MergeMeshes([wheelb, wheelprofileb, wheelraysb, tyre_back, wheelsprocket, (scene.getMeshByName(“cyl_screwclone0”)), (scene.getMeshByName(“bolt_basic_clone2”))], true, true, undefined, false, true);
Edited 4h later:( :
Following the above I tried to apply this to my suspension (first exemple of buggy meshes) but had no luck. I tried hard figuring what was going, since the ‘standalone’ debug version is working, unmerging everything, removing meshes/clones, changing the order in the array, changing the materials but nothing did it.
Only now do I realize I get this warning from loading in preview (not with cdn)
GL_INVALID_OPERATION: Vertex buffer is not big enough for the draw call
@RaananW Could this be part of an explanation? Thanks for your time…