npm.io
3.0.0 • Published 20h ago

primitive-geometry

Licence
MIT
Version
3.0.0
Deps
0
Size
790 kB
Vulns
0
Weekly
0
Stars
105

primitive-geometry

npm version stability-stable npm minzipped size dependencies types Conventional Commits styled with prettier linted with eslint license

Geometries for 3D rendering: planes, grids, solids, polyhedra and outline paths, with normals, UVs and cell indices (faces). Perfect if you want to supercharge your dependency folder... with 20KB of geometries.

paypal coinbase twitter

primitive-geometry screenshot

Installation

npm install primitive-geometry

Features

  • 72 geometries: planes and grids, quadrilaterals and arcs, solids of revolution, prisms, platonic and stellated polyhedra, geodesic spheres - plus 21 outline paths.
  • Common API: options object in, simplicial complex out. Parameters are named the same everywhere (sx/sy/sz, nx/ny/nz, radius, segments, theta/phi).
  • TypedArray out: Float32Array for positions, normals and uvs, cells narrowed to Uint8Array|Uint16Array|Uint32Array by vertex count (or pinned with setTypedArrayType).
  • Welded, crack-free meshes: vertices shared between patches are bit-identical, not merely close. Every geometry is checked for cracks, non-manifold edges, degenerate cells, winding and uv continuity across 101 configurations.
  • Partial shapes: theta/phi sweeps with optional caps, hollow variants, and vDistribution to choose how rows spread along a revolution's meridian.
  • 17 UV mappings, swappable per compatible geometry: see the comparison images and the demo.
  • Zero dependency, tree-shakeable: ~1.7KB min+gzip for a single geometry, ~21KB for all of them.

Usage

See the example and its source.

import * as Primitives from "primitive-geometry";

const { mappings, utils } = Primitives;

const geometry = Primitives.quad({ scale: 0.5 });
console.log(geometry);
// {
//   positions: Float32Array [x, y, z, x, y, z,  ...],
//   normals: Float32Array [x, y, z, x, y, z, ...]
//   uvs: Float32Array [u, v, u, v, ...],
//   cells: Uint8/16/32/Array [a, b, c, a, b, c, ...],
// }

// Every geometry below, with its options set to their defaults. Grids
// return an n-gon complex: positions and cells only, no normals or uvs. Most
// plane geometries also have a `*Path` outline variant, and the polyhedra a
// `*Faces` n-gon seed variant: see the API below.

// Plane
const quadGrid = Primitives.quadGrid({
  sx: 1,
  sy: 1,
  nx: 10,
  ny: 10,
});
const triangularGrid = Primitives.triangularGrid({
  sx: 1,
  nx: 10,
  ny: 10,
  inscribed: true,
});
const hexagonalGrid = Primitives.hexagonalGrid({
  sx: 1,
  nx: 10,
  ny: 10,
  inscribed: true,
});

const triangle = Primitives.triangle({
  sx: 1,
  sy: 1,
  apexOffset: 0,
  radius: 0.5,
  edgeSegments: 1,
  innerSegments: 16,
  innerRadius: 0,
  theta: Math.PI * 2,
  thetaOffset: 0,
  mergeCentroid: true,
  mapping: mappings.rectangular,
});
const rightTriangle = Primitives.rightTriangle({
  sx: 1,
  sy: 1,
  radius: 0.5,
  edgeSegments: 1,
  innerSegments: 16,
  innerRadius: 0,
  theta: Math.PI * 2,
  thetaOffset: 0,
  mergeCentroid: true,
  mapping: mappings.rectangular,
});

const quad = Primitives.quad({
  scale: 0.5,
});
const plane = Primitives.plane({
  sx: 1,
  sy: 1,
  nx: 1,
  ny: 1,
  direction: "z",
});
const roundedRectangle = Primitives.roundedRectangle({
  sx: 1,
  sy: 1,
  radius: 0.25,
  roundSegments: 8,
  edgeSegments: 1,
  nx: 1,
  ny: 1,
  roundedCorners: ["top-left", "top-right", "bottom-right", "bottom-left"],
});
const stadium = Primitives.stadium({
  sx: 1,
  sy: 0.5,
  nx: 1,
  ny: 1,
  roundSegments: 8,
  edgeSegments: 1,
});

const kite = Primitives.kite({
  sx: 1,
  sy: 1,
  ratio: 0.5,
  radius: 0.5,
  edgeSegments: 1,
  innerSegments: 16,
  innerRadius: 0,
  theta: Math.PI * 2,
  thetaOffset: Math.PI / 2,
  mergeCentroid: true,
  mapping: mappings.concentric,
});
const rhombus = Primitives.rhombus({
  sx: 1,
  sy: 1,
  radius: 0.5,
  edgeSegments: 1,
  innerSegments: 16,
  innerRadius: 0,
  theta: Math.PI * 2,
  thetaOffset: Math.PI / 2,
  mergeCentroid: true,
  mapping: mappings.concentric,
});
const lozenge = Primitives.lozenge({
  sx: 0.5,
  sy: 1,
  radius: 0.5,
  edgeSegments: 1,
  innerSegments: 16,
  innerRadius: 0,
  theta: Math.PI * 2,
  thetaOffset: Math.PI / 2,
  mergeCentroid: true,
  mapping: mappings.concentric,
});
const trapezoid = Primitives.trapezoid({
  sx: 1,
  sy: 1,
  topRatio: 0.5,
  topOffset: 0,
  radius: 0.5,
  edgeSegments: 1,
  innerSegments: 16,
  innerRadius: 0,
  theta: Math.PI * 2,
  thetaOffset: 0,
  mergeCentroid: true,
  mapping: mappings.rectangular,
});
const parallelogram = Primitives.parallelogram({
  sx: 0.5,
  sy: 1,
  shear: 0.3,
  radius: 0.5,
  edgeSegments: 1,
  innerSegments: 16,
  innerRadius: 0,
  theta: Math.PI * 2,
  thetaOffset: 0,
  mergeCentroid: true,
  mapping: mappings.rectangular,
});

const arbelos = Primitives.arbelos({
  radius: 0.5,
  innerRadius: 0.125,
  segments: 32,
  innerSegments: 16,
  mapping: mappings.rectangular,
});
const lens = Primitives.lens({
  radius: 0.5,
  radius2: 0.5,
  distance: 0.5,
  segments: 32,
  innerSegments: 16,
  mapping: mappings.rectangular,
});
const lune = Primitives.lune({
  radius: 0.5,
  innerRadius: 0.5,
  distance: 0.25,
  segments: 32,
  innerSegments: 16,
  mapping: mappings.rectangular,
});
const salinon = Primitives.salinon({
  radius: 0.5,
  innerRadius: 0.125,
  segments: 32,
  innerSegments: 16,
  mapping: mappings.rectangular,
});
const triquetra = Primitives.triquetra({
  radius: 0.5,
  segments: 32,
  innerSegments: 16,
  mapping: mappings.rectangular,
});
const yinYang = Primitives.yinYang({
  radius: 0.5,
  dotRadius: 0.5 / 6,
  part: "yin-yang",
  segments: 32,
  holeSegments: 16,
  innerSegments: 16,
  mapping: mappings.rectangular,
});

const ellipse = Primitives.ellipse({
  sx: 1,
  sy: 0.5,
  radius: 0.5,
  segments: 32,
  innerSegments: 16,
  theta: Math.PI * 2,
  thetaOffset: 0,
  innerRadius: 0,
  mergeCentroid: true,
  mapping: mappings.elliptical,
});
const disc = Primitives.disc({
  radius: 0.5,
  segments: 32,
  innerSegments: 16,
  theta: Math.PI * 2,
  thetaOffset: 0,
  mergeCentroid: true,
  mapping: mappings.concentric,
});
const superellipse = Primitives.superellipse({
  sx: 1,
  sy: 0.5,
  radius: 0.5,
  segments: 32,
  innerSegments: 16,
  theta: Math.PI * 2,
  thetaOffset: 0,
  mergeCentroid: true,
  mapping: mappings.lamé,
  m: 2,
  n: 2,
});
const squircle = Primitives.squircle({
  sx: 1,
  sy: 1,
  radius: 0.5,
  segments: 128,
  innerSegments: 16,
  theta: Math.PI * 2,
  thetaOffset: 0,
  mergeCentroid: true,
  mapping: mappings.fgSquircular,
  squareness: 0.95,
});
const astroid = Primitives.astroid({
  radius: 0.5,
  segments: 32,
  innerSegments: 16,
  theta: Math.PI * 2,
  thetaOffset: 0,
  mergeCentroid: true,
  mapping: mappings.lamé,
});
const annulus = Primitives.annulus({
  sx: 1,
  sy: 1,
  radius: 0.5,
  segments: 32,
  innerSegments: 16,
  theta: Math.PI * 2,
  thetaOffset: 0,
  innerRadius: 0.25,
  mapping: mappings.concentric,
});

const polygon = Primitives.polygon({
  sides: 6,
  sx: 1,
  sy: 1,
  radius: 0.5,
  edgeSegments: 1,
  innerSegments: 16,
  innerRadius: 0,
  theta: Math.PI * 2,
  thetaOffset: 0,
  mergeCentroid: true,
  mapping: mappings.concentric,
});
const reuleaux = Primitives.reuleaux({
  radius: 0.5,
  segments: 32,
  innerSegments: 16,
  theta: Math.PI * 2,
  thetaOffset: 0,
  mergeCentroid: true,
  mapping: mappings.concentric,
  n: 3,
});
const star = Primitives.star({
  points: 5,
  density: 2,
  radius: 0.5,
  notchRadius: 0.5 * utils.computeStarRatio(5, 2),
  innerRadius: 0,
  circularHole: false,
  innerSegments: 16,
  theta: Math.PI * 2,
  thetaOffset: 0,
  mapping: mappings.concentric,
});
const cross = Primitives.cross({
  radius: 0.5,
  armWidth: 0.5 / 3,
  segments: 1,
  innerSegments: 16,
  innerRadius: 0,
  mergeCentroid: true,
  mapping: mappings.rectangular,
});

// Solid
const cube = Primitives.cube({
  sx: 1,
  sy: 1,
  sz: 1,
  nx: 1,
  ny: 1,
  nz: 1,
});
const hollowCube = Primitives.hollowCube({
  sx: 1,
  sy: 1,
  sz: 1,
  thickness: 0.2,
});
const roundedCube = Primitives.roundedCube({
  sx: 1,
  sy: 1,
  sz: 1,
  radius: 0.25,
  roundSegments: 8,
  edgeSegments: 1,
  nx: 1,
  ny: 1,
  nz: 1,
  roundDirection: "all",
});

const sphere = Primitives.sphere({
  radius: 0.5,
  nx: 32,
  ny: 16,
  theta: Math.PI,
  thetaOffset: 0,
  phi: Math.PI * 2,
  phiOffset: 0,
});
const hollowSphere = Primitives.hollowSphere({
  radius: 0.5,
  innerRadius: 0.25,
  nx: 32,
  ny: 16,
  capSegments: 1,
  theta: Math.PI / 2,
  thetaOffset: Math.PI / 4,
  phi: Math.PI * 2,
  phiOffset: 0,
});
const ellipsoid = Primitives.ellipsoid({
  radius: 1,
  nx: 32,
  ny: 16,
  rx: 0.5,
  ry: 0.25,
  rz: 0.25,
  theta: Math.PI,
  thetaOffset: 0,
  phi: Math.PI * 2,
  phiOffset: 0,
  vDistribution: utils.linear,
});
const superellipsoid = Primitives.superellipsoid({
  radius: 1,
  nx: 32,
  ny: 16,
  rx: 0.5,
  ry: 0.25,
  rz: 0.25,
  n1: 3,
  n2: 3,
  theta: Math.PI,
  thetaOffset: 0,
  phi: Math.PI * 2,
  phiOffset: 0,
  vDistribution: utils.linear,
});
const astroidalEllipsoid = Primitives.astroidalEllipsoid({
  radius: 1,
  nx: 32,
  ny: 16,
  rx: 0.5,
  ry: 0.25,
  rz: 0.25,
  theta: Math.PI,
  thetaOffset: 0,
  phi: Math.PI * 2,
  phiOffset: 0,
});
const superegg = Primitives.superegg({
  radius: 0.5,
  ry: (0.5 * 5) / 6,
  nx: 32,
  ny: 16,
  n: 2.5,
  theta: Math.PI,
  thetaOffset: 0,
  phi: Math.PI * 2,
  phiOffset: 0,
  vDistribution: utils.linear,
});

const cylinder = Primitives.cylinder({
  height: 1,
  radius: 0.25,
  nx: 16,
  ny: 1,
  radiusApex: 0.25,
  capSegments: 1,
  capApex: true,
  capBase: true,
  capBaseSegments: 1,
  phi: Math.PI * 2,
  phiOffset: 0,
  capMapping: mappings.rectangular,
  sx: 1,
  sz: 1,
  sxApex: 1,
  szApex: 1,
  vDistribution: utils.linear,
});
const hollowCylinder = Primitives.hollowCylinder({
  height: 1,
  radius: 0.5,
  innerRadius: 0.25,
  nx: 32,
  ny: 1,
  capSegments: 1,
  capApex: true,
  capBase: true,
  phi: Math.PI * 2,
  phiOffset: 0,
});
const roundedCylinder = Primitives.roundedCylinder({
  height: 1,
  radius: 0.25,
  roundRadius: 0.075,
  nx: 16,
  ny: 1,
  roundSegments: 8,
  capSegments: 1,
  phi: Math.PI * 2,
  phiOffset: 0,
  vDistribution: utils.linear,
});

const cone = Primitives.cone({
  height: 1,
  radius: 0.25,
  nx: 16,
  ny: 1,
  capSegments: 1,
  capBase: true,
  phi: Math.PI * 2,
  phiOffset: 0,
  capMapping: mappings.rectangular,
  sx: 1,
  sz: 1,
  vDistribution: utils.linear,
});
const bicone = Primitives.bicone({
  height: 1,
  radius: 0.5,
  nx: 16,
  ny: 1,
  phi: Math.PI * 2,
  phiOffset: 0,
  sx: 1,
  sz: 1,
});
const sphericon = Primitives.sphericon({
  radius: 0.5,
  nx: 16,
  ny: 1,
});
const doubleCone = Primitives.doubleCone({
  height: 1,
  radius: 0.5,
  nx: 16,
  ny: 1,
  capSegments: 1,
  capApex: true,
  capBase: true,
  capBaseSegments: 1,
  phi: Math.PI * 2,
  phiOffset: 0,
  capMapping: mappings.rectangular,
  sx: 1,
  sz: 1,
});
const capsule = Primitives.capsule({
  height: 0.5,
  radius: 0.25,
  nx: 16,
  ny: 1,
  roundSegments: 16,
  phi: Math.PI * 2,
  phiOffset: 0,
  vDistribution: utils.linear,
});

const torus = Primitives.torus({
  radius: 0.4,
  segments: 64,
  minorRadius: 0.1,
  minorSegments: 32,
  theta: Math.PI * 2,
  thetaOffset: 0,
  phi: Math.PI * 2,
  phiOffset: 0,
  capSegments: 1,
  capStart: true,
  capEnd: true,
  capStartSegments: 1,
  capEndSegments: 1,
  capMapping: mappings.rectangular,
  sx: 1,
  sy: 1,
  minorSx: 1,
  minorSy: 1,
});
const apple = Primitives.apple({
  radius: 0.5,
  height: 0.5,
  nx: 32,
  ny: 16,
  phi: Math.PI * 2,
  phiOffset: 0,
  vDistribution: utils.linear,
});
const lemon = Primitives.lemon({
  radius: 0.3,
  height: 1,
  nx: 32,
  ny: 16,
  phi: Math.PI * 2,
  phiOffset: 0,
  vDistribution: utils.linear,
});
const sphericalRing = Primitives.sphericalRing({
  radius: 0.5,
  innerRadius: 0.25,
  nx: 32,
  ny: 16,
  holeSegments: 1,
  phi: Math.PI * 2,
  phiOffset: 0,
  vDistribution: utils.linear,
});

const prism = Primitives.prism({
  radius: 0.25,
  height: 1,
  sides: 6,
  phiOffset: 0,
  capMapping: mappings.rectangular,
});
const antiprism = Primitives.antiprism({
  radius: 0.25,
  height: 1,
  sides: 6,
  phiOffset: 0,
  capMapping: mappings.rectangular,
});

const paraboloid = Primitives.paraboloid({
  height: 1,
  radius: 0.5,
  nx: 32,
  ny: 16,
  capSegments: 1,
  capBase: true,
  phi: Math.PI * 2,
  phiOffset: 0,
  capMapping: mappings.rectangular,
  vDistribution: utils.linear,
});
const hyperboloid = Primitives.hyperboloid({
  height: 1,
  radius: 0.25,
  radiusTop: 0.5,
  nx: 32,
  ny: 16,
  capSegments: 1,
  capApex: true,
  capBase: true,
  phi: Math.PI * 2,
  phiOffset: 0,
  capMapping: mappings.rectangular,
  vDistribution: utils.linear,
});
const barrel = Primitives.barrel({
  height: 1,
  radius: 0.5,
  endRadius: 0.35,
  nx: 32,
  ny: 16,
  capSegments: 1,
  capApex: true,
  capBase: true,
  phi: Math.PI * 2,
  phiOffset: 0,
  capMapping: mappings.rectangular,
  vDistribution: utils.linear,
});
const funnel = Primitives.funnel({
  height: 1,
  radius: 0.1,
  radiusTop: 0.5,
  nx: 32,
  ny: 16,
  capSegments: 1,
  capApex: true,
  capBase: true,
  phi: Math.PI * 2,
  phiOffset: 0,
  capMapping: mappings.rectangular,
  vDistribution: utils.linear,
});

const tetrahedron = Primitives.tetrahedron({
  radius: 0.5,
  subdivisions: 0,
  mapping: mappings.rectangular,
});
const hexahedron = Primitives.hexahedron({
  radius: 0.5,
  subdivisions: 0,
  mapping: mappings.rectangular,
});
const octahedron = Primitives.octahedron({
  radius: 0.5,
  subdivisions: 0,
  mapping: mappings.rectangular,
});
const dodecahedron = Primitives.dodecahedron({
  radius: 0.5,
  subdivisions: 0,
  mapping: mappings.rectangular,
});
const icosahedron = Primitives.icosahedron({
  radius: 0.5,
  subdivisions: 0,
  mapping: mappings.rectangular,
});

const greatDodecahedron = Primitives.greatDodecahedron({
  radius: 0.5,
  subdivisions: 0,
  mapping: mappings.rectangular,
});
const greatIcosahedron = Primitives.greatIcosahedron({
  radius: 0.5,
  subdivisions: 0,
  mapping: mappings.rectangular,
});
const smallStellatedDodecahedron = Primitives.smallStellatedDodecahedron({
  radius: 0.5,
  subdivisions: 0,
  mapping: mappings.rectangular,
});
const greatStellatedDodecahedron = Primitives.greatStellatedDodecahedron({
  radius: 0.5,
  subdivisions: 0,
  mapping: mappings.rectangular,
});

const tetrasphere = Primitives.tetrasphere({
  radius: 0.5,
  subdivisions: 2,
  projection: "gnomonic",
  mapping: mappings.spherical,
});
const hexasphere = Primitives.hexasphere({
  radius: 0.5,
  subdivisions: 2,
  projection: "gnomonic",
  mapping: mappings.spherical,
});
const octasphere = Primitives.octasphere({
  radius: 0.5,
  subdivisions: 2,
  projection: "gnomonic",
  mapping: mappings.spherical,
});
const dodecasphere = Primitives.dodecasphere({
  radius: 0.5,
  subdivisions: 2,
  projection: "gnomonic",
  mapping: mappings.spherical,
});
const icosphere = Primitives.icosphere({
  radius: 0.5,
  subdivisions: 2,
  projection: "gnomonic",
  mapping: mappings.spherical,
});

API

Modules

primitiveGeometry

Re-export all geometries, UV mappings functions and utils.

mappings utils

Typedefs

TypedArrayLike : Array.<number> | Uint8Array | Uint16Array | Uint32Array SimplicialComplex : object

Geometry definition.

SimplicialComplexPolygon : object

Geometry polygon definition: each cell is a closed n-gon face (implicitly wraps its last index back to its first - never repeat the first index at the end).

SimplicialComplexPath : object

Geometry path definition: each cell is an open polyline (no implicit closing edge between its last and first index); repeat the first index at the end of a cell to close that loop explicitly.

primitiveGeometry

Re-export all geometries, UV mappings functions and utils.

primitiveGeometry.cross([options]) ⇒ SimplicialComplex

Greek cross: a plus-sign shaped non-regular dodecagon - 4 equal arms extending from a square center, filled with a fan from the center.

Kind: static method of primitiveGeometry See: Wolfram MathWorld – Greek Cross

Param Type Default
[options] CrossOptions {}

primitiveGeometry.crossPath([options]) ⇒ SimplicialComplexPath

Outline dual of cross: the same 12-corner outline, walked directly instead of fanned from the center.

Kind: static method of primitiveGeometry

Param Type Default
[options] CrossPathOptions {}

primitiveGeometry.polygon([options]) ⇒ SimplicialComplex

A regular polygon: sides corners evenly spaced around a circle, connected by straight edges rather than ellipse's elliptical arc (rhombus is this shape's sides=4 case). sx/sy independently scale the two axes; equal values keep it regular, different values stretch it into an ellipse-inscribed polygon.

Kind: static method of primitiveGeometry

Param Type Default
[options] PolygonOptions {}

primitiveGeometry.polygonPath([options]) ⇒ SimplicialComplexPath

Outline dual of polygon: sides corners evenly spaced around a circle, connected by straight edges (rhombus is this shape's sides=4 case).

Kind: static method of primitiveGeometry Returns: SimplicialComplexPath - edgeSegments * sides positions and a single path cell of that many indices (+ 1, repeating index 0, when closed)

Param Type Default
[options] PolygonPathOptions {}

primitiveGeometry.reuleaux([options]) ⇒ SimplicialComplex

A Reuleaux polygon: a constant-width curve built from n circular arcs, each centered on the opposite vertex.

Kind: static method of primitiveGeometry See: Parametric equations for regular and Reuleaux polygons

Param Type Default
[options] ReuleauxOptions {}

primitiveGeometry.reuleauxPath([options]) ⇒ SimplicialComplexPath

Outline dual of reuleaux: same parametric boundary, sampled directly with no radial fill.

Kind: static method of primitiveGeometry

Param Type Default
[options] ReuleauxPathOptions {}

primitiveGeometry.star([options]) ⇒ SimplicialComplex

Regular {points/density} star polygon: points outer tips alternating with points inner notches. notchRadius defaults to the tips' own {points/density} ratio, so e.g. the default star() traces a regular pentagram.

Kind: static method of primitiveGeometry See: Wolfram MathWorld – Star Polygon

Param Type Default
[options] StarOptions {}

primitiveGeometry.starPath([options]) ⇒ SimplicialComplexPath

Outline dual of star: points outer tips alternating with points inner notches, connected by straight edges.

Kind: static method of primitiveGeometry Returns: SimplicialComplexPath - points * 2 positions and a single path cell of that many indices (+ 1, repeating index 0, when closed)

Param Type Default
[options] StarPathOptions {}

primitiveGeometry.arbelos([options]) ⇒ SimplicialComplex

Arbelos ("shoemaker's knife"): the region inside a big semicircle and outside 2 smaller ones sharing its baseline, tangent where their diameters meet. Area: pi * innerRadius * (radius - innerRadius).

Kind: static method of primitiveGeometry See: Wolfram MathWorld – Arbelos

Param Type Default
[options] ArbelosOptions {}

primitiveGeometry.lens([options]) ⇒ SimplicialComplex

Lens: the convex region where two circles overlap, centered on the x axis and offset symmetrically by distance. Defaults to a Vesica Piscis.

Kind: static method of primitiveGeometry See

Param Type Default
[options] LensOptions {}

primitiveGeometry.lune([options]) ⇒ SimplicialComplex

Lune: a crescent, the region inside the big circle and outside the offset small one.

Kind: static method of primitiveGeometry See: Wolfram MathWorld – Lune

Param Type Default
[options] LuneOptions {}

primitiveGeometry.salinon([options]) ⇒ SimplicialComplex

Archimedes' salinon: a "salt cellar" bounded by four semicircles - one full-width on the bottom, a smaller one opposite it on top, and two "ear" semicircles filling the remaining top thirds. Area: pi/4 * (radius + innerRadius) ** 2 (Archimedes' theorem).

Kind: static method of primitiveGeometry See: Wolfram MathWorld – Salinon

Param Type Default
[options] SalinonOptions {}

primitiveGeometry.triquetra([options]) ⇒ SimplicialComplex

Triquetra: three mutually intersecting vesica piscis lenses, centered at the vertices of an equilateral triangle of side radius.

Kind: static method of primitiveGeometry See: Wolfram MathWorld – Triquetra

Param Type Default
[options] TriquetraOptions {}

primitiveGeometry.yinYang([options]) ⇒ SimplicialComplex

Yin-Yang (taijitu): a circle divided by an S-shaped seam of two opposing semicircles, each side holed by a dot at the other's bulge.

Kind: static method of primitiveGeometry See: Wolfram MathWorld – Yin-Yang

Param Type Default
[options] YinYangOptions {}

primitiveGeometry.annulus([options]) ⇒ SimplicialComplex

An annulus (ring): the region between two concentric circles.

Kind: static method of primitiveGeometry

Param Type Default
[options] AnnulusOptions {}

primitiveGeometry.annulusPath([options]) ⇒ SimplicialComplexPath

Outline dual of annulus: unlike every other path in this module, an annulus's boundary is 2 disjoint loops, not one - 2 path cells (outer loop first, inner second).

Kind: static method of primitiveGeometry

Param Type Default
[options] AnnulusPathOptions {}

primitiveGeometry.astroid([options]) ⇒ SimplicialComplex

Hypocycloid with 4 cusps: a superellipse special case (m = n = 2/3).

Kind: static method of primitiveGeometry See: Wolfram MathWorld – Astroid

Param Type Default
[options] AstroidOptions {}

primitiveGeometry.astroidPath([options]) ⇒ SimplicialComplexPath

Outline dual of astroid: superellipsePath with m = n = 2 / 3.

Kind: static method of primitiveGeometry

Param Type Default
[options] AstroidPathOptions {}

primitiveGeometry.disc([options]) ⇒ SimplicialComplex

A disc: ellipse with sx = sy = 1.

Kind: static method of primitiveGeometry

Param Type Default
[options] DiscOptions {}

primitiveGeometry.circlePath([options]) ⇒ SimplicialComplexPath

Outline dual of disc: ellipsePath with sx = sy = 1.

Kind: static method of primitiveGeometry Returns: SimplicialComplexPath - segments positions and a single path cell of segments indices (segments + 1, repeating index 0, when closed)

Param Type Default
[options] CirclePathOptions {}

primitiveGeometry.ellipse([options]) ⇒ SimplicialComplex

An ellipse (or circle when sx = sy).

Kind: static method of primitiveGeometry

Param Type Default
[options] EllipseOptions {}

primitiveGeometry.ellipsePath([options]) ⇒ SimplicialComplexPath

Outline dual of ellipse: sx/sy independently scale the two axes, same as circlePath with sx = sy = 1.

Kind: static method of primitiveGeometry Returns: SimplicialComplexPath - segments positions and a single path cell of segments indices (segments + 1, repeating index 0, when closed)

Param Type Default
[options] EllipsePathOptions {}

primitiveGeometry.squircle([options]) ⇒ SimplicialComplex

Fernández-Guasti squircle

Kind: static method of primitiveGeometry See: Squircular Calculations – Chamberlain Fong

Param Type Default
[options] SquircleOptions {}

primitiveGeometry.squirclePath([options]) ⇒ SimplicialComplexPath

Outline dual of squircle: the same Fernández-Guasti curve, sampled directly with no radial fill.

Kind: static method of primitiveGeometry

Param Type Default
[options] SquirclePathOptions {}

primitiveGeometry.superellipse([options]) ⇒ SimplicialComplex

Lamé curve See elliptical-mapping example for a few special cases

Kind: static method of primitiveGeometry See

Param Type Default
[options] SuperellipseOptions {}

primitiveGeometry.superellipsePath([options]) ⇒ SimplicialComplexPath

Outline dual of superellipse: the same Lamé curve, sampled directly with no radial fill.

Kind: static method of primitiveGeometry

Param Type Default
[options] SuperellipsePathOptions {}

primitiveGeometry.hexagonalGrid([options]) ⇒ SimplicialComplexPolygon

Hexagonal grid tiling regular hexagons

Kind: static method of primitiveGeometry

Param Type Default
[options] HexagonalGridOptions {}

primitiveGeometry.quadGrid([options]) ⇒ SimplicialComplexPolygon

Regular grid

Kind: static method of primitiveGeometry

Param Type Default
[options] QuadGridOptions {}

primitiveGeometry.triangularGrid([options]) ⇒ SimplicialComplexPolygon

Isometric grid tiling equilateral triangles

Kind: static method of primitiveGeometry

Param Type Default
[options] TriangularGridOptions {}

primitiveGeometry.kite([options]) ⇒ SimplicialComplex

A kite: a rhombus with its bottom vertex pulled toward the center (by ratio) while the top, left and right vertices stay put.

Kind: static method of primitiveGeometry

Param Type Default
[options] KiteOptions {}

primitiveGeometry.kitePath([options]) ⇒ SimplicialComplexPath

Outline dual of kite: same shape, ratio pulling the bottom vertex toward the center.

Kind: static method of primitiveGeometry

Param Type Default
[options] KitePathOptions {}

primitiveGeometry.lozenge([options]) ⇒ SimplicialComplex

A rhombus elongated along its vertical diagonal by default (sy = sx * 2), the classic narrow diamond look.

Kind: static method of primitiveGeometry

Param Type Default
[options] LozengeOptions {}

primitiveGeometry.lozengePath([options]) ⇒ SimplicialComplexPath

Outline dual of lozenge: rhombusPath elongated along its vertical diagonal by default (sy = sx * 2).

Kind: static method of primitiveGeometry

Param Type Default
[options] LozengePathOptions {}

primitiveGeometry.parallelogram([options]) ⇒ SimplicialComplex

A parallelogram: trapezoid with topRatio fixed to 1 (top and bottom edges the same width) and shifted sideways by shear.

Kind: static method of primitiveGeometry

Param Type Default
[options] ParallelogramOptions {}

primitiveGeometry.parallelogramPath([options]) ⇒ SimplicialComplexPath

Outline dual of parallelogram: trapezoidPath with topRatio fixed to 1, shifted sideways by shear.

Kind: static method of primitiveGeometry

Param Type Default
[options] ParallelogramPathOptions {}

primitiveGeometry.plane([options]) ⇒ SimplicialComplex

A flat rectangular grid, facing direction.

Kind: static method of primitiveGeometry

Param Type Default
[options] PlaneOptions {}

primitiveGeometry.rectanglePath([options]) ⇒ SimplicialComplexPath

Outline dual of plane: just its z-facing boundary loop, walked directly (bottom-left → bottom-right → top-right → top-left) rather than extracted from the full grid.

Kind: static method of primitiveGeometry

Param Type Default
[options] RectanglePathOptions {}

primitiveGeometry.quad([options]) ⇒ SimplicialComplex

A square, filled with 2 triangles.

Kind: static method of primitiveGeometry

Param Type Default
[options] QuadOptions {}

primitiveGeometry.squarePath([options]) ⇒ SimplicialComplexPath

Outline dual of quad: rectanglePath with equal sx/sy, same as quad itself is built from it.

Kind: static method of primitiveGeometry

Param Type Default
[options] SquarePathOptions {}

primitiveGeometry.rhombus([options]) ⇒ SimplicialComplex

A rhombus: a diamond with vertices at top/right/bottom/left, sx and sy independently scaling the horizontal and vertical diagonals. Equal sx/sy gives a square rotated 45°.

Kind: static method of primitiveGeometry

Param Type Default
[options] RhombusOptions {}

primitiveGeometry.rhombusPath([options]) ⇒ SimplicialComplexPath

Outline dual of rhombus: polygonPath with sides fixed to 4.

Kind: static method of primitiveGeometry

Param Type Default
[options] RhombusPathOptions {}

primitiveGeometry.roundedRectangle([options]) ⇒ SimplicialComplex

A rectangle with rounded corners.

Kind: static method of primitiveGeometry

Param Type Default
[options] RoundedRectangleOptions {}

primitiveGeometry.roundedRectanglePath([options]) ⇒ SimplicialComplexPath

Outline dual of roundedRectangle: same radius/segment/roundedCorners conventions, walked directly (bottom-left → bottom-right → top-right → top-left). A rounded corner contributes roundSegments samples along its quarter-circle arc; a sharp one contributes its single corner point. Produces identical output to rectanglePath when radius is 0.

Kind: static method of primitiveGeometry

Param Type Default
[options] RoundedRectanglePathOptions {}

primitiveGeometry.stadium([options]) ⇒ SimplicialComplex

A stadium (discorectangle): roundedRectangle with radius fixed to half the shorter side.

Kind: static method of primitiveGeometry

Param Type Default
[options] StadiumOptions {}

primitiveGeometry.stadiumPath([options]) ⇒ SimplicialComplexPath

Outline dual of stadium: roundedRectanglePath with radius fixed to half the shorter side, collapsing that axis's straight section to 0 (two semicircular caps joined by straight edges).

Kind: static method of primitiveGeometry

Param Type Default
[options] StadiumPathOptions {}

primitiveGeometry.trapezoid([options]) ⇒ SimplicialComplex

A trapezoid: a quad with horizontal top/bottom edges, the top narrowed to topRatio of the bottom's width and optionally shifted by topOffset. The default thetaOffset=0 starts at the bottom-left corner and sweeps CCW through bottom-right, top-right, top-left.

Kind: static method of primitiveGeometry See: Wolfram MathWorld – Trapezoid

Param Type Default
[options] TrapezoidOptions {}

primitiveGeometry.trapezoidPath([options]) ⇒ SimplicialComplexPath

Outline dual of trapezoid: the same 4 corners, walked directly instead of fanned.

Kind: static method of primitiveGeometry

Param Type Default
[options] TrapezoidPathOptions {}

primitiveGeometry.rightTriangle([options]) ⇒ SimplicialComplex

A right triangle: triangle with its apex pulled directly above the bottom-left corner (apexOffset = -sx), landing the right angle there.

Kind: static method of primitiveGeometry

Param Type Default
[options] RightTriangleOptions {}

primitiveGeometry.rightTrianglePath([options]) ⇒ SimplicialComplexPath

Outline dual of rightTriangle: trianglePath with apexOffset fixed to -sx.

Kind: static method of primitiveGeometry

Param Type Default
[options] RightTrianglePathOptions {}

primitiveGeometry.triangle([options]) ⇒ SimplicialComplex

A triangle: a horizontal base with the apex placed anywhere above it via apexOffset. thetaOffset=0 starts at the bottom-left corner and sweeps CCW through bottom-right, apex.

Kind: static method of primitiveGeometry See: Wolfram MathWorld – Triangle

Param Type Default
[options] TriangleOptions {}

primitiveGeometry.trianglePath([options]) ⇒ SimplicialComplexPath

Outline dual of triangle: the same 3 corners, walked directly instead of fanned.

Kind: static method of primitiveGeometry

Param Type Default
[options] TrianglePathOptions {}

primitiveGeometry.cubeFaces([options]) ⇒ SimplicialComplexPolygon

Cuboid faces: 8 positions and 6 quad faces (indices into positions). Cells order: +x, -x, +y, -y, +z, -z.

Kind: static method of primitiveGeometry

Param Type Default
[options] CubeFacesOptions {}

primitiveGeometry.box([options]) ⇒ SimplicialComplexPolygon

A cuboid, as raw quad faces rather than a triangulated mesh - see cubeFaces.

Kind: static method of primitiveGeometry

Param Type Default
[options] BoxOptions {}

primitiveGeometry.cube([options]) ⇒ SimplicialComplex

A cuboid (rectangular box).

Kind: static method of primitiveGeometry

Param Type Default
[options] CubeOptions {}

primitiveGeometry.hollowCube([options]) ⇒ SimplicialComplex

A cube with a square hole through the center of each face, like a single cell of a Menger sponge: the 8 corners stay solid (t x t x t blocks) and the 12 edges become beams of the same cross-section running between them.

Kind: static method of primitiveGeometry

Param Type Default
[options] HollowCubeOptions {}

primitiveGeometry.roundedCube([options]) ⇒ SimplicialComplex

A cuboid with rounded edges and corners.

Kind: static method of primitiveGeometry

Param Type Default
[options] RoundedCubeOptions {}

primitiveGeometry.antiprism([options]) ⇒ SimplicialComplex

Antiprism: like prism, but the top sides-gon is rotated by half a sector relative to the bottom one, so the two rings connect through a zigzag band of 2 * sides flat triangles (each with its own hard-edged normal) instead of prism's sides flat rectangles. The 2 end caps are otherwise identical to prism's own, just with the top one rotated to match its own ring.

Kind: static method of primitiveGeometry

Param Type Default
[options] AntiprismOptions {}

primitiveGeometry.prism([options]) ⇒ SimplicialComplex

Right prism: a regular sides-gon extruded into sides flat rectangular side faces, each with its own hard-edged normal - unlike cylinder's smooth per-vertex normal, which just makes a large-nx cylinder look faceted rather than actually being one.

Kind: static method of primitiveGeometry

Param Type Default
[options] PrismOptions {}

primitiveGeometry.apple([options]) ⇒ SimplicialComplex

MathWorld's Apple Surface: "more than half of a circular arc rotated about an axis passing through the [arc's] endpoints" - the outer lobe of a spindle torus. Poles are true cusps (dimples), not smooth tangent points like a sphere's - each pole's normal varies per column, same as cone's apex.

Kind: static method of primitiveGeometry See: Wolfram MathWorld – Apple Surface

Param Type Default
[options] AppleOptions {}

primitiveGeometry.astroidalEllipsoid([options]) ⇒ SimplicialComplex

A superellipsoid special case (n1 = n2 = 2/3): the surface

|x/rx|^(2/3) + |y/ry|^(2/3) + |z/rz|^(2/3) = 1, pinched to 6 cusps along

The axes.

Kind: static method of primitiveGeometry See: Wolfram MathWorld – Astroidal Ellipsoid

Param Type Default
[options] AstroidalEllipsoidOptions {}

primitiveGeometry.barrel([options]) ⇒ SimplicialComplex

Barrel/cask: a cylinder that bulges outward at the equator and tapers back to a narrower flat rim at both ends. Unlike superegg (which also bulges but tapers all the way to a point at each pole), both ends here stay flat, open rings, cappable like cylinder's.

Kind: static method of primitiveGeometry

Param Type Default
[options] BarrelOptions {}

primitiveGeometry.bicone([options]) ⇒ SimplicialComplex

Two right circular cones joined base-to-base at the equator (a bipyramid of revolution/spinning-top shape) - both ends come to a point, so unlike cylinder/doubleCone there are no cap options.

Kind: static method of primitiveGeometry

Param Type Default
[options] BiconeOptions {}

primitiveGeometry.capsule([options]) ⇒ SimplicialComplex

A cylindrical body capped with two hemispheres (a "pill" shape).

Kind: static method of primitiveGeometry

Param Type Default
[options] CapsuleOptions {}

primitiveGeometry.cone([options]) ⇒ SimplicialComplex

Right circular cone by default. Other shapes fall out of the same parameters: an open cone/funnel (capBase false) and an elliptical cone (sx != sz). There's no apex-side ellipse - the apex is always a single point, so any apex scale would be a no-op.

Kind: static method of primitiveGeometry

Param Type Default
[options] ConeOptions {}

primitiveGeometry.cylinder([options]) ⇒ SimplicialComplex

Right circular cylinder by default. Other shapes fall out of the same parameters: a tube (capBase/capApex false, any radii), a frustum/cone (radiusApex != radius, 0 for a true cone apex), and an elliptical cylinder or frustum (sx != sz, optionally different per end via sxApex/szApex).

Kind: static method of primitiveGeometry

Param Type Default
[options] CylinderOptions {}

primitiveGeometry.doubleCone([options]) ⇒ SimplicialComplex

Two right circular cones joined apex-to-apex at the waist (an hourglass of revolution) - the wide top/bottom ends are flat, so unlike bicone it takes the same capBase/capApex/capSegments/capMapping options as cylinder.

Kind: static method of primitiveGeometry

Param Type Default
[options] DoubleConeOptions {}

primitiveGeometry.ellipsoid([options]) ⇒ SimplicialComplex

Default to an oblate spheroid.

Kind: static method of primitiveGeometry

Param Type Default
[options] EllipsoidOptions {}

primitiveGeometry.funnel([options]) ⇒ SimplicialComplex

Revolution of y = a·ln(r) (equivalently r = radius·e^(k·(y+height/2)), an exponential - not linear (cone) or hyperbolic (hyperboloid) - radius law) between a narrow spout and a wide mouth. Both ends stay flat, open rings, cappable exactly like hyperboloid's.

Kind: static method of primitiveGeometry See: Wolfram MathWorld – Funnel

Param Type Default
[options] FunnelOptions {}

primitiveGeometry.hollowCylinder([options]) ⇒ SimplicialComplex

A cylinder with a concentric cylindrical bore through it - a washer/pipe extruded to a given height. Doesn't close the phi < TAU wedge cut (no wall between the outer/inner walls or the 2 caps there) - same limitation as a plain cylinder({ phi: <TAU }).

Kind: static method of primitiveGeometry

Param Type Default
[options] HollowCylinderOptions {}

primitiveGeometry.hollowSphere([options]) ⇒ SimplicialComplex

A sphere with a smaller, concentric sphere hollowed out of it: a shell of uniform wall thickness. Defaults to a quarter band (theta/thetaOffset) rather than a full sphere, since a closed hollow sphere looks identical to a plain sphere from outside - the partial default exposes the cavity and cut caps immediately.

Kind: static method of primitiveGeometry

Param Type Default
[options] HollowSphereOptions {}

primitiveGeometry.hyperboloid([options]) ⇒ SimplicialComplex

Hyperboloid of one sheet (revolution of x² + z² = radius² + k·y², a pinched-waist, flared-both-ends shape - cooling towers, gear/skew-roller profiles). Both ends are flat rings, not points, cappable like cylinder's frustum.

Kind: static method of primitiveGeometry See: Wolfram MathWorld – One-Sheeted Hyperboloid

Param Type Default
[options] HyperboloidOptions {}

primitiveGeometry.lemon([options]) ⇒ SimplicialComplex

Lemon (geometry): "a circular arc of angle less than half of a full circle" rotated about the chord through its own endpoints - apple's exact complementary half. Unlike apple, the meridian is plain y-monotonic: no dimple, just a smooth convex taper to a point (still a cusp, not a tangent point, at each pole).

Kind: static method of primitiveGeometry See: Wikipedia – Lemon (geometry)

Param Type Default
[options] LemonOptions {}

primitiveGeometry.paraboloid([options]) ⇒ SimplicialComplex

Circular paraboloid (revolution of x² + z² = k·(apexY - y), the classic satellite-dish/reflector shape) - apex up, rim down, same orientation as cone, and like cone only the rim end takes a cap option. Unlike a cone's apex, the surface here is smooth at the apex (no crease), with a single well-defined normal there.

Kind: static method of primitiveGeometry See: Wolfram MathWorld – Paraboloid

Param Type Default
[options] ParaboloidOptions {}

primitiveGeometry.roundedCylinder([options]) ⇒ SimplicialComplex

A cylinder with its top/bottom rim edges filleted instead of sharp - a flat cap blended into the straight side by a quarter-circle fillet, both ends symmetric. roundRadius = 0 gives a plain flat-capped cylinder; roundRadius = radius = height / 2 pinches the flat cap away entirely, becoming capsule's hemisphere.

Kind: static method of primitiveGeometry

Param Type Default
[options] RoundedCylinderOptions {}

primitiveGeometry.sphere([options]) ⇒ SimplicialComplex

A sphere: ellipsoid with rx = ry = 1.

Kind: static method of primitiveGeometry

Param Type Default
[options] SphereOptions {}

primitiveGeometry.sphericalRing([options]) ⇒ SimplicialComplex

A sphere with a cylindrical hole drilled through its center - MathWorld's Spherical Ring, aka a napkin ring. Unlike what "ring" might suggest, there's no flat annulus at either end: at the rim (height sqrt(radius² - innerRadius²)), the sphere's and bore's surfaces meet directly, so the meridian cross-section is a single closed loop - topologically a torus with a lens-shaped minor curve instead of a circular one.

Kind: static method of primitiveGeometry See: Wolfram MathWorld – Spherical Ring

Param Type Default
[options] SphericalRingOptions {}

primitiveGeometry.sphericon([options]) ⇒ SimplicialComplex

A right-circular bicone with a 90° apex angle, split along the plane through both apexes and reattached with one half rotated 90° - the classic 4-quarter-cone rolling solid. No flat faces: a single continuous developable surface that rolls by wobbling in a straight line.

Kind: static method of primitiveGeometry See: Wolfram MathWorld – Sphericon

Param Type Default
[options] SphericonOptions {}

primitiveGeometry.superegg([options]) ⇒ SimplicialComplex

Piet Hein's superegg: a superellipsoid special case (n2 = 2, rx = rz) with a circular cross-section at every height, ie. an actual surface of revolution - unlike the general superellipsoid, whose cross-sections are themselves superelliptical.

Kind: static method of primitiveGeometry See

Param Type Default
[options] SupereggOptions {}

primitiveGeometry.superellipsoid([options]) ⇒ SimplicialComplex

Superquadric ellipsoid (Barr 1981): generalizes ellipsoid by raising its meridian (n1) and cross-section (n2) sin/cos terms to signed powers - n = 2 is a plain ellipsoid, n < 2 rounds toward a box, n > 2 (the default, n1 = n2 = 3) pinches toward a star/octahedron. See superegg for the n2 = 2 (circular cross-section) special case.

Kind: static method of primitiveGeometry See

Param Type Default
[options] SuperellipsoidOptions {}

primitiveGeometry.torus([options]) ⇒ SimplicialComplex

Ring torus by default. Other shapes fall out of the same parameters: a partial/open torus (phi < TAU, optionally capped via capStart/capEnd), an elliptical torus (sx != sy, an oval/racetrack footprint), and a tube with an elliptical cross-section (minorSx != minorSy, like a flattened or spindle-shaped bagel).

Kind: static method of primitiveGeometry

Param Type Default
[options] TorusOptions {}

primitiveGeometry.dodecasphere([options]) ⇒ SimplicialComplex

A geodesic sphere built by radially projecting and welding a subdivided dodecahedron

Kind: static method of primitiveGeometry

Param Type Default
[options] DodecasphereOptions {}

primitiveGeometry.hexasphere([options]) ⇒ SimplicialComplex

A geodesic sphere built by radially projecting and welding a subdivided hexahedron (cube) - an alternative to icosphere's topology, with cubemap-friendly UVs.

Kind: static method of primitiveGeometry

Param Type Default
[options] HexasphereOptions {}

primitiveGeometry.icosphere([options]) ⇒ SimplicialComplex

A geodesic sphere built by radially projecting and welding a subdivided icosahedron.

Kind: static method of primitiveGeometry

Param Type Default
[options] IcosphereOptions {}

primitiveGeometry.octasphere([options]) ⇒ SimplicialComplex

A geodesic sphere built by radially projecting and welding a subdivided octahedron.

Kind: static method of primitiveGeometry

Param Type Default
[options] OctasphereOptions {}

primitiveGeometry.tetrasphere([options]) ⇒ SimplicialComplex

A geodesic sphere built by radially projecting and welding a subdivided tetrahedron.

Kind: static method of primitiveGeometry

Param Type Default
[options] TetrasphereOptions {}

primitiveGeometry.dodecahedronFaces([options]) ⇒ SimplicialComplexPolygon

Regular dodecahedron.

Kind: static method of primitiveGeometry

Param Type Default
[options] DodecahedronFacesOptions {}

primitiveGeometry.dodecahedron([options]) ⇒ SimplicialComplex

Regular dodecahedron.

Kind: static method of primitiveGeometry

Param Type Default
[options] DodecahedronOptions {}

primitiveGeometry.greatDodecahedronFaces([options]) ⇒ SimplicialComplexPolygon

Great dodecahedron, sharing the icosahedron's 12 vertices; each of its 12 pentagonal faces is the convex pentagon formed by one vertex's 5 neighbors, deeply interpenetrating the other 11 faces.

Kind: static method of primitiveGeometry

Param Type Default
[options] GreatDodecahedronFacesOptions {}

primitiveGeometry.greatDodecahedron([options]) ⇒ SimplicialComplex

Great dodecahedron.

Kind: static method of primitiveGeometry

Param Type Default
[options] GreatDodecahedronOptions {}

primitiveGeometry.greatIcosahedronFaces([options]) ⇒ SimplicialComplexPolygon

Great icosahedron, sharing the icosahedron's 12 vertices; each of its 20 triangular faces connects a vertex to two of its "second-shell" neighbors (rather than its 5 immediate ones), deeply interpenetrating the rest.

Kind: static method of primitiveGeometry

Param Type Default
[options] GreatIcosahedronFacesOptions {}

primitiveGeometry.greatIcosahedron([options]) ⇒ SimplicialComplex

Great icosahedron.

Kind: static method of primitiveGeometry

Param Type Default
[options] GreatIcosahedronOptions {}

primitiveGeometry.greatStellatedDodecahedronFaces([options]) ⇒ SimplicialComplexPolygon

Great stellated dodecahedron: the 3rd (outermost) stellation of the dodecahedron. Each face's 5 edges, extended within its own plane, first cross at a "depth 1" ring (exactly the icosahedron's vertex positions - small stellated dodecahedron's own tips) before crossing a second, further ring at "depth 2" - the true tips here, a plain radial scale of the dodecahedron's own vertices by phi^3.

Kind: static method of primitiveGeometry

Param Type Default
[options] GreatStellatedDodecahedronFacesOptions {}

primitiveGeometry.greatStellatedDodecahedron([options]) ⇒ SimplicialComplex

Great stellated dodecahedron.

Kind: static method of primitiveGeometry

Param Type Default
[options] GreatStellatedDodecahedronOptions {}

primitiveGeometry.hexahedronFaces([options]) ⇒ SimplicialComplexPolygon

Regular hexahedron (cube) faces: 8 corners, cells order +x, -x, +y, -y, +z, -z - cubeFaces's own layout, since a regular hexahedron is exactly a cube whose half-extent (radius) is the same on all 3 axes.

Kind: static method of primitiveGeometry

Param Type Default
[options] HexahedronFacesOptions {}

primitiveGeometry.hexahedron([options]) ⇒ SimplicialComplex

Regular hexahedron (cube).

Kind: static method of primitiveGeometry

Param Type Default
[options] HexahedronOptions {}

primitiveGeometry.icosahedronFaces([options]) ⇒ SimplicialComplexPolygon

Regular icosahedron.

Kind: static method of primitiveGeometry

Param Type Default
[options] IcosahedronFacesOptions {}

primitiveGeometry.icosahedron([options]) ⇒ SimplicialComplex

Regular icosahedron.

Kind: static method of primitiveGeometry

Param Type Default
[options] IcosahedronOptions {}

primitiveGeometry.octahedronFaces([options]) ⇒ SimplicialComplexPolygon

Regular octahedron.

Kind: static method of primitiveGeometry

Param Type Default
[options] OctahedronFacesOptions {}

primitiveGeometry.octahedron([options]) ⇒ SimplicialComplex

Regular octahedron.

Kind: static method of primitiveGeometry

Param Type Default
[options] OctahedronOptions {}

primitiveGeometry.smallStellatedDodecahedronFaces([options]) ⇒ SimplicialComplexPolygon

Small stellated dodecahedron: the same 12 vertices and pentagon groupings as the great dodecahedron, with each face's 5 corners connected as a pentagram (skip-one star) instead of a convex pentagon.

Kind: static method of primitiveGeometry

Param Type Default
[options] SmallStellatedDodecahedronFacesOptions {}

primitiveGeometry.smallStellatedDodecahedron([options]) ⇒ SimplicialComplex

Small stellated dodecahedron.

Kind: static method of primitiveGeometry

Param Type Default
[options] SmallStellatedDodecahedronOptions {}

primitiveGeometry.tetrahedronFaces([options]) ⇒ SimplicialComplexPolygon

Regular tetrahedron, apex-up, bounding box centered at the origin.

Kind: static method of primitiveGeometry

Param Type Default
[options] TetrahedronFacesOptions {}

primitiveGeometry.tetrahedron([options]) ⇒ SimplicialComplex

Regular tetrahedron.

Kind: static method of primitiveGeometry

Param Type Default
[options] TetrahedronOptions {}

primitiveGeometry~CrossOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.5 Distance from the center to each arm's tip.
[armWidth] number radius/3 Half-width of each arm. Defaults to a third of radius, the classic Greek cross made of 5 equal squares.
[segments] number 1 Column count per outline edge (the cross is a 12-sided, non-regular dodecagon), swept around the outline.
[innerSegments] number 16 Row count between the center and the outline at each column.
[innerRadius] number 0 Like star's: a hole radius the fill stops at instead of reaching the center, traced as a smaller, self- similar copy of the outer cross. 0 (default): no hole, fill reaches the center.
[mergeCentroid] boolean true
[mapping] MappingFn mappings.rectangular Uv mapping function. Defaults to a flat, bounding-box-relative unwrap.

primitiveGeometry~CrossPathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[armWidth] number radius/3
[segments] number 1
[closed] boolean false

primitiveGeometry~PolygonOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sides] number 6
[sx] number 1
[sy] number 1
[radius] number 0.5
[edgeSegments] number 1
[innerSegments] number 16
[innerRadius] number 0
[theta] number TAU
[thetaOffset] number 0
[mergeCentroid] boolean true
[mapping] MappingFn mappings.concentric

primitiveGeometry~PolygonPathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sides] number 6
[sx] number 1
[sy] number 1
[radius] number 0.5
[edgeSegments] number 1
[theta] number TAU
[thetaOffset] number 0
[closed] boolean false

primitiveGeometry~ReuleauxOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[segments] number 32
[innerSegments] number 16
[theta] number TAU
[thetaOffset] number 0
[mergeCentroid] boolean true
[mapping] MappingFn mappings.concentric
[n] number 3

primitiveGeometry~ReuleauxPathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[segments] number 32
[theta] number TAU
[thetaOffset] number 0
[n] number 3
[closed] boolean false

primitiveGeometry~StarOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[points] number 5
[density] number 2 Schläfli "skip" factor: must be < points / 2 (and coprime with points for a genuine, non-compound star polygon) or the auto-computed notchRadius degenerates.
[radius] number 0.5
[notchRadius] number radius*computeStarRatio(points,density) Radius of the points/tips' flanking concave vertices, ie. how deep the star's notches cut in.
[innerRadius] number 0 Like annulus's: a hole radius the fill stops at instead of reaching the center. 0 (default): no hole, fill reaches the center (subject to mergeCentroid).
[circularHole] boolean false Only relevant when innerRadius is non-zero: false (default) traces the hole as a smaller, self-similar copy of the outer star; true traces it as a plain circle.
[innerSegments] number 16
[theta] number TAU
[thetaOffset] number 0
[mergeCentroid] boolean Defaults to true (fill to center) when innerRadius is 0, false (leave the hole open) otherwise.
[mapping] MappingFn mappings.concentric

primitiveGeometry~StarPathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[points] number 5
[density] number 2
[radius] number 0.5
[notchRadius] number radius*computeStarRatio(points,density)
[theta] number TAU
[thetaOffset] number 0
[closed] boolean false

primitiveGeometry~ArbelosOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.5 Outer (enclosing) semicircle's radius: half the total baseline width.
[innerRadius] number radius*0.25 Radius of the left of the 2 inner semicircles, both bulging the same way as the enclosing one (up, above the baseline) and tangent to each other where they meet it: innerRadius and radius - innerRadius apart from the enclosing semicircle's left/right ends, respectively.
[segments] number 32 Column count, swept left to right.
[innerSegments] number 16 Row count between the bottom and top boundary at each column.
[mapping] MappingFn mappings.rectangular Uv mapping function. Defaults to a flat, bounding-box-relative unwrap; pass a function using uRatio/vRatio (the swept parametrization) to follow the arcs instead.

primitiveGeometry~LensOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.5 Radius of the first circle, centered at -distance / 2.
[radius2] number radius Radius of the second circle, centered at distance / 2. Equal to radius (a symmetric lens) by default.
[distance] number radius Distance between the two circles' centers.
[segments] number 32 Column count, swept left to right.
[innerSegments] number 16 Row count between the bottom and top boundary at each column.
[mapping] MappingFn mappings.rectangular Uv mapping function. Defaults to a flat, bounding-box-relative unwrap; pass a function using uRatio/vRatio (the swept parametrization) to follow the arcs instead.

primitiveGeometry~LuneOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.5 Radius of the big circle (b in MathWorld's notation), centered at the origin.
[innerRadius] number radius Radius of the small circle (a), whose disk is subtracted from the big one. Must be < radius.
[distance] number radius*0.5 Offset of the small circle's center from the origin, along +x (c). For a proper crescent (both arcs contributing to the boundary) distance + innerRadius must exceed radius, ie. the small circle actually pokes through the big one's edge rather than sitting fully inside it.
[segments] number 32 Column count, swept left to right.
[innerSegments] number 16 Row count between the two halves' near/far boundary at each column.
[mapping] MappingFn mappings.rectangular Uv mapping function. Defaults to a flat, bounding-box-relative unwrap; pass a function using uRatio/vRatio (the swept parametrization) to follow the arcs instead.

primitiveGeometry~SalinonOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.5 Outer (enclosing) radius: half the total width, and the radius of the semicircle forming the bottom boundary.
[innerRadius] number radius*0.25 Radius of the central semicircle, bulging opposite the enclosing one (up, above the baseline) over the middle third. The two flanking "ear" semicircles bulge the same way as the enclosing one (down, a shallower dip below the baseline) over the outer two thirds, sized to meet it at the baseline: (radius - innerRadius) / 2 each.
[segments] number 32 Column count, swept left to right.
[innerSegments] number 16 Row count between the bottom and top boundary at each column.
[mapping] MappingFn mappings.rectangular Uv mapping function. Defaults to a flat, bounding-box-relative unwrap; pass a function using uRatio/vRatio (the swept parametrization) to follow the arcs instead.

primitiveGeometry~TriquetraOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.5 Radius of each of the 3 circles, and the side length of the equilateral triangle formed by their centers - a canonical Triquetra has no separate spacing parameter.
[segments] number 32 Column count, swept angularly per wedge, for both the core and the petals.
[innerSegments] number 16 Row count between the two boundaries at each column.
[mapping] MappingFn mappings.rectangular Uv mapping function. Defaults to a flat, bounding-box-relative unwrap; pass a function using uRatio/vRatio (the swept parametrization) to follow the arcs instead.

primitiveGeometry~YinYangOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.5 Radius of the enclosing circle.
[dotRadius] number radius/6 Radius of the hole cut at each returned half's own dot position. 0 omits the hole(s).
[part] "yin" | "yang" | "yin-yang" "yin-yang" "yin"/"yang" return one S-curve-divided half (bounded by half the outer circle and the S-curve), with its dot hole centered at the other half's bulge ((0, -radius/2) for yang, (0, radius/2) for yin). "yin-yang" merges both into one mesh; without per-face material/color the S-curve seam is then invisible (indistinguishable from a disc with two holes).
[segments] number 32 Row count for the outer circle/S-curve boundary, swept bottom to top.
[holeSegments] number 16 Row count for a dot hole's own boundary, independent of the outer boundary's segments.
[innerSegments] number 16 Column count spanning each side of a dot hole (or the whole half, where the hole doesn't reach) at each row.
[mapping] MappingFn mappings.rectangular Uv mapping function. Defaults to a flat, bounding-box-relative unwrap; pass a function using uRatio/vRatio (the swept parametrization) to follow the arcs instead.

primitiveGeometry~AnnulusOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number 1
[radius] number 0.5
[segments] number 32
[innerSegments] number 16
[theta] number TAU
[thetaOffset] number 0
[innerRadius] number radius * 0.5
[mapping] MappingFn mappings.concentric

primitiveGeometry~AnnulusPathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number 1
[radius] number 0.5
[segments] number 32
[theta] number TAU
[thetaOffset] number 0
[innerRadius] number radius * 0.5
[closed] boolean false

primitiveGeometry~AstroidOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[segments] number 32
[innerSegments] number 16
[theta] number TAU
[thetaOffset] number 0
[mergeCentroid] boolean true
[mapping] MappingFn mappings.lamé

primitiveGeometry~AstroidPathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[segments] number 32
[theta] number TAU
[thetaOffset] number 0
[closed] boolean false

primitiveGeometry~DiscOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[segments] number 32
[innerSegments] number 16
[theta] number TAU
[thetaOffset] number 0
[mergeCentroid] boolean true
[mapping] MappingFn mappings.concentric

primitiveGeometry~CirclePathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[segments] number 32
[theta] number TAU
[thetaOffset] number 0
[closed] boolean false

primitiveGeometry~EllipseOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[sx] number 1
[sy] number 0.5
[radius] number 0.5
[segments] number 32
[innerSegments] number 16
[theta] number TAU
[thetaOffset] number 0
[innerRadius] number 0 Like annulus's: a hole radius the fill stops at instead of reaching the center. 0 (default): no hole, fill reaches the center (subject to mergeCentroid).
[mergeCentroid] boolean true
[mapping] MappingFn mappings.elliptical
[equation] EllipseEquationFn Maps each (rx, ry, cosTheta, sinTheta) sample to its [x, y] position, defaulting to an ellipse's arc.

primitiveGeometry~EllipseEquationFn ⇒ [x, y]

Kind: inner typedef of primitiveGeometry

Param Type Description
sample object
sample.rx number Scaled ring radius along x
sample.ry number Scaled ring radius along y
sample.cosTheta number
sample.sinTheta number
sample.s number Radius ratio (0..1, innerRadius to radius)
sample.t number Angle

primitiveGeometry~EllipsePathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number 0.5
[radius] number 0.5
[segments] number 32
[theta] number TAU
[thetaOffset] number 0
[closed] boolean false

primitiveGeometry~SquircleOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[sx] number 1
[sy] number 1
[radius] number 0.5
[segments] number 128
[innerSegments] number 16
[theta] number TAU
[thetaOffset] number 0
[mergeCentroid] boolean true
[mapping] MappingFn mappings.fgSquircular
[squareness] number 0.95 Squareness (0 < s <= 1)

primitiveGeometry~SquirclePathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number 1
[radius] number 0.5
[segments] number 128
[theta] number TAU
[thetaOffset] number 0
[squareness] number 0.95
[closed] boolean false

primitiveGeometry~SuperellipseOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number 0.5
[radius] number 0.5
[segments] number 32
[innerSegments] number 16
[theta] number TAU
[thetaOffset] number 0
[mergeCentroid] boolean true
[mapping] MappingFn mappings.lamé
[m] number 2
[n] number m

primitiveGeometry~SuperellipsePathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number 0.5
[radius] number 0.5
[segments] number 32
[theta] number TAU
[thetaOffset] number 0
[m] number 2
[n] number m
[closed] boolean false

primitiveGeometry~HexagonalGridOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[nx] number 10
[ny] number 10
[inscribed] boolean true

primitiveGeometry~QuadGridOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number sx
[nx] number 10
[ny] number nx

primitiveGeometry~TriangularGridOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[nx] number 10
[ny] number 10
[inscribed] boolean true

primitiveGeometry~KiteOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[sx] number 1
[sy] number 1
[ratio] number 0.5 Bottom vertex distance from center, as a fraction of the top vertex's (sy). ratio=1 is a rhombus, ratio=0 collapses the bottom to the center.
[radius] number 0.5
[edgeSegments] number 1
[innerSegments] number 16
[innerRadius] number 0
[theta] number TAU
[thetaOffset] number HALF_PI
[mergeCentroid] boolean true
[mapping] MappingFn mappings.concentric

primitiveGeometry~KitePathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number 1
[ratio] number 0.5
[radius] number 0.5
[edgeSegments] number 1
[theta] number TAU
[thetaOffset] number HALF_PI
[closed] boolean false

primitiveGeometry~LozengeOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 0.5
[sy] number sx*2
[radius] number 0.5
[edgeSegments] number 1
[innerSegments] number 16
[innerRadius] number 0
[theta] number TAU
[thetaOffset] number HALF_PI
[mergeCentroid] boolean true
[mapping] MappingFn mappings.concentric

primitiveGeometry~LozengePathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 0.5
[sy] number sx*2
[radius] number 0.5
[edgeSegments] number 1
[theta] number TAU
[thetaOffset] number HALF_PI
[closed] boolean false

primitiveGeometry~ParallelogramOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[sx] number 0.5 Narrower than trapezoid's default so the sheared top edge still fits the unit box.
[sy] number 1
[shear] number 0.3 Horizontal shift of the top edge's center, as a fraction of sx.
[radius] number 0.5
[edgeSegments] number 1
[innerSegments] number 16
[innerRadius] number 0
[theta] number TAU
[thetaOffset] number 0
[mergeCentroid] boolean true
[mapping] MappingFn mappings.rectangular

primitiveGeometry~ParallelogramPathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 0.5
[sy] number 1
[shear] number 0.3
[radius] number 0.5
[edgeSegments] number 1
[theta] number TAU
[thetaOffset] number 0
[closed] boolean false

primitiveGeometry~PlaneOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number sx
[nx] number 1
[ny] number nx
[direction] PlaneDirection "z"

primitiveGeometry~PlaneDirection : "x" | "-x" | "y" | "-y" | "z" | "-z"

Kind: inner typedef of primitiveGeometry

primitiveGeometry~RectanglePathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[sx] number 1
[sy] number 0.5
[nx] number 1 Segments along the bottom/top edges
[ny] number nx Segments along the left/right edges

primitiveGeometry~QuadOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[scale] number 0.5

primitiveGeometry~SquarePathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[scale] number 0.5
[nx] number 1 Segments along the bottom/top edges
[ny] number nx Segments along the left/right edges

primitiveGeometry~RhombusOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number 1
[radius] number 0.5
[edgeSegments] number 1
[innerSegments] number 16
[innerRadius] number 0
[theta] number TAU
[thetaOffset] number HALF_PI
[mergeCentroid] boolean true
[mapping] MappingFn mappings.concentric

primitiveGeometry~RhombusPathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number 1
[radius] number 0.5
[edgeSegments] number 1
[theta] number TAU
[thetaOffset] number HALF_PI
[closed] boolean false

primitiveGeometry~RoundedRectangleCorner : "top-left" | "top-right" | "bottom-right" | "bottom-left"

Kind: inner typedef of primitiveGeometry

primitiveGeometry~RoundedRectangleOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[sx] number 1
[sy] number sx
[radius] number sx * 0.25
[roundSegments] number 8
[edgeSegments] number 1
[nx] number edgeSegments Segments along the straight top/bottom sections.
[ny] number nx Segments along the straight left/right sections.
[roundedCorners] Array.<RoundedRectangleCorner> ["top-left", "top-right", "bottom-right", "bottom-left"]

primitiveGeometry~RoundedRectanglePathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number sx
[radius] number sx * 0.25
[roundSegments] number 8
[edgeSegments] number 1
[nx] number edgeSegments
[ny] number nx
[roundedCorners] Array.<RoundedRectangleCorner> ["top-left", "top-right", "bottom-right", "bottom-left"]
[closed] boolean false

primitiveGeometry~StadiumOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number 0.5
[nx] number 1
[ny] number nx
[roundSegments] number 8
[edgeSegments] number 1

primitiveGeometry~StadiumPathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number 0.5
[nx] number 1
[ny] number nx
[roundSegments] number 8
[edgeSegments] number 1
[closed] boolean false

primitiveGeometry~TrapezoidOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[sx] number 1 Bottom edge half-width.
[sy] number 1 Half-height: the bottom/top edges sit at y = -sy/y = sy.
[topRatio] number 0.5 Top edge half-width, as a fraction of sx. 1 matches the bottom edge's width (a parallelogram once topOffset shifts it off-center); 0 collapses the top edge to a point (a triangle).
[topOffset] number 0 Horizontal shift of the top edge's center, as a fraction of sx. 0 (default) keeps both legs symmetric (an isosceles trapezoid); a non-zero shift skews it into a right/scalene trapezoid.
[radius] number 0.5
[edgeSegments] number 1
[innerSegments] number 16
[innerRadius] number 0
[theta] number TAU Negative values aren't supported: the corner lookup assumes t - thetaOffset stays non-negative.
[thetaOffset] number 0
[mergeCentroid] boolean true
[mapping] MappingFn mappings.rectangular Uv mapping function. Defaults to a flat, bounding-box-relative unwrap.

primitiveGeometry~TrapezoidPathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number 1
[topRatio] number 0.5
[topOffset] number 0
[radius] number 0.5
[edgeSegments] number 1
[theta] number TAU
[thetaOffset] number 0
[closed] boolean false

primitiveGeometry~RightTriangleOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[sx] number 1 Horizontal leg half-length: the leg itself runs the full 2 * sx, from the right-angle corner to the opposite base corner.
[sy] number 1 Vertical leg half-length, likewise doubled.
[radius] number 0.5
[edgeSegments] number 1
[innerSegments] number 16
[innerRadius] number 0
[theta] number TAU
[thetaOffset] number 0
[mergeCentroid] boolean true
[mapping] MappingFn mappings.rectangular

primitiveGeometry~RightTrianglePathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number 1
[radius] number 0.5
[edgeSegments] number 1
[theta] number TAU
[thetaOffset] number 0
[closed] boolean false

primitiveGeometry~TriangleOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[sx] number 1 Base half-width: the base corners sit at x = -sx/x = sx.
[sy] number 1 Half-height: the base sits at y = -sy, the apex at y = sy.
[apexOffset] number 0 Horizontal shift of the apex, in the same units as sx. 0 (default) keeps it centered (an isosceles triangle); ±sx lands it directly above a base corner (a right triangle); anything else gives a scalene triangle.
[radius] number 0.5
[edgeSegments] number 1
[innerSegments] number 16
[innerRadius] number 0
[theta] number TAU Negative values aren't supported: the corner lookup assumes t - thetaOffset stays non-negative.
[thetaOffset] number 0
[mergeCentroid] boolean true
[mapping] MappingFn mappings.rectangular Uv mapping function. Defaults to a flat, bounding-box-relative unwrap.

primitiveGeometry~TrianglePathOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number 1
[apexOffset] number 0
[radius] number 0.5
[edgeSegments] number 1
[theta] number TAU
[thetaOffset] number 0
[closed] boolean false

primitiveGeometry~CubeFacesOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number sx
[sz] number sx

primitiveGeometry~BoxOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number sx
[sz] number sx

primitiveGeometry~CubeOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[sx] number 1
[sy] number sx
[sz] number sx
[nx] number 1
[ny] number nx
[nz] number nx

primitiveGeometry~HollowCubeOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[sx] number 1
[sy] number sx
[sz] number sx
[thickness] number sx*0.2 Uniform beam/wall size (must stay < half of the smallest of sx/sy/sz for positive-length beams)

primitiveGeometry~RoundedCubeDirection : "all" | "x" | "y" | "z"

Kind: inner typedef of primitiveGeometry

primitiveGeometry~RoundedCubeOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[sx] number 1
[sy] number sx
[sz] number sx
[radius] number sx * 0.25
[roundSegments] number 8
[edgeSegments] number 1
[nx] number edgeSegments Segments along the straight x sections.
[ny] number nx Segments along the straight y sections.
[nz] number nx Segments along the straight z sections.
[roundDirection] RoundedCubeDirection "all"

primitiveGeometry~AntiprismOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.25
[height] number 1
[sides] number 6
[phiOffset] number 0
[capMapping] MappingFn mappings.rectangular

primitiveGeometry~PrismOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.25
[height] number 1
[sides] number 6
[phiOffset] number 0
[capMapping] MappingFn mappings.rectangular

primitiveGeometry~AppleOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.5 Equatorial (belly) radius
[height] number radius Full height between the two dimple points, silently clamped to (0, radius*2] - the generating circle's own radius must exceed its offset from the axis (see below), which fails past that bound
[nx] number 32
[ny] number 16
[phi] number TAU
[phiOffset] number 0
[vDistribution] DistributionFn utils.linear

primitiveGeometry~AstroidalEllipsoidOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 1
[nx] number 32
[ny] number 16
[rx] number 0.5
[ry] number 0.25
[rz] number ry
[theta] number Math.PI Meridian sweep length, silently clamped to [-thetaOffset, PI - thetaOffset] - see ellipsoid.js's EllipsoidOptions for why.
[thetaOffset] number 0 Meridian sweep start, silently clamped to [0, PI] - see theta.
[phi] number TAU
[phiOffset] number 0

primitiveGeometry~BarrelOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[height] number 1
[radius] number 0.5 Belly radius, at the equator (y = 0)
[endRadius] number radius*0.7 Rim radius, at y = ±height/2 (both ends, symmetric) - must be < radius for an actual outward bulge; endRadius = radius degenerates to a plain cylinder, endRadius > radius pinches inward instead (a barrel held together the wrong way round, still a valid NaN-free surface)
[nx] number 32
[ny] number 16
[capSegments] number 1
[capApex] boolean true
[capBase] boolean true
[phi] number TAU
[phiOffset] number 0
[capMapping] MappingFn mappings.rectangular
[vDistribution] DistributionFn utils.linear

primitiveGeometry~BiconeOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[height] number 1
[radius] number 0.5
[nx] number 16
[ny] number 1 Meridian segments per half (top/bottom cone)
[phi] number TAU
[phiOffset] number 0
[sx] number 1 Equator x scale, elliptical when != sz
[sz] number 1 Equator z scale, elliptical when != sx

primitiveGeometry~CapsuleOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[height] number 0.5
[radius] number 0.25
[nx] number 16
[ny] number 1
[roundSegments] number 16 0 collapses both hemispheres away, leaving an open tube.
[phi] number TAU
[phiOffset] number 0
[vDistribution] DistributionFn utils.linear

primitiveGeometry~ConeOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[height] number 1
[radius] number 0.25
[nx] number 16
[ny] number 1
[capSegments] number 1
[capBase] boolean true
[phi] number TAU
[phiOffset] number 0
[capMapping] MappingFn mappings.rectangular
[sx] number 1 Base ring x scale, elliptical when != sz
[sz] number 1 Base ring z scale, elliptical when != sx
[vDistribution] DistributionFn utils.linear

primitiveGeometry~CylinderOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[height] number 1
[radius] number 0.25
[nx] number 16
[ny] number 1
[radiusApex] number radius
[capSegments] number 1
[capApex] boolean true
[capBase] boolean true
[capBaseSegments] number capSegments
[phi] number TAU
[phiOffset] number 0
[capMapping] MappingFn mappings.rectangular
[sx] number 1 Base ring x scale, elliptical when != sz
[sz] number 1 Base ring z scale, elliptical when != sx
[sxApex] number sx Apex ring x scale, independent of the base
[szApex] number sz Apex ring z scale, independent of the base
[vDistribution] DistributionFn utils.linear

primitiveGeometry~DoubleConeOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[height] number 1
[radius] number 0.5
[nx] number 16
[ny] number 1 Meridian segments per half (top/bottom cone)
[capSegments] number 1
[capApex] boolean true
[capBase] boolean true
[capBaseSegments] number capSegments
[phi] number TAU
[phiOffset] number 0
[capMapping] MappingFn mappings.rectangular
[sx] number 1 End ring x scale, elliptical when != sz
[sz] number 1 End ring z scale, elliptical when != sx

primitiveGeometry~EllipsoidOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 1
[nx] number 32
[ny] number 16
[rx] number 0.5
[ry] number 0.25
[rz] number ry
[theta] number Math.PI Meridian sweep length, silently clamped to [-thetaOffset, PI - thetaOffset]: a pole can only sit at the sweep's own start or end, never partway through.
[thetaOffset] number 0 Meridian sweep start (0 = north pole), silently clamped to [0, PI] - see theta.
[phi] number TAU
[phiOffset] number 0
[vDistribution] DistributionFn utils.linear

primitiveGeometry~FunnelOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[height] number 1
[radius] number 0.1 Spout radius, at y = -height/2
[radiusTop] number radius*5 Mouth radius, at y = height/2 - must be > radius for the usual flared-outward shape; radiusTop = radius degenerates to a plain cylinder, radiusTop < radius flips the taper (still a valid, NaN-free surface, just narrowing toward the top instead)
[nx] number 32
[ny] number 16
[capSegments] number 1
[capApex] boolean true
[capBase] boolean true
[phi] number TAU
[phiOffset] number 0
[capMapping] MappingFn mappings.rectangular
[vDistribution] DistributionFn utils.linear

primitiveGeometry~HollowCylinderOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[height] number 1
[radius] number 0.5
[innerRadius] number radius*0.5 Bore radius
[nx] number 32
[ny] number 1
[capSegments] number 1 Radial segments of each annular cap
[capApex] boolean true
[capBase] boolean true
[phi] number TAU
[phiOffset] number 0

primitiveGeometry~HollowSphereOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.5
[innerRadius] number radius*0.5
[nx] number 32
[ny] number 16
[capSegments] number 1 Radial segments of each cut cap
[theta] number Math.PI / 2 Meridian sweep length, silently clamped like ellipsoid's
[thetaOffset] number Math.PI / 4 Meridian sweep start, silently clamped like ellipsoid's
[phi] number TAU
[phiOffset] number 0

primitiveGeometry~HyperboloidOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[height] number 1
[radius] number 0.25 Waist radius, at y = 0
[radiusTop] number radius*2 Rim radius, at y = ±height/2 (both ends, symmetric) - the classic one-sheet shape needs radiusTop > radius (pinched waist flaring to both rims); radiusTop = radius degenerates to a plain cylinder, and radiusTop < radius traces an oblate-spheroid-like profile instead (still a valid, NaN-free surface, just not a hyperbola)
[nx] number 32
[ny] number 16
[capSegments] number 1
[capApex] boolean true
[capBase] boolean true
[phi] number TAU
[phiOffset] number 0
[capMapping] MappingFn mappings.rectangular
[vDistribution] DistributionFn utils.linear

primitiveGeometry~LemonOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.3 Equatorial (widest) radius
[height] number 1 Full height between the two pointed ends, silently raised to at least radius_2 - below that the generating circle's center offset would go negative, no longer tracing the lemon's own (minor, less-than-half-circle) arc; height = radius_2 exactly degenerates to a plain sphere (the offset hits 0)
[nx] number 32
[ny] number 16
[phi] number TAU
[phiOffset] number 0
[vDistribution] DistributionFn utils.linear

primitiveGeometry~ParaboloidOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[height] number 1
[radius] number 0.5 Rim radius, at the open (base) end
[nx] number 32
[ny] number 16
[capSegments] number 1
[capBase] boolean true
[phi] number TAU
[phiOffset] number 0
[capMapping] MappingFn mappings.rectangular
[vDistribution] DistributionFn utils.linear

primitiveGeometry~RoundedCylinderOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[height] number 1
[radius] number 0.25
[roundRadius] number radius*0.3 Fillet radius at the top/bottom rim, silently clamped to [0, min(radius, height/2)] - the fillet can neither exceed the body's own radius nor meet itself across the height
[nx] number 16
[ny] number 1 Straight side segments
[roundSegments] number 8 Fillet segments (each end)
[capSegments] number 1 Flat cap segments (each end)
[phi] number TAU
[phiOffset] number 0
[vDistribution] DistributionFn utils.linear

primitiveGeometry~SphereOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[nx] number 32
[ny] number 16
[theta] number Math.PI
[thetaOffset] number 0
[phi] number TAU
[phiOffset] number 0

primitiveGeometry~SphericalRingOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.5 Sphere radius
[innerRadius] number radius*0.5 Cylindrical bore radius, silently clamped to [0, radius] - a bore wider than the sphere has no sensible rim to meet
[nx] number 32
[ny] number 16 Outer spherical band meridian segments
[holeSegments] number 1 Inner bore wall segments
[phi] number TAU
[phiOffset] number 0
[vDistribution] DistributionFn utils.linear Applies to the outer spherical band only - the inner bore wall is a plain cylinder.

primitiveGeometry~SphericonOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.5
[nx] number 16 Segments per quarter-cone's half-turn sweep
[ny] number 1 Meridian segments per quarter-cone (its meridian is a straight cone slant, so ny > 1 buys nothing by default, same as cone/bicone/doubleCone)

primitiveGeometry~SupereggOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.5 Equatorial radius
[ry] number radius*5/6 Vertical (polar) semi-axis
[nx] number 32
[ny] number 16
[n] number 2.5 Roundness exponent - Piet Hein's original; n > 2 gives a "true" superegg, n = 2 is a spheroid, n < 2 rounds toward a cylinder-capped-with-cones shape
[theta] number Math.PI Meridian sweep length, silently clamped to [-thetaOffset, PI - thetaOffset] - see ellipsoid.js's EllipsoidOptions for why.
[thetaOffset] number 0 Meridian sweep start, silently clamped to [0, PI] - see theta.
[phi] number TAU
[phiOffset] number 0
[vDistribution] DistributionFn utils.linear

primitiveGeometry~SuperellipsoidOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 1
[nx] number 32
[ny] number 16
[rx] number 0.5
[ry] number 0.25
[rz] number ry
[n1] number 3 North-south (meridian) roundness exponent
[n2] number n1 East-west (cross-section) roundness exponent
[theta] number Math.PI Meridian sweep length, silently clamped to [-thetaOffset, PI - thetaOffset] - see ellipsoid.js's EllipsoidOptions for why.
[thetaOffset] number 0 Meridian sweep start, silently clamped to [0, PI] - see theta.
[phi] number TAU
[phiOffset] number 0
[vDistribution] DistributionFn utils.linear

primitiveGeometry~TorusOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.4
[segments] number 64
[minorRadius] number 0.1
[minorSegments] number 32
[theta] number TAU
[thetaOffset] number 0
[phi] number TAU
[phiOffset] number 0
[capSegments] number 1
[capStart] boolean true
[capEnd] boolean true
[capStartSegments] number capSegments
[capEndSegments] number capSegments
[capMapping] MappingFn mappings.rectangular
[sx] number 1 Major sweep x scale (footprint), elliptical when != sy
[sy] number 1 Major sweep y scale (footprint), elliptical when != sx
[minorSx] number 1 Tube radial scale (meridian cross-section), elliptical when != minorSy
[minorSy] number 1 Tube z scale (meridian cross-section), elliptical when != minorSx

primitiveGeometry~DodecasphereOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[subdivisions] number 2
[projection] "gnomonic" | "spherical" "gnomonic"
[mapping] MappingFn mappings.spherical

primitiveGeometry~HexasphereOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[subdivisions] number 2
[projection] "gnomonic" | "spherical" "gnomonic"
[mapping] MappingFn mappings.spherical

primitiveGeometry~IcosphereOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[subdivisions] number 2
[projection] "gnomonic" | "spherical" "gnomonic"
[mapping] MappingFn mappings.spherical

primitiveGeometry~OctasphereOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[subdivisions] number 2
[projection] "gnomonic" | "spherical" "gnomonic"
[mapping] MappingFn mappings.spherical

primitiveGeometry~TetrasphereOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[subdivisions] number 2
[projection] "gnomonic" | "spherical" "gnomonic"
[mapping] MappingFn mappings.spherical

primitiveGeometry~DodecahedronFacesOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5

primitiveGeometry~DodecahedronOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[subdivisions] number 0
[mapping] MappingFn mappings.rectangular

primitiveGeometry~GreatDodecahedronFacesOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5

primitiveGeometry~GreatDodecahedronOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[subdivisions] number 0
[mapping] MappingFn mappings.rectangular

primitiveGeometry~GreatIcosahedronFacesOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.5 Radius of the shared icosahedron vertices

primitiveGeometry~GreatIcosahedronOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[subdivisions] number 0
[mapping] MappingFn mappings.rectangular

primitiveGeometry~GreatStellatedDodecahedronFacesOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.5 Radius the star's tips touch (box half-extent)

primitiveGeometry~GreatStellatedDodecahedronOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.5
[subdivisions] number 0 Barycentric grid subdivisions per triangle
[mapping] MappingFn mappings.rectangular

primitiveGeometry~HexahedronFacesOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5

primitiveGeometry~HexahedronOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[subdivisions] number 0
[mapping] MappingFn mappings.rectangular

primitiveGeometry~IcosahedronFacesOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5

primitiveGeometry~IcosahedronOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[subdivisions] number 0
[mapping] MappingFn mappings.rectangular

primitiveGeometry~OctahedronFacesOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5

primitiveGeometry~OctahedronOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[subdivisions] number 0
[mapping] MappingFn mappings.rectangular

primitiveGeometry~SmallStellatedDodecahedronFacesOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.5 Radius of the shared icosahedron vertices

primitiveGeometry~SmallStellatedDodecahedronOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[subdivisions] number 0
[mapping] MappingFn mappings.rectangular

primitiveGeometry~TetrahedronFacesOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default Description
[radius] number 0.5
[center] boolean true Center the bounding box at the origin. Set to false to keep every vertex at exactly the circumradius from the origin - needed as-is wherever radial projection applies.

primitiveGeometry~TetrahedronOptions : object

Kind: inner typedef of primitiveGeometry Properties

Name Type Default
[radius] number 0.5
[subdivisions] number 0
[mapping] MappingFn mappings.rectangular

mappings

mappings.rectangular() : MappingsFn

Kind: static method of mappings

mappings.polar() : MappingsFn

Kind: static method of mappings

mappings.spherical() : MappingsFn

Kind: static method of mappings

mappings.radial() : MappingsFn

Kind: static method of mappings

mappings.concentric() : MappingsFn

Kind: static method of mappings

mappings.lamé() : MappingsFn

Kind: static method of mappings

mappings.elliptical() : MappingsFn

Kind: static method of mappings

mappings.fgSquircular() : MappingsFn

Kind: static method of mappings

mappings.twoSquircular() : MappingsFn

Kind: static method of mappings

mappings.threeSquircular() : MappingsFn

Kind: static method of mappings

mappings.cornerificTapered2() : MappingsFn

Kind: static method of mappings

mappings.tapered4() : MappingsFn

Kind: static method of mappings

mappings.nonAxial2Pinch() : MappingsFn

Kind: static method of mappings

mappings.nonAxialHalfPinch() : MappingsFn

Kind: static method of mappings

mappings.squelched() : MappingsFn

Kind: static method of mappings

mappings.squelchedVertical() : MappingsFn

Kind: static method of mappings

mappings.squelchedHorizontal() : MappingsFn

Kind: static method of mappings

mappings~MappingFn : function

Kind: inner typedef of mappings

Param Type
mappingOptions object
[mappingOptions.uvs] Float32Array
[mappingOptions.index] number
[mappingOptions.x] number
[mappingOptions.y] number
[mappingOptions.radius] number
[mappingOptions.nx] number
[mappingOptions.ny] number
[mappingOptions.nz] number
[mappingOptions.sx] number
[mappingOptions.sy] number
[mappingOptions.t] number
[mappingOptions.radiusRatio] number
[mappingOptions.thetaRatio] number

utils

utils.TAU : number

Two times PI.

Kind: static constant of utils

utils.HALF_PI : number

Half of PI.

Kind: static constant of utils

utils.SQRT2 : number

Square root of 2.

Kind: static constant of utils

utils.SQRT3 : number

Square root of 3.

Kind: static constant of utils

utils.SQRT6 : number

Square root of 6.

Kind: static constant of utils

utils.PHI : number

Golden ratio: (1 + √5) / 2.

Kind: static constant of utils

utils.getCellsTypedArray ⇒ Uint8Array | Uint16Array | Uint32Array

Select cells typed array from a size determined by amount of vertices.

Kind: static constant of utils See: MDN TypedArray objects

Param Type Description
size number The max value expected

utils.fullscreenTriangle() ⇒ Object

A single triangle, 3x oversized so its 3 vertices land past every edge of the [-1, 1] clip-space square: the standard vertex-shader trick for a fullscreen pass (rasterizes to exactly the viewport once clipped, with no diagonal seam and no overdraw compared to a quad split into 2 triangles). xy positions only

  • No z, no normals/uvs, no cells - since a fullscreen pass reads screen-space data directly (gl_FragCoord, or a uv derived from the clip position in-shader) rather than interpolated vertex attributes, and needs no index buffer for a single triangle.

Kind: static method of utils

utils.setTypedArrayType(type)

Enforce a typed array constructor for cells

Kind: static method of utils

Param Type
type Class.<Uint8Array> | Class.<Uint16Array> | Class.<Uint32Array>

utils.triangulateFaces(cells, numVertices) ⇒ Uint8Array | Uint16Array | Uint32Array

Fan-triangulate a list of closed n-gon faces (a SimplicialComplexPolygon's cells, e.g. [0, 1, 2, 3]) from each face's last corner into a flat, stride-3 SimplicialComplex-style typed array (e.g. [3, 0, 1, 3, 1, 2]). Anchoring on the last corner rather than the first is deliberate for quads: for the BL/BR/TR/TL winding used by eg. rectanglePath, it splits the quad along the same diagonal a row-major TRIANGLE_STRIP produces (and that computePlane/computePolarGeometry/ computeRevolutionGeometry already use), so displacement in a vertex shader creases consistently across every primitive in this library. Only valid for convex, planar faces.

Kind: static method of utils

Param Type Description
cells Array.<TypedArrayLike>
numVertices number Used to pick the returned typed array's element size

utils.concatGeometries(geometries) ⇒ SimplicialComplex

Concatenate SimplicialComplex geometries into one, offsetting each one's cell indices by the running vertex count. Positions coincident across inputs (eg. two bands sharing a seam) stay as separate, unwelded vertices.

Kind: static method of utils

Param Type
geometries Array.<SimplicialComplex>

utils.invert(geometry) ⇒ SimplicialComplex

Flip a geometry inside-out: negate every normal and swap 2 of each triangle's 3 indices so winding stays consistent with the flipped normal. Used to turn an outward-facing surface (eg. a standalone sphere or cylinder) into the inward-facing wall of a shell around it.

Kind: static method of utils

Param Type
geometry SimplicialComplex

utils.linear() : DistributionFn

Uniform spacing: v maps to itself. The default vDistribution for every computeRevolutionGeometry-based solid.

Kind: static method of utils

utils.chebyshev() : DistributionFn

Chebyshev-node-like spacing: clusters rows toward both ends of the meridian sweep (t = 0 and t = 1), sparser through the middle - the classic fix for a pole/cusp at each end whose radius shrinks faster than the sweep parameter grows (eg. ellipsoid's poles, apple/lemon's cusps).

Kind: static method of utils

utils.smoothstep() : DistributionFn

Smoothstep (Hermite ease-in-out) spacing: same both-ends clustering as chebyshev, as a cheap polynomial instead of a cosine - the standard "smoothstep" curve used throughout computer graphics.

Kind: static method of utils

utils.power([exponent]) ⇒ function

Power/ease-out spacing: clusters rows toward t = 1 only, leaving t = 0 as sparse as linear - unlike chebyshev/smoothstep's symmetric, both-ends clustering. exponent = 2 exactly cancels a sqrt radius law (eg. paraboloid's apex, where r = radius·sqrt(1 - v)); exponent = 1 is linear.

Kind: static method of utils

Param Type Default
[exponent] number 2

utils~DistributionFn ⇒ number

Kind: inner typedef of utils

Param Type
t number

TypedArrayLike : Array.<number> | Uint8Array | Uint16Array | Uint32Array

Kind: global typedef

SimplicialComplex : object

Geometry definition.

Kind: global typedef Properties

Name Type
positions Float32Array
normals Float32Array
uvs Float32Array
cells Uint8Array | Uint16Array | Uint32Array

SimplicialComplexPolygon : object

Geometry polygon definition: each cell is a closed n-gon face (implicitly wraps its last index back to its first - never repeat the first index at the end).

Kind: global typedef Properties

Name Type
positions Float32Array
[normals] Float32Array
[uvs] Float32Array
cells Array.<TypedArrayLike>

SimplicialComplexPath : object

Geometry path definition: each cell is an open polyline (no implicit closing edge between its last and first index); repeat the first index at the end of a cell to close that loop explicitly.

Kind: global typedef Properties

Name Type
positions Float32Array
cells Array.<TypedArrayLike>

License

See original packages used in v1:

v3: geometry generators consolidation and expansion

v2 differences with v1:

  • use 3D positions for circle
  • base disc on ellispse and add inner segments
  • fix cylinder orientation and uvs
  • fix icosphere uvs (based on: https://github.com/mourner/icomesh)
  • fix quad normal to +z
  • fix subdivision for rounded geometries (rounded-cube and capsule)
  • uniformise api and internal names
  • use options object
  • remove gl-matrix/pex-math and icosphere dependencies
  • use only trigonometric operation, no matrix transformation
  • base sphere on ellispsoid
  • add cone based on cylinder
  • use flat typed arrays
  • defaults produce geometries contained in a unit bbox
  • add jsdoc, prettier, eslint via snowdev

MIT. See license file.

Keywords