0
\$\begingroup\$

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?

\$\endgroup\$
4
  • \$\begingroup\$ Do you observe any errors printing in the developer console? \$\endgroup\$
    – DMGregory
    Aug 25, 2022 at 11:21
  • \$\begingroup\$ @DMGregory no errors everything seems to functioning as expected, except for the huge amount of processin power needed to generate it. simpler meshes work fine with the same code \$\endgroup\$ Aug 25, 2022 at 11:23
  • \$\begingroup\$ ....so does it crash or does it work? Asking simply "my program crashes, how do I fix it" is not a question we can answer if you don't do your part to diagnose where the error occurs and tell us more about the issue. \$\endgroup\$
    – Vaillancourt
    Aug 25, 2022 at 12:07
  • \$\begingroup\$ @Vaillancourt it works with simple meshes. It completely crashed for a mesh with only about 40k verticies. I know exactly what the problem is-- in the method that the octree is being built at runtime. Trying to save the octree to a file using standard exporting methods would take up 230mb for a simple file. The question is how a moderately complex mesh can be loaded more efficiently, all the code is cited in the question. \$\endgroup\$ Aug 25, 2022 at 12:39

0

You must log in to answer this question.

Browse other questions tagged .