fenomas / noa

Experimental voxel game engine.
MIT License
611 stars 87 forks source link

Meshing in a worker #130

Closed Jarred-Sumner closed 4 years ago

Jarred-Sumner commented 4 years ago

I have meshing in a worker like 50% working

It technically works and feels quite fast...but, there's two really weird bugs that I don't really understand the cause of.

Video (worker meshing on): https://www.dropbox.com/s/t4pmgs1w7v50nnm/worker.1.mp4?dl=0 Video (worker meshing off): https://www.dropbox.com/s/ko3foqcmiftfa4k/Screen%20Recording%202020-07-24%20at%2011.35.15%20AM.mp4?dl=0

Bug 1: Some chunks are skipped? Specifically, the one the player starts at (something to do with _chunkIDsToMeshFirst maybe?) Bug 2: The positions of the chunks are all wrong.

Does anything come to mind why this might happen? I suspect the two bugs are related, but the positions being wrong makes no sense to me. The position is set on the main thread.

This is all using SharedArrayBuffer for the voxel / neighbor data

Jarred-Sumner commented 4 years ago

Fixed it. I forgot to pass the offset of the ndarray.

Jarred-Sumner commented 4 years ago

If you want the code I can make a PR but it's a lot of other changes too, it would be time-consuming for you to review it, and the code style doesn't match what you currently do (no semicolons, using ES6 classes, etc)