Using the standard three.js FPS example of octree implementation with a more advanced mesh, crashes the page on load.
My first idea is to write a few functions to save the octee data to a file, then load it, to avoid the extra computational time, such as the following added to the example, which is slightly edited:
this.chootify/*save as object that can be stringified*/ = () => {
return ({
triangles:this.triangles,
box:this.box,
subTrees:this.subTrees.map(k=>k.chootify())
});
};
this.load = (awts) => {
this.triangles = awts.triangles
this.box = awts.box
this.subTrees = []
if(awts.subTrees){
awts.subTrees.forEach(k=>{
var aw = new AwtsOctTree(k.box)
aw.load(k)
this.subTrees.push(aw)
})
}
}
and then I was planning on loading it in a background thread.
However I didn't realize that even for a fairly simple building mesh, the octree file would take up 230mb of space when stringified (example: run functions to worldOctree from console to test).
When using a more complex mesh with stairs etc. it completely crashes the web page using the standard build-on-runtime method.
I have no idea how to optimize this, any thoughts?