Tools for splitting Three.js objects into (cube) chunks?

I’m curious if someone has tools for splitting Three.js meshes (their geometries), or GLTF or OBJ models, into cube-shaped chunks of arbitrary size.

What I would like to do, for example, is take large models, split them up into cube chunks, then be able to load/unload those chunks (tiles) using something like @gkjohnson’s zoom-based (LOD) 3D tile loader.

I hacked together a prototype along these lines recently, just splitting a glTF/GLB file in two along a plane. Might be useful as starting point, but it doesn’t support all cases yet… Gist: Divide glTF Document.

NYTimes R&D has published some interesting work in this area too, using 3D Tiles, glTF, and various tools:

2 Likes

Thanks for that. Another thing that just occurred to me is using

or one of the newer derivatives. F.e. if I take the intersection of my model and a cube, that’ll give me a chunk or tile. I wonder if texture maps are handled…

EDIT: The modernized version of CSG by @manthrax,

has examples that maintain materials/textures in place.

I think CSG is overly complex and heavy for this type of thing. If you’re interested in writing you’re own converter I’d look into writing your own slicing logic or something out there that’s more light weight. Clipping geometry with a plane or box isn’t as complex as it seems. You really just need a function to slice a triangle into it’s component parts, convert the quad component to two triangles, and determine which side of the plane the triangles you want to keep are on. Creating decimated or lower level of detail tiles is the more complicated piece, though, but there should be libraries for that, too.

It looks like there are existing open source tools on Github for converting to 3d tiles, though, if you look through the 3d-tiles and 3dtiles tags. Keep in mind I haven’t used any of these and can’t vouch for any of them but it looks like there are command line tools to convert OBJ or GLTF to a hierarchical 3d tiles format. Perhaps you can use or build upon these?

1 Like

Late to the party, but here’s an example of chopping up a torus knot with a bunch of boxes…

3 Likes