How to only export geometry using GLTFExporter?

When exporting gltf(glb), the file is too large.

We do not want to export material(image), and only geometry is needed.

GLTFExporter: Remove embedImages option

With gltf Export, only scenes or objects can be exported.

BufferGeometry is not an Object3D on its own.

However, BufferGeometry can be saved as a three.js definition, for example.
See SDFGeometry

1 Like

make a const exportDefaultMaterial = new MeshStandardMaterial()
Then do model.traverse and apply this material on each mesh ( + make backups so you can restore after export)

This will still export a material but you won’t have any images and the gltf file will stay compatible with other software

5 Likes

Agreed with suggestions above. THREE.GLTFExporter requires Object3D input, and you cannot make a Mesh without a Material, so there’s limited flexibility to create glTF files with arbitrary inputs this way.

If you still want to export just an isolated resource as glTF, you could use the glTF Transform library:

When using this method, it’s fine to not include a material. Just keep in mind that an isolated geometry, detached from any scene, may not show up in 3D viewers. Consider including a scene with the mesh for portability. The glTF format defines a default material if none is specified, automatically.

2 Likes