threepipe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

script.ts 1.4KB

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