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

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