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.

AssetExporterPlugin.md 1.7KB

1 vuosi sitten
1 vuosi sitten
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ---
  2. prev:
  3. text: 'FullScreenPlugin'
  4. link: './FullScreenPlugin'
  5. next:
  6. text: 'FileTransferPlugin'
  7. link: './FileTransferPlugin'
  8. ---
  9. # AssetExporterPlugin
  10. [//]: # (todo: image)
  11. [Example](https://threepipe.org/examples/#asset-exporter-plugin/) —
  12. [Source Code](https://github.com/repalash/threepipe/blob/master/src/plugins/export/AssetExporterPlugin.ts) —
  13. [API Reference](https://threepipe.org/docs/classes/AssetExporterPlugin.html)
  14. Asset Exporter Plugin provides options and methods to export the scene, object GLB or Viewer Config.
  15. All the functionality is available in the viewer(and `AssetExporter`) directly, this plugin only provides an ui-config and maintains state of the options which is saved as plugin configuration along with glb/vjson file
  16. ```typescript
  17. import {ThreeViewer, AssetExporterPlugin} from 'threepipe'
  18. const viewer = new ThreeViewer({...})
  19. const assetExporter = viewer.addPluginSync(new AssetExporterPlugin())
  20. // check the existing options
  21. console.log(assetExporter.exportOptions)
  22. // enable/disable viewer config/json embedding in glb
  23. assetExporter.viewerConfig = true
  24. // set encryption
  25. assetExporter.encrypt = true
  26. assetExporter.encryptKey = 'superstrongpassword' // comment this to get prompted for a key during export.
  27. // export scene as blob
  28. const blob = assetExporter.exportScene()
  29. // or export and download directly
  30. assetExporter.downloadSceneGlb()
  31. // export a specific object
  32. const object = viewer.scene.getObjectByName('objectName')
  33. const blob2 = assetExporter.exportObject(object, true) // true to also download
  34. ```
  35. Note: when downloading the model through the plugin, it uses viewer.export, which downloads the files by default, but uploads it to remote destinations when overloaded using `FileTransferPlugin`.