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ů.

plugin-geometry-generator.md 2.9KB

před 1 rokem
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ---
  2. prev:
  3. text: '@threepipe/plugin-configurator'
  4. link: './plugin-configurator'
  5. next:
  6. text: '@threepipe/plugin-gltf-transform'
  7. link: './plugin-gltf-transform'
  8. ---
  9. # @threepipe/plugin-geometry-generator
  10. Exports [GeometryGeneratorPlugin](https://threepipe.org/plugins/geometry-generator/docs/classes/BlendLoadPlugin.html) with several Geometry generators to create parametric and updatable geometries like plane, circle, sphere, box, torus, cylinder, cone etc.
  11. [Example](https://threepipe.org/examples/#geometry-generator-plugin/) —
  12. [Source Code](https://github.com/repalash/threepipe/blob/master/plugins/geometry-generator/src/index.ts) —
  13. [API Reference](https://threepipe.org/plugins/geometry-generator/docs)
  14. [![NPM Package](https://img.shields.io/npm/v/@threepipe/plugin-geometry-generator.svg)](https://www.npmjs.com/package/@threepipe/plugin-geometry-generator)
  15. ```bash
  16. npm install @threepipe/plugin-geometry-generator
  17. ```
  18. The generated geometries/meshes include the parameters in the userData and can be re-generated by changing the parameters from the UI or the plugin API.
  19. Includes the following generator which inherit from [AGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/AGeometryGenerator.html):
  20. - **plane**: [PlaneGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/PlaneGeometryGenerator),
  21. - **sphere**: [SphereGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/SphereGeometryGenerator),
  22. - **box**: [BoxGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/BoxGeometryGenerator),
  23. - **circle**: [CircleGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/CircleGeometryGenerator),
  24. - **torus**: [TorusGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/TorusGeometryGenerator),
  25. - **cylinder**: [CylinderGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/CylinderGeometryGenerator),
  26. Sample Usage:
  27. ```typescript
  28. import {ThreeViewer, UnlitMaterial} from 'threepipe'
  29. import {GeometryGeneratorPlugin} from '@threepipe/plugin-geometry-generator'
  30. const viewer = new ThreeViewer({...})
  31. const generator = viewer.addPluginSync(GeometryGeneratorPlugin)
  32. const sphere = generator.generateObject('sphere', {radius: 3})
  33. viewer.scene.addObject(sphere)
  34. // to update the geometry
  35. generator.updateGeometry(sphere.geometry, {radius: 4, widthSegments: 100})
  36. // to add a custom generator
  37. generator.generators.custom = new CustomGenerator('custom') // Extend from AGeometryGenerator or implement GeometryGenerator interface
  38. // refresh the ui so the new generator is available to select.
  39. generator.uiConfig.uiRefresh?.()
  40. // change the material type for all objects
  41. generator.defaultMaterialClass = UnlitMaterial // by default its PhysicalMaterial
  42. viewer.scene.addObject(generator.generateObject('box', {width: 2, height: 2, depth: 2}))
  43. ```