threepipe
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

script.ts 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import {_testFinish, BoxGeometry, Color, Mesh, PhysicalMaterial, ThreeViewer, TonemapPlugin} 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. rgbm: false,
  7. dropzone: {
  8. allowedExtensions: ['gltf', 'glb', 'hdr'],
  9. addOptions: {
  10. disposeSceneObjects: true,
  11. autoSetEnvironment: true, // when hdr is dropped
  12. autoSetBackground: true,
  13. },
  14. },
  15. })
  16. viewer.scene.backgroundColor = new Color().set('black')
  17. viewer.getPlugin(TonemapPlugin)!.exposure = 0.04
  18. // viewer.renderManager.screenPass.outputColorSpace = LinearSRGBColorSpace
  19. const box = new BoxGeometry(0.5, 0.5, 0.5)
  20. const material = new PhysicalMaterial({
  21. color: 'white',
  22. emissive: 'white',
  23. emissiveIntensity: 1,
  24. })
  25. const n = 5
  26. for (let i = 0; i < n * n; i++) {
  27. const mesh = new Mesh()
  28. const mat = material.clone()
  29. mat.emissiveIntensity = (1 - i / (n * n)) * 16
  30. mesh.material = mat
  31. mesh.geometry = box
  32. mesh.position.x = Math.floor(n / 2) - Math.floor(i % n)
  33. mesh.position.y = Math.floor(i / n) - Math.floor(n / 2)
  34. mesh.position.multiplyScalar(0.5)
  35. viewer.scene.addObject(mesh)
  36. console.log(mat.emissiveIntensity)
  37. }
  38. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true))
  39. ui.setupPluginUi(TonemapPlugin)
  40. ui.appendChild(viewer.renderManager.screenPass.uiConfig)
  41. }
  42. init().then(_testFinish)