threepipe
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

script.ts 1.9KB

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