threepipe
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import {
  2. _testFinish,
  3. _testStart,
  4. IObject3D,
  5. LoadingScreenPlugin,
  6. PhysicalMaterial,
  7. SSAAPlugin,
  8. ThreeViewer,
  9. } from 'threepipe'
  10. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'
  11. // @ts-expect-error todo fix
  12. import {BloomPlugin, TemporalAAPlugin} from '@threepipe/webgi-plugins'
  13. async function init() {
  14. const viewer = new ThreeViewer({
  15. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  16. msaa: false,
  17. rgbm: false,
  18. zPrepass: false,
  19. renderScale: 1,
  20. // rgbm: false,
  21. maxHDRIntensity: 8,
  22. dropzone: {
  23. addOptions: {
  24. disposeSceneObjects: true,
  25. },
  26. },
  27. plugins: [LoadingScreenPlugin, SSAAPlugin, TemporalAAPlugin],
  28. })
  29. const bloom = viewer.addPluginSync(BloomPlugin)
  30. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true))
  31. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr', {
  32. setBackground: true,
  33. })
  34. const result = await viewer.load<IObject3D>('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf', {
  35. autoCenter: true,
  36. autoScale: true,
  37. })
  38. const model = result?.getObjectByName('node_damagedHelmet_-6514')
  39. const materials = (model?.materials || []) as PhysicalMaterial[]
  40. ui.setupPluginUi(bloom)
  41. for (const material of materials) {
  42. ui.appendChild(material.uiConfig)
  43. }
  44. bloom.pass!.intensity = 3
  45. bloom.pass!.threshold = 1
  46. // viewer.scene.background = null
  47. // bloom.pass!.bloomDebug = true
  48. }
  49. _testStart()
  50. init().then(_testFinish)