I try to upgrade my project from 4.1.0 to 4.2.1 . I found that updatable is set to true when creating polygon, which will be crashed. I found an example on playground. Try to set updatable to be true, then the polygon will be disappeared. So, there exist bugs? Also, how can i update the polygon?
Guys, I’m trying to get as much familiar with the source code as I can so I did a little debug session on this.
The error occurs when you set sideOrientation: BABYLON.Mesh.DOUBLESIDE. The indices are added correctly but the positions array remains the same thus the indices are pointing to non existent vertices. Windows is quite indulgent on this but Mac/Android is not It fails on Windows only when you try to pick the mesh.
The problem here is that positions is a Float32Array and a typed array can’t change it’s size after it was created. The indices are added correctly, it’s not a typed array. Another problem is that the positions is a ref in the public static _ComputeSides function and changing it’s size by creating a new array in the method will not help. I believe this must be already handled in PolygonMeshBuilder.buildVertexData() We need to double the size of the positions/normals/uvs here or somewhere in this function.
A temporary solution could be to create two front side meshes, put them close enough to each other and rotate one of them. This way you would need to modify your existing code though. Or wait with the migration until the bug gets fixed.
The doubling of the build once in PolygonMeshBuilder.buildVertexData() and again in CreatePolygonVertexData is the issue, I have prevented this happening in a PR just submitted. The update will, of course, be in v5.0 rather than v4.2.1
If you see this as a problem with the _ComputeSides functions please raise as a separate bug, I am not going to attempt to make any changes with such a fundamental function.
It would be a problem in the context of the fix I proposed So no problem at all here!
What I saw while debugging was 15 vertices (or 16 I can’t recall it now) in the positions array. The other half of the indices array entries pointed to vertices with index greater than the last vertice index so basicaly 15 and up. This is why I thought we are missing some vertices.