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.

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import {_testFinish, _testStart, LoadingScreenPlugin, ThreeViewer} from 'threepipe'
  2. async function init() {
  3. const viewer = new ThreeViewer({
  4. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  5. msaa: true,
  6. dropzone: {
  7. addOptions: {
  8. disposeSceneObjects: true,
  9. autoSetEnvironment: true, // when hdr is dropped
  10. autoSetBackground: true,
  11. },
  12. },
  13. })
  14. viewer.addPluginSync(LoadingScreenPlugin)
  15. const env = 'https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr'
  16. const url = 'https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf'
  17. const responses = await Promise.all([
  18. fetch(env),
  19. fetch(url),
  20. ])
  21. const envFile = new File([await responses[0].blob()], 'venice_sunset_1k.hdr')
  22. await viewer.setEnvironmentMap(envFile, {
  23. setBackground: true,
  24. })
  25. const blob = await responses[1].blob()
  26. const file = new File([blob], url) // Set the file name to the URL, so that internal textures can be resolved correctly from the base path
  27. const result = await viewer.load(file, {
  28. autoCenter: true,
  29. autoScale: true,
  30. })
  31. console.log(result)
  32. }
  33. _testStart()
  34. init().finally(_testFinish)