vorg / geom-builder

Simplicial-complex-like geometry builder backed by typed arrays
MIT License
14 stars 2 forks source link

Use Uint32Array when necessary #4

Closed vorg closed 10 months ago

vorg commented 10 months ago

It is possible to build mesh with more than 64k vertices that creates clamped indices due to Uint16Array array for cell. Either we should switch to Uint32Array or upgrade to it once positionsIndex is above 60k

vorg commented 10 months ago

Another option would be to specify type, constructor or provide initial indices array in anticipation of big vertex count.

createGeomBuilder({ positions: 3, colors: 4, cells: { size: 3, type: Uint32Array } })
dmnsgn commented 10 months ago

Another option would be to specify type, constructor or provide initial indices array in anticipation of big vertex count.

createGeomBuilder({ positions: 3, colors: 4, cells: { size: 3, type: Uint32Array } })

I have my typed-array-constructor for that purpose.

vorg commented 10 months ago

Wanna patch it here?

vorg commented 10 months ago

And if we will use it i suggest a bit more readable syntax

new (typedArrayConstructor(indexCount * 2))(10); //anticipating next resize

vs

const DetectedArrayType = typedArrayConstructor(indexCount * 2) //anticipating next resize
indicesArray = new DetectedArrayType(10);