|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- ---
- prev:
- text: '@threepipe/plugin-configurator'
- link: './plugin-configurator'
-
- next:
- text: '@threepipe/plugin-gltf-transform'
- link: './plugin-gltf-transform'
-
- ---
-
- # @threepipe/plugin-geometry-generator
-
- 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.
-
- [Example](https://threepipe.org/examples/#geometry-generator-plugin/) —
- [Source Code](https://github.com/repalash/threepipe/blob/master/plugins/geometry-generator/src/index.ts) —
- [API Reference](https://threepipe.org/plugins/geometry-generator/docs)
-
- [](https://www.npmjs.com/package/@threepipe/plugin-geometry-generator)
-
- ```bash
- npm install @threepipe/plugin-geometry-generator
- ```
-
- 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.
-
- Includes the following generator which inherit from [AGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/AGeometryGenerator.html):
- - **plane**: [PlaneGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/PlaneGeometryGenerator),
- - **sphere**: [SphereGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/SphereGeometryGenerator),
- - **box**: [BoxGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/BoxGeometryGenerator),
- - **circle**: [CircleGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/CircleGeometryGenerator),
- - **torus**: [TorusGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/TorusGeometryGenerator),
- - **cylinder**: [CylinderGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/CylinderGeometryGenerator),
-
-
- Sample Usage:
-
- ```typescript
- import {ThreeViewer, UnlitMaterial} from 'threepipe'
- import {GeometryGeneratorPlugin} from '@threepipe/plugin-geometry-generator'
-
- const viewer = new ThreeViewer({...})
- const generator = viewer.addPluginSync(GeometryGeneratorPlugin)
-
- const sphere = generator.generateObject('sphere', {radius: 3})
- viewer.scene.addObject(sphere)
-
- // to update the geometry
- generator.updateGeometry(sphere.geometry, {radius: 4, widthSegments: 100})
-
- // to add a custom generator
- generator.generators.custom = new CustomGenerator('custom') // Extend from AGeometryGenerator or implement GeometryGenerator interface
- // refresh the ui so the new generator is available to select.
- generator.uiConfig.uiRefresh?.()
-
- // change the material type for all objects
- generator.defaultMaterialClass = UnlitMaterial // by default its PhysicalMaterial
- viewer.scene.addObject(generator.generateObject('box', {width: 2, height: 2, depth: 2}))
-
- ```
|