threepipe
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

script.ts 2.9KB

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