threepipe
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

script.ts 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {
  2. _testFinish, _testStart,
  3. Color,
  4. GLTFLoader2,
  5. IObject3D,
  6. LineMaterial2,
  7. LoadingScreenPlugin,
  8. PickingPlugin, PopmotionPlugin,
  9. ThreeViewer,
  10. } from 'threepipe'
  11. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'
  12. // Read more about the example - https://threepipe.org/notes/gltf-mesh-lines
  13. async function init() {
  14. const viewer = new ThreeViewer({
  15. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  16. msaa: true,
  17. plugins: [LoadingScreenPlugin, PickingPlugin],
  18. dropzone: true,
  19. })
  20. viewer.scene.autoNearFarEnabled = false
  21. GLTFLoader2.UseMeshLines = true
  22. viewer.scene.backgroundColor = new Color(0x333333)
  23. await viewer.load<IObject3D>('https://asset-samples.threepipe.org/demos/temple-lines.glb.zip', {
  24. autoScale: true,
  25. autoCenter: true,
  26. })
  27. const popmotion = viewer.addPluginSync(PopmotionPlugin)
  28. const material = viewer.materialManager.findMaterialsByName('Stone')[0] as LineMaterial2
  29. popmotion.animate({
  30. from: 0,
  31. to: 1,
  32. duration: 1000,
  33. repeat: Infinity,
  34. repeatType: 'mirror',
  35. onUpdate: (v) => {
  36. material.linewidth = Math.sin(v * Math.PI) * 3.5 + 1
  37. material.color.setHSL(v, 0.5, 0.7)
  38. material.setDirty()
  39. },
  40. })
  41. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true))
  42. ui.setupPluginUi(PickingPlugin)
  43. }
  44. _testStart()
  45. init().finally(_testFinish)