UNPKG

three-stdlib

Version:

stand-alone library of threejs examples

24 lines (23 loc) 719 B
import { LatheGeometry, Path } from "three"; class CapsuleGeometry extends LatheGeometry { constructor(radius = 1, length = 1, capSegments = 4, radialSegments = 8) { const path = new Path(); path.absarc(0, -length / 2, radius, Math.PI * 1.5, 0); path.absarc(0, length / 2, radius, 0, Math.PI * 0.5); super(path.getPoints(capSegments), radialSegments); this.type = "CapsuleGeometry"; this.parameters = { radius, height: length, capSegments, radialSegments }; } static fromJSON(data) { return new CapsuleGeometry(data.radius, data.length, data.capSegments, data.radialSegments); } } export { CapsuleGeometry }; //# sourceMappingURL=CapsuleGeometry.js.map