voxel-mesher
voxel-mesher copied to clipboard
Performance improvement: Don't call .subarray on final array
It would probably be a bit faster to not return a subarray slice of a typedarray from the voxel mesher and instead return the entire unsliced typedarray + a size parameter for the number of vertices. That way the typedarray that it creates would not be truncated and could possibly be returned to the memory pool when it is done.
In a web worker type environment, the way this could work is the worker would generate typedarrays/chunks, pass them directly to the main thread which uploads them to WebGL, and then the main thread would pass them back to the worker which would put them back on the heap. (By calling typedarray-pool.free)
https://github.com/mikolalysenko/typedarray-pool#poolfreearray