threepipe
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

GLTFKHRMaterialVariantsPlugin.md 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. ---
  2. prev:
  3. text: 'ThreeFirstPersonControlsPlugin'
  4. link: './ThreeFirstPersonControlsPlugin'
  5. next:
  6. text: 'Rhino3dmLoadPlugin'
  7. link: './Rhino3dmLoadPlugin'
  8. ---
  9. # GLTFKHRMaterialVariantsPlugin
  10. [//]: # (todo: image)
  11. [Example](https://threepipe.org/examples/#gltf-khr-material-variants-plugin/) —
  12. [Source Code](https://github.com/repalash/threepipe/blob/master/src/plugins/extras/GLTFKHRMaterialVariantsPlugin.ts) —
  13. [API Reference](https://threepipe.org/docs/classes/GLTFKHRMaterialVariantsPlugin.html)
  14. GLTFKHRMaterialVariantsPlugin adds support for importing and exporting glTF models with the `KHR_materials_variants` extension to load the model with different material variants/combinations. It also provides API and UI to change the current material variant.
  15. The plugin automatically adds support for the extension when added to the viewer.
  16. The materials are stored in `object.userData._variantMaterials` and are automatically loaded and saved when using the `GLTFLoader`.
  17. Sample Usage
  18. ```typescript
  19. import {ThreeViewer, GLTFKHRMaterialVariantsPlugin, Mesh2} from 'threepipe'
  20. const viewer = new ThreeViewer({...})
  21. const variantsPlugin = viewer.addPluginSync(GLTFKHRMaterialVariantsPlugin)
  22. // load some model
  23. await viewer.load(model_url)
  24. // list of all variants in the model (names and objects)
  25. console.log(variantsPlugin.variants)
  26. // change the selected variant
  27. variantsPlugin.selectedVariant = 'beach'
  28. ```
  29. ## Links
  30. - https://www.khronos.org/blog/blender-gltf-i-o-support-for-gltf-pbr-material-extensions
  31. - https://www.khronos.org/blog/streamlining-3d-commerce-with-material-variant-support-in-gltf-assets
  32. - https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_variants/README.md