How to store an octree

  1. What do you mean by “it doesn’t work”? It’s possible to store pretty much any kind of data in a JSON, even binary if you’re into that - storing octree should actually be quite easy, since it’s just boundaries.

  2. Not directly an answer to the question, but most likely an answer to your challenge overall (ie. there’s little reason for reinventing the wheel, if there’s a ready robust opensource alternative :relieved:)

  • three-mesh-bvh: see this example and this example. Three-mesh-bvh runs on pure optimised magic, so using it may not only spare you all the unnecessary coding, but will also likely work faster :sweat_smile:
  • recast-navigation-js: this is a different approach to navigation in games (although a better one compared to raycasting, if you want to implement character movement and AI navigation.) You can combine it together with raycast collisions, since these are generally more expensive.
2 Likes