vixel
vixel copied to clipboard
Use more compact keys, prefer Map to Object
Hi, first off let me just thank you for an amazing project! I've had so much fun rendering voxel landscapes, a breeze to get started with this. Of course I more or less immediately started to push this to its limits, and encountered some problems when generating large maps.
I think I found some potential improvements:
- Most importantly, using ES6
Mapinstead ofObjectto store the voxels and their index appears to be much faster - I also made some changes regarding how keys are generated, preferring integers (as much as they exist in JavaScript...) or at least shorter strings as keys to the maps
- Material information was duplicated in the
Stageas well as in theVoxelIndex, so I replaced this with a reference from theStageto theVoxelIndex, which saves memory
Using this, I have shaved off something like 40% of the heap size when I generate a 512x32x512 Vixel, and time to initialize the map is down from 8 seconds to 6.7, which is not as significant but at least better.
Hope you can find some use for these changes!
@perliedman Thank you for these. Sorry it's taken me a year and a half to take a look. I'll see about integrating them.
No worries, I'm more than familiar with the feeling :sweat_smile: