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

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