slin
January 7, 2022, 6:08pm
1
Hello,
There seem to be a Chrome upgrade happened and initially I was hit by this missing highp declaration for sampler2DShadow error . So I upgraded to babylon.js 5.0.0-beta.2 (also tried alpha 65).
After upgrade, I got the error in the screenshot. It was working in babylon.js 5.0.0-alpha.45 before upgrade.
It is difficult to reproduce in the PG. What I did was essentially the following. The vertex data I provide to the mesh has not been changed. But now I got the above error when calling convertToFlatShadedMesh.
const vertexData = new VertexData();
vertexData.positions = positions;
vertexData.indices = indices;
vertexData.normals = [];
vertexData.colors = [];
VertexData.ComputeNormals(vertexData.positions, vertexData.indices, vertexData.normals);
const terrainMesh = new Mesh(TerrainMeshName, scene);
vertexData.applyToMesh(terrainMesh, true);
terrainMesh.material = terrainMaterial;
terrainMesh.useVertexColors = true;
terrainMesh.convertToFlatShadedMesh();
Hi slin,
That error likely indicates that your offset
is large enough that the Float32Array
being created overflows the buffer on which it’s being created, but without an inspectable repro it’s difficult to know exactly how that may have come about. To be clear, this error appeared after the version change with no changes to your code at all?
slin
January 7, 2022, 6:23pm
3
Update:
I debugged into the code and found the issue. In convertToFlatShadedMesh, the error was thrown from this.getVerticesData(kind)
for the colors
kind.
Code snippet from convertToFlatShadedMesh in mesh.ts
for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
kind = kinds[kindIndex];
var vertexBuffer = <VertexBuffer>this.getVertexBuffer(kind);
if (kind === VertexBuffer.NormalKind) {
updatableNormals = vertexBuffer.isUpdatable();
kinds.splice(kindIndex, 1);
kindIndex--;
continue;
}
vbs[kind] = vertexBuffer;
data[kind] = this.getVerticesData(kind)!;
newdata[kind] = [];
}
It seems the newer version breaks because I have this line in my code:
vertexData.colors = [];
After removing this line it works again in the newer version.
2 Likes
Ok makes sense. This is expected as you have to provide a complete set of vertex data
Thanks a lot!
I’ll update the code to be a bit more resilient
3 Likes
Hey @Deltakosh just checking, do we have an issue to track this?
LOL! Yes boss, this is done
1 Like