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.

1234567891011121314151617181920212223242526272829303132333435363738
  1. import {_testFinish, DropzonePlugin, ThreeViewer} from 'threepipe'
  2. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'
  3. async function init() {
  4. const viewer = new ThreeViewer({
  5. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  6. dropzone: { // this can also be set to true and configured by getting a reference to the DropzonePlugin
  7. allowedExtensions: ['gltf', 'glb', 'hdr', 'bin', 'png', 'jpeg', 'webp', 'jpg', 'exr', 'fbx', 'obj'], // only allow these file types. If undefined, all files are allowed.
  8. addOptions: {
  9. disposeSceneObjects: true, // auto dispose of old scene objects
  10. autoSetEnvironment: true, // when hdr is dropped
  11. autoSetBackground: true, // when any image is dropped
  12. autoCenter: true, // auto center the object
  13. autoScale: true, // auto scale according to radius
  14. autoScaleRadius: 2,
  15. license: 'Imported from dropzone', // Any license to set on imported objects
  16. importConfig: true, // import config from file
  17. },
  18. },
  19. })
  20. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr')
  21. const dropzone = viewer.getPlugin(DropzonePlugin)!
  22. dropzone.addEventListener('drop', (e: any) => {
  23. if (!e.assets?.length) return // no assets imported
  24. console.log('Dropped Event:', e)
  25. const promptDiv = document.getElementById('prompt-div')!
  26. promptDiv.style.display = 'none'
  27. })
  28. const ui = viewer.addPluginSync(TweakpaneUiPlugin, true)
  29. ui.appendChild(dropzone.uiConfig)
  30. }
  31. init().then(_testFinish)