@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
13 lines (12 loc) • 500 B
JavaScript
;
import { RoundedBoxGeometry } from "three/examples/jsm/geometries/RoundedBoxGeometry";
export function createCapsuleGeometry(capsuleOptions) {
const { radius, height, divisions, center } = capsuleOptions;
const diameter = 2 * radius;
const bevel = radius;
const width = diameter;
const boxHeight = height;
const geometry = new RoundedBoxGeometry(width, boxHeight + diameter, width, divisions, bevel);
geometry.translate(center.x, center.y, center.z);
return geometry;
}