Debugging it, I was able to track down the issue to the MeshBatcher.canBatch method. It has two bugs, which are causing it to erroneously report "true" (indicating it has space), when in fact it does not.[.WebGL-000031B603EFE200] GL_INVALID_OPERATION: Error: 0x00000502, in ..\..\third_party\angle\src\libANGLE\renderer\d3d\VertexDataManager.cpp, reserveSpaceForAttrib:520. Internal error: 0x00000502: Vertex buffer is not big enough for the draw call.

WebGL: INVALID_VALUE: bufferSubData: srcOffset + length too large

Here's the original method:

**canBatch**(

**verticesLength**,

**indicesLength**) {

**if**(

**this**.

**indicesLength**+

**indicesLength**>=

**this**.

**indices**.

**byteLength**/

**2**)

**return**

**false**;

**if**(

**this**.

**verticesLength**+

**verticesLength**>=

**this**.

**vertices**.

**byteLength**/

**2**)

**return**

**false**;

**return**

**true**;

}

**if**(

**this**.

**verticesLength**+

**verticesLength**>=

**this**.

**vertices**.

**byteLength**/

**2**)

Bug 2: The "verticesLength" field is really a number of floats, not vertices. SkeletonMesh is passing in a value that assumes that are SkeletonMesh.VERTEX_SIZE (8) floats per vertex. But from MeshBatcher's perspective, vertices have MeshBatcher.VERTEX_SIZE (9) floats per vertex. If you look down in the batch method, you can see that for every 8 floats passed in, 9 floats are added to the MeshBatcher (with the uniform 'z' value getting stamped on each vertex).

I'm not sure what the most elegant fix is, but I calculated a "vertLength3D" value in canBatch, to work out the number of floats of actual space that are implied by the submitted value, and then used that in the comparison:

**let**

**vertLength3D**=

**verticesLength*** (

**Mesh**

**Batcher**.

**V**

**E**

**R**

**T**

**E**

**X_**

**S**

**I**

**Z**

**E**/

**Skeleton**

**Mesh**.

**V**

**E**

**R**

**T**

**E**

**X_**

**S**

**I**

**Z**

**E**);

and then

**if**(

**this**.

**verticesLength**+

**vertLength3D**>=

**this**.

**vertices**.

**byteLength**/

**4**)