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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import {
  2. _testFinish,
  3. CameraViewPlugin,
  4. ChromaticAberrationPlugin,
  5. DepthBufferPlugin,
  6. DropzonePlugin,
  7. FilmicGrainPlugin,
  8. FrameFadePlugin,
  9. FullScreenPlugin,
  10. GLTFAnimationPlugin,
  11. HalfFloatType,
  12. HDRiGroundPlugin,
  13. HemisphereLight,
  14. KTX2LoadPlugin,
  15. KTXLoadPlugin,
  16. NormalBufferPlugin,
  17. PickingPlugin,
  18. PLYLoadPlugin,
  19. ProgressivePlugin,
  20. RenderTargetPreviewPlugin,
  21. Rhino3dmLoadPlugin,
  22. SceneUiConfigPlugin,
  23. STLLoadPlugin,
  24. ThreeViewer,
  25. TonemapPlugin,
  26. USDZLoadPlugin,
  27. ViewerUiConfigPlugin,
  28. VignettePlugin,
  29. } from 'threepipe'
  30. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'
  31. import {TweakpaneEditorPlugin} from '@threepipe/plugin-tweakpane-editor'
  32. import {BlendLoadPlugin} from '@threepipe/plugin-blend-importer'
  33. import {extraImportPlugins} from '@threepipe/plugin-extra-importers'
  34. async function init() {
  35. const viewer = new ThreeViewer({
  36. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  37. msaa: true,
  38. rgbm: true,
  39. zPrepass: false, // set it to true if you only have opaque objects in the scene to get better performance.
  40. dropzone: {
  41. addOptions: {
  42. clearSceneObjects: false, // clear the scene before adding new objects on drop.
  43. },
  44. },
  45. })
  46. // @ts-expect-error unused
  47. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true))
  48. const editor = viewer.addPluginSync(new TweakpaneEditorPlugin())
  49. await viewer.addPlugins([
  50. new ProgressivePlugin(),
  51. GLTFAnimationPlugin,
  52. PickingPlugin,
  53. CameraViewPlugin,
  54. ViewerUiConfigPlugin,
  55. // new SceneUiConfigPlugin(), // this is already in ViewerUiPlugin
  56. new DepthBufferPlugin(HalfFloatType, true, true),
  57. new NormalBufferPlugin(HalfFloatType, false),
  58. new RenderTargetPreviewPlugin(false),
  59. new FrameFadePlugin(),
  60. new HDRiGroundPlugin(false, true),
  61. new VignettePlugin(false),
  62. new ChromaticAberrationPlugin(false),
  63. new FilmicGrainPlugin(false),
  64. KTX2LoadPlugin,
  65. KTXLoadPlugin,
  66. PLYLoadPlugin,
  67. Rhino3dmLoadPlugin,
  68. STLLoadPlugin,
  69. USDZLoadPlugin,
  70. BlendLoadPlugin,
  71. ...extraImportPlugins,
  72. ])
  73. const rt = viewer.getOrAddPluginSync(RenderTargetPreviewPlugin)
  74. rt.addTarget(viewer.getPlugin(DepthBufferPlugin)?.target, 'depth', false, false, false)
  75. rt.addTarget(viewer.getPlugin(NormalBufferPlugin)?.target, 'normal', false, true, false)
  76. editor.loadPlugins({
  77. ['Viewer']: [ViewerUiConfigPlugin, SceneUiConfigPlugin, DropzonePlugin, FullScreenPlugin],
  78. ['Interaction']: [PickingPlugin],
  79. ['GBuffer']: [DepthBufferPlugin, NormalBufferPlugin],
  80. ['Post-processing']: [TonemapPlugin, ProgressivePlugin, FrameFadePlugin, VignettePlugin],
  81. ['Animation']: [GLTFAnimationPlugin, CameraViewPlugin],
  82. ['Extras']: [HDRiGroundPlugin, Rhino3dmLoadPlugin],
  83. ['Debug']: [RenderTargetPreviewPlugin],
  84. })
  85. viewer.scene.addObject(new HemisphereLight(0xffffff, 0x444444, 5))
  86. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr')
  87. // const result = await viewer.load<IObject3D>('https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Blender-Exporter@master/polly/project_polly.gltf', {
  88. // autoCenter: true,
  89. // autoScale: true,
  90. // })
  91. //
  92. // const model = result?.getObjectByName('Correction__MovingCamera')
  93. // const config = model?.uiConfig
  94. // console.log(model, config, result)
  95. // if (config) ui.appendChild(config)
  96. }
  97. init().then(_testFinish)