--- 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) [![NPM Package](https://img.shields.io/npm/v/@threepipe/plugin-geometry-generator.svg)](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})) ```