threepipe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

plugin-gltf-transform.md 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ---
  2. prev:
  3. text: '@threepipe/plugin-geometry-generator'
  4. link: './plugin-geometry-generator'
  5. next:
  6. text: '@threepipe/plugins-extra-importers'
  7. link: './plugins-extra-importers'
  8. ---
  9. # @threepipe/plugin-gltf-transform
  10. Exports [GLTFDracoExportPlugin](https://threepipe.org/plugins/gltf-transform/docs/classes/GLTFDracoExportPlugin.html) that extends the default gltf exporter to compress the file after export.
  11. [Example](https://threepipe.org/examples/#glb-draco-export/) —
  12. [Source Code](plugins/gltf-transform/src/index.ts) —
  13. [API Reference](https://threepipe.org/plugins/gltf-transform/docs)
  14. [![NPM Package](https://img.shields.io/npm/v/@threepipe/plugin-gltf-transform.svg)](https://www.npmjs.com/package/@threepipe/plugin-gltf-transform)
  15. ```bash
  16. npm install @threepipe/plugin-gltf-transform
  17. ```
  18. To use, simply add the plugin to the viewer and export using the `viewer.export` or `viewer.exportScene` functions. This also adds UI options to `AssetExporterPlugin` which are used when exporting using the plugin or using `viewer.exportScene`
  19. The plugin overloads the default gltf exporter in the asset manager with `GLTFDracoExporter`. Using the [gltf-transform](https://gltf-transform.donmccurdy.com/) library, it compresses the exported gltf file using the [khr_draco_mesh_compression](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_draco_mesh_compression/README.md) extension.
  20. Note - Only `glb` export supported right now.
  21. Sample Usage:
  22. ```typescript
  23. import {ThreeViewer, downloadBlob} from 'threepipe'
  24. import {GLTFDracoExportPlugin} from '@threepipe/plugin-gltf-transform'
  25. const viewer = new ThreeViewer({...})
  26. viewer.addPluginSync(GLTFDracoExportPlugin)
  27. await viewer.load('file.glb')
  28. const blob = await viewer.exportScene({
  29. compress: true, // this must be specified, by default it's false.
  30. viewerConfig: true, // to export with viewer, scene and plugin settings
  31. })
  32. // download the file
  33. downloadBlob(blob, 'scene.glb')
  34. ```