I have incorporated the collision detection system in its current state into the game engine. This took some time because I was fighting with the Blender-to-THREE workflow again. Here’s a little sidebar on that.
The recommended file format for working with 3D assets in THREE is glTF. This format is maintained by Khronos Group and includes important features like materials and animations. Unfortunately, it’s also been a huge pain to work with so far. Creating assets in Blender then exporting them to glTF seems to work fine, but working with the imported assets in THREE is just quirky sometimes. When you import a file it is added as a Scene that you then have to add to an existing Scene. The geometries are all BufferGeometry objects (which is actually a good thing for performance, but difficult to work with) and you just have to really work at getting things to line up just right.
I wanted to be able to model an asset in Blender, model a collision object separately but in the same file, then import the file with THREE and tell my collision detection system to use the hidden collision object. This way I can make the asset somewhat complex but still keep a simple collision cage for performance reasons. I don’t think this should be complicated but I struggled with it. Partially I still have trouble with asynchronous aspects of Javascript programming and so I was just confused. Partially it’s just somewhat difficult to do what I want to do with THREE.
After quite a bit of tinkering my system is now working. I have a weirdly shaped concave object with a separately modeled (also concave) collision cage that I put into a map file. My engine loads the asset, recognizes the collision cage, and the collision system responds correctly when you walk around it.
This is a big step in the right direction. Next I still need to do pretty much everything from my last post, but I have a working system already integrated into the rest of the engine. Hopefully this will keep me motivated to finish the code rewrite, implement gravity, blah blah blah.