I’m trying to use the DRACOExporter
for my project. Occasionally, my project will get a BufferGeometry
that has “groups” in it. If that is the case, I want to have the DRACOExporter
export one mesh for every group in the BufferGeometry
. I’m struggling to find a good way to do this though.
My first thought was to just clone the BufferGeometry
and manipulate the new copy. Looking at the source code, if I clone a BufferGeometry
, that will also clone all it’s BufferAttribute
s, which will all copy their underlying TypedArray
. I’m hesitant to do this, because some models will have very high poly counts (5 million or more) and I’m worried about how much time/memory that will consume copying the entire array multiple times (If there are 6 groups present, it would copy the same 5 million element array 6 times). However, even if I did just clone the original buffer geometry, I’m not sure how to modify it so that it only has the faces for a single group. Looking at the source code for the DRACOExporter
, it seems to ignore things like draw ranges anyway?
Is there any way that I can create a BufferGeometry
which shares the same underlying arrays as another BufferGeometry
? I see that you can create a new BufferAttribute
with a TypedArray
, and I know that TypedArray
s are views of an underlying ArrayBuffer
. So I can perhaps create multiple views of the same ArrayBuffer
and create different BufferGeometry
s from each one. Once I have multiple BufferGeometry
s I can then give them one by one to the DRACOExporter
. I’ve started going down this road, but it’s starting to get a little complicated, and I worry that I might have missed a simpler solution to my problem. Will this strategy (using the same underlying arrays) work, or is there something about three.js that will prevent me from doing this? Alternatively, is there a better solution to my problem?