Getting "Invalid array length" at OctreeHelper

I am trying to load 700kb model in my scene (glb), and then apply an Octree, but I keep getting this error

this is exactly where it breaks:

(in code)

const octree = new OctreeHelper( collider );

(in console)

my model is made of 3 buildings. if I remove 2 and leave only 1, it loads and works as expected.

What could be the issue?

does it matter which building you remove that makes it work?

The octtree generation function is recursive, so it’s possible you might be hitting a stack limit of some kind, but I would expect a different error from that… so I suspect there might be something funky in one of the geometries themselves. Perhaps a degenerate triangle or something…

The array is too big, once you get to a certain threshold and you try to push, it will double in size. Preallocating a typed array should work.