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

script.ts 1.6KB

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