GLTFExporter does not respect drawRange?

So mesh made using three-bvh-csg uses drawRange to its advantage to clip some unnecessary part of the mesh

when this mesh is exported as glb the drawRange is ignored and entire mesh is visible

before i report an issue on github was wondering if this a valid usecase which gltf exporter should support ?

here’s a js fiddle to rest

We have decided at GitHub some time ago that exporters do not honor drawRange. The property is just a hint for the renderer which does not affect the actual structure of the geometry.

So if you want to export only parts of the geometry data, you have to extract the data on app level before the export is done.

2 Likes

Eventually I have found the mentioned thread:

1 Like

cool

so workaround would be to :

  • clone the geometry ,
  • use the drawRange start & count to splice the attributes
  • make the drawRange infinite again
  • if there are geometry.groups do it for each entry

and export this geometry

We have decided at GitHub some time ago that exporters do not honor drawRange .

Is this documented? It might be nice if the exporters logged a warning or something if the geometry has a draw range that will result in the exported result looking different. three-bvh-csg uses this to keep performance up and outputs valid three.js geometry but people think it’s broken because GLTFExporter doesn’t support the draw range setting.

It might be nice to provide a transform function in BufferGeometryUtils to convert draw range geometry so it can be exported correctly.

1 Like

BufferGeometryUtils has a mergeGroups method which helped me trim the geometry to correct range

(i have updated a reply on the main csg thread with workaround which worked + sandbox )

Sounds good!

1 Like