threepipe
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

DropzonePlugin.md 2.1KB

1 год назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ---
  2. prev:
  3. text: 'TonemapPlugin'
  4. link: './TonemapPlugin'
  5. next:
  6. text: 'ProgressivePlugin'
  7. link: './ProgressivePlugin'
  8. ---
  9. # DropzonePlugin
  10. [//]: # (todo: image)
  11. [Example](https://threepipe.org/examples/#dropzone-plugin/) —
  12. [Source Code](https://github.com/repalash/threepipe/blob/master/src/plugins/interaction/DropzonePlugin.ts) —
  13. [API Reference](https://threepipe.org/docs/classes/DropzonePlugin.html)
  14. DropzonePlugin adds support for drag and drop of local files to automatically import, process and load them into the viewer.
  15. DropzonePlugin can be added by default in ThreeViewer
  16. by setting the `dropzone` property to `true` or an object of `DropzonePluginOptions` in the options.
  17. ```typescript
  18. import {DropzonePlugin, ThreeViewer} from 'threepipe'
  19. const viewer = new ThreeViewer({
  20. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  21. dropzone: true, // just set to true to enable drag drop functionatility in the viewer
  22. })
  23. ```
  24. To set custom options,
  25. pass an object of [DropzonePluginOptions](https://threepipe.org/docs/interfaces/DropzonePluginOptions.html) type to the `dropzone` property.
  26. ```typescript
  27. import {DropzonePlugin, ThreeViewer} from 'threepipe'
  28. const viewer = new ThreeViewer({
  29. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  30. dropzone: { // this can also be set to true and configured by getting a reference to the DropzonePlugin
  31. allowedExtensions: ['gltf', 'glb', 'hdr', 'png', 'jpg', 'json', 'fbx', 'obj', 'bin', 'exr'], // only allow these file types. If undefined, all files are allowed.
  32. addOptions: {
  33. disposeSceneObjects: true, // auto dispose of old scene objects
  34. autoSetEnvironment: true, // when hdr is dropped
  35. autoSetBackground: true, // when any image is dropped
  36. autoCenter: true, // auto center the object
  37. autoScale: true, // auto scale according to radius
  38. autoScaleRadius: 2,
  39. license: 'Imported from dropzone', // Any license to set on imported objects
  40. importConfig: true, // import config from file
  41. },
  42. // check more options in the DropzonePluginOptions interface
  43. },
  44. })
  45. ```