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

script.ts 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {_testFinish, IObject3D, PhysicalMaterial, ProgressivePlugin, SSAAPlugin, ThreeViewer} from 'threepipe'
  2. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'
  3. async function init() {
  4. const viewer = new ThreeViewer({
  5. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  6. debug: true,
  7. msaa: false,
  8. rgbm: true,
  9. renderScale: 1,
  10. dropzone: {
  11. addOptions: {
  12. disposeSceneObjects: true,
  13. importConfig: true,
  14. },
  15. },
  16. })
  17. viewer.addPluginSync(new SSAAPlugin())
  18. await Promise.all([
  19. viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr'),
  20. // viewer.load<IObject3D>('https://threejs.org/examples/models/gltf/IridescenceLamp.glb', {
  21. // autoCenter: true,
  22. // autoScale: true,
  23. // }),
  24. viewer.load<IObject3D>('https://threejs.org/examples/models/gltf/LittlestTokyo.glb', {
  25. autoCenter: true,
  26. autoScale: true,
  27. }),
  28. ])
  29. viewer.scene.overrideMaterial = new PhysicalMaterial({
  30. color: 'white',
  31. roughness: 1,
  32. metalness: 0,
  33. wireframe: true,
  34. })
  35. viewer.scene.mainCamera.position.set(0, 0, 3.5)
  36. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true))
  37. ui.appendChild({
  38. type: 'toggle',
  39. label: 'Auto Rotate',
  40. property: [viewer.scene.mainCamera.controls, 'autoRotate'],
  41. })
  42. ui.setupPluginUi(SSAAPlugin, {
  43. expanded: true,
  44. })
  45. ui.setupPlugins(ProgressivePlugin)
  46. await viewer.getPlugin(ProgressivePlugin)?.convergedPromise
  47. console.log('converged')
  48. }
  49. init().finally(_testFinish)