I find out the performance gap is due to the flag STATIC_DRAW
/ DYNAMIC_DRAW
on binding buffer data. Three.js use static by default while Babylon use dynamic.
/// thinEngine.ts
public createVertexBuffer(data: DataArray, _updatable?: boolean, _label?: string): DataBuffer {
return this._createVertexBuffer(data, this._gl.STATIC_DRAW);
}
public createDynamicVertexBuffer(data: DataArray, _label?: string): DataBuffer {
return this._createVertexBuffer(data, this._gl.DYNAMIC_DRAW);
}
After adding a true
as staticBuffer param to thinInstanceSetBuffer()
usage, the fps raised to 60. see PG
quad.thinInstanceSetBuffer("matrix", matricesData, 16, true);
quad.thinInstanceSetBuffer("color", colorData, 4, true);