Any bugs on updatable field?

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?

Platform: MacOS 11.6
Chrome: 98.0.4758.80

cc @JohnK who is our geometry expert :slight_smile:
cc @PirateJC for follow up in case we need one :wink:

Can you please have a look at the console? Do you see any WebGL speicifc error messages similar to this?

 WebGL2 256[.WebGL-0x70008a6200]GL ERROR :GL_INVALID_OPERATION : glDrawElements: attempt to access out of range vertices in attribute 0

i can see this warning in the console. I just open the example, then see the warning

@JohnK Hi!

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 :slight_smile: It fails on Windows only when you try to pick the mesh.

The offending code: (it actually does nothing)

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.

Hopefully I am not totally wrong lol


Thx for your professional reply. My project also set sideOrientation: BABYLON.Mesh.DOUBLESIDE and updatable:true. What is your suggestion to migrate 4.1.0 to 4.2.1?

Hey! This is a bug and needs to be fixed. Please wait for @JohnK 's response. Thank you!

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.

@KingWu, @roland

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. :slightly_smiling_face:


It would be a problem in the context of the fix I proposed :slight_smile: 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.

Thank you! :slight_smile:

@JohnK Can you release the fix on v4.2.2? v5.0 is still in beta and i am not sure that there is a breaking change in API.

As far as I know there is no way to make retrospective changes when a new version is under development. @Deltakosh ?

Breaking changes are always kept to a minimum and where they occur it will be to correct bugs. You can find a list of changes for v5.0, breaking changes are at the bottom of the list

Yup we are not moving back bug fixes to prior versions except related to browser breaking changes as we did for 4.2.1. You should be able to rely on our 5.0 beta safely though.

I see. Want to know when babylonjs 5.0.0 will be released?

@KingWu I believe you’d like to know.