@triforge/radius-parametric-geometry
v0.1.1
Published
Parametric geometry for Three.js - 90.6% triangle reduction
Maintainers
Readme
@three-radius-parametric
Optimized parametric geometry for Three.js with 90.6% triangle reduction.
Installation
npm install @three-radius-parametric threeQuick Start
import { RadiusParametricGeometry } from '@three-radius-parametric'
import * as THREE from 'three'
const geometry = new RadiusParametricGeometry(
(u, v) => 1 + 0.5 * Math.cos(v * Math.PI * 2),
(u, v) => 0.5 * Math.sin(v * Math.PI * 2),
{ radiusSegments: 32, heightSegments: 16 }
)
const mesh = new THREE.Mesh(geometry, new THREE.MeshPhongMaterial({ color: 0x00ff00 }))
scene.add(mesh)API
Constructor
new RadiusParametricGeometry(
radiusFunction: (u: number, v: number) => number,
heightFunction?: (u: number, v: number) => number,
options?: RadiusGeometryOptions
)Both u and v are in [0, 1].
Options
| Option | Default | Description |
|---|---|---|
| radiusSegments | 32 | Segments around the axis |
| heightSegments | 16 | Segments along the height |
| thetaStart | 0 | Start angle (radians) |
| thetaLength | 2π | Angle sweep (radians) |
Methods
getStats(): GeometryStats— vertex count, triangle count, memory usage
Examples
Sphere
new RadiusParametricGeometry((u, v) => Math.sin(v * Math.PI))Cone
new RadiusParametricGeometry(
(u, v) => 1 - v,
(u, v) => v
)Torus
new RadiusParametricGeometry(
(u, v) => 1 + 0.5 * Math.cos(v * Math.PI * 2),
(u, v) => 0.5 * Math.sin(v * Math.PI * 2)
)Wavy Cylinder
new RadiusParametricGeometry(
(u, v) => 1 + 0.3 * Math.sin(u * Math.PI * 4 + v * Math.PI * 2)
)Performance
- 90.6% triangle reduction vs high-resolution standard approach
- 88%+ memory reduction
- Compatible with all Three.js materials and physics engines
License
MIT
