fenomas / noa

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

Migration to Typescript & ES6 Classes #133

Closed SamKirkland closed 3 years ago

SamKirkland commented 3 years ago

This library rocks. ❤️ I've been using voxel.js for a while now but it seems to be abandonware at this point. Noa is absolutely amazing and has a lot of potential.

In my opinion the only thing holding this project back is lack of documentation & examples. I hope to contribute in this area over the next few months.

Step 1: Migrate & add jsdocs to main lib files [This PR] Step 2: Add dat-gui Step 3: Migrate & add jsdocs to component files Step 4: Establish some build tooling like a code formatter, tests, and using github actions to deploy noa-examples on each commit Step 5+: Add to existing markdown docs to live playground examples using codesandbox.io

I've spent the last few weeks converting the main library code over to ES6 classes and typescript. You will see a night and day difference in IntelliSense. I've been using this typescript version for the past few weeks and the development experience is amazing.

I've updated a large number of jsdoc comments and documented some undocumented features/options along the way. Also fixed a few dozen bugs that came up when type checking was enabled. A large number of any types are still being used, these can be iterated on in the future. Some of these are because implicit typing is lacking due to dependent libraries not having types (integrating work like Miguel's would be helpful here).

Here are some of the changes in this PR:

Please let me know of any feedback.

Closes #85

Patbox commented 3 years ago

I can say it looks interesting. However, it looks like it's based on master (0.28) and not develop (0.29), so it lacks some new stuff (like bigger block limit and other, see https://github.com/andyhall/noa/tree/develop ), so I can't test it with my project :/

fenomas commented 3 years ago

Hi Sam, thanks for looking at this!

This mostly looks like a good direction, but it's a lot of large changes so I'd need to take some time with it (particularly since I'm not currently using TS). Can you structure this in its own branch (based off #develop rather than #master), so that I and others can pull it in and try our projects in it?

Also if this PR contains bug fixes that aren't related to the conversion/documentation work, it would great if you could mention those so I can check that before/after behavior separately from the conversion work generally.

Thanks!

SamKirkland commented 3 years ago

I've opened up a PR for the dev branch --> #134

I can look through the code and try to put together a list of the bugs. Most are type related (obviously lol) For example terrainMesher.meshChunk is using the wrong props. If you look at the usage in chunk, its missing a ignoreMaterials prop so the useAO, aoVals, revAoVal are all using the wrong arg for the name.