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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import {
  2. _testFinish, _testStart,
  3. BoxGeometry,
  4. Color,
  5. LoadingScreenPlugin,
  6. Mesh,
  7. PhysicalMaterial,
  8. ThreeViewer,
  9. TonemapPlugin,
  10. } from 'threepipe'
  11. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'
  12. async function init() {
  13. const viewer = new ThreeViewer({
  14. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  15. rgbm: false,
  16. plugins: [LoadingScreenPlugin],
  17. })
  18. viewer.scene.backgroundColor = new Color().set('black')
  19. viewer.getPlugin(TonemapPlugin)!.exposure = 0.04
  20. // viewer.renderManager.screenPass.outputColorSpace = LinearSRGBColorSpace
  21. const box = new BoxGeometry(0.5, 0.5, 0.5)
  22. const material = new PhysicalMaterial({
  23. color: 'white',
  24. emissive: 'white',
  25. emissiveIntensity: 1,
  26. })
  27. const n = 5
  28. for (let i = 0; i < n * n; i++) {
  29. const mesh = new Mesh()
  30. const mat = material.clone()
  31. mat.emissiveIntensity = (1 - i / (n * n)) * 16
  32. mesh.material = mat
  33. mesh.geometry = box
  34. mesh.position.x = Math.floor(n / 2) - Math.floor(i % n)
  35. mesh.position.y = Math.floor(i / n) - Math.floor(n / 2)
  36. mesh.position.multiplyScalar(0.5)
  37. viewer.scene.addObject(mesh)
  38. console.log(mat.emissiveIntensity)
  39. }
  40. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true))
  41. ui.setupPluginUi(TonemapPlugin)
  42. ui.appendChild(viewer.renderManager.screenPass.uiConfig)
  43. }
  44. _testStart()
  45. init().finally(_testFinish)