threepipe
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

FragmentClippingExtensionPlugin.md 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ---
  2. prev:
  3. text: 'ClearcoatTintPlugin'
  4. link: './ClearcoatTintPlugin'
  5. next:
  6. text: 'ParallaxMappingPlugin'
  7. link: './ParallaxMappingPlugin'
  8. ---
  9. # FragmentClippingExtensionPlugin
  10. [//]: # (todo: image)
  11. [Example](https://threepipe.org/examples/#fragment-clipping-extension-plugin/) —
  12. [Source Code](https://github.com/repalash/threepipe/blob/master/src/plugins/material/FragmentClippingExtensionPlugin.ts) —
  13. [API Reference](https://threepipe.org/docs/classes/FragmentClippingExtensionPlugin.html)
  14. FragmentClippingExtensionPlugin adds a material extension to PhysicalMaterial to add support for fragment clipping.
  15. Fragment clipping allows to clip fragments of the material in screen space or world space based on a circle, rectangle, plane, sphere, etc.
  16. It uses fixed SDFs with params defined by the user for clipping.
  17. It also adds a UI to the material to edit the settings.
  18. It uses `WEBGI_materials_fragment_clipping_extension` glTF extension to save the settings in glTF/glb files.
  19. ```typescript
  20. import {ThreeViewer, FragmentClippingExtensionPlugin} from 'threepipe'
  21. const viewer = new ThreeViewer({...})
  22. const fragmentClipping = viewer.addPluginSync(FragmentClippingExtensionPlugin)
  23. // add initial properties
  24. FragmentClippingExtensionPlugin.AddFragmentClipping(material, {
  25. clipPosition: new Vector4(0.5, 0.5, 0, 0),
  26. clipParams: new Vector4(0.1, 0.05, 0, 1),
  27. })
  28. // Change properties with code or use the UI
  29. material.userData._fragmentClipping!.clipPosition.set(0, 0, 0, 0)
  30. material.setDirty()
  31. // Disable
  32. material.userData._clearcoatTint.clipEnabled = false
  33. material.setDirty()
  34. ```