Gathering detailed insights and metrics for primitive-geometry
Gathering detailed insights and metrics for primitive-geometry
Gathering detailed insights and metrics for primitive-geometry
Gathering detailed insights and metrics for primitive-geometry
Geometries for 3D rendering, including normals, UVs and cell indices (faces). Perfect if you want to supercharge your dependency folder... with 30KB of geometries.
npm install primitive-geometry
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (99.88%)
HTML (0.12%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
104 Stars
83 Commits
7 Forks
2 Watchers
1 Branches
2 Contributors
Updated on Jun 22, 2025
Latest Version
2.11.0
Package Id
primitive-geometry@2.11.0
Unpacked Size
142.85 kB
Size
25.84 kB
File Count
58
NPM Version
10.9.2
Node Version
23.11.0
Published on
May 24, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Geometries for 3D rendering, including normals, UVs and cell indices (faces). Perfect if you want to supercharge your dependency folder... with 30KB of geometries.
1npm install primitive-geometry
Float32Array
for geometry data and Uint8Array|Uint16Array|Uint32Array
for cells)See difference with v1 here.
See the example and its source.
1import Primitives from "primitive-geometry"; 2 3const quadGeometry = Primitives.quad({ 4 scale: 0.5, 5}); 6console.log(quadGeometry); 7// { 8// positions: Float32Array [x, y, z, x, y, z, ...], 9// normals: Float32Array [x, y, z, x, y, z, ...] 10// uvs: Float32Array [u, v, u, v, ...], 11// cells: Uint8/16/32/Array [a, b, c, a, b, c, ...], 12// } 13const planeGeometry = Primitives.plane({ 14 sx: 1, 15 sy: 1, 16 nx: 1, 17 ny: 1, 18 direction: "z", 19 quads: false, 20}); 21const roundedRectangleGeometry = Primitives.roundedRectangle({ 22 sx: 1, 23 sy: 1, 24 nx: 1, 25 ny: 1, 26 radius: 0.25, 27 roundSegments: 8, 28 edgeSegments: 1, 29}); 30const stadiumGeometry = Primitives.stadium({ 31 sx: 1, 32 sy: 0.5, 33 nx: 1, 34 ny: 1, 35 roundSegments: 8, 36 edgeSegments: 1, 37}); 38 39const ellipseGeometry = Primitives.ellipse({ 40 sx: 1, 41 sy: 0.5, 42 radius: 0.5, 43 segments: 32, 44 innerSegments: 16, 45 theta: Math.PI * 2, 46 thetaOffset: 0, 47 mergeCentroid: true, 48 mapping: mappings.elliptical, 49}); 50const disc = Primitives.disc({ 51 radius: 0.5, 52 segments: 32, 53 innerSegments: 16, 54 theta: Math.PI * 2, 55 thetaOffset: 0, 56 mergeCentroid: true, 57 mapping: mappings.concentric, 58}); 59const superellipse = Primitives.superellipse({ 60 sx: 1, 61 sy: 0.5, 62 radius: 0.5, 63 segments: 32, 64 innerSegments: 16, 65 theta: Math.PI * 2, 66 thetaOffset: 0, 67 mergeCentroid: true, 68 mapping: mappings.lamé, 69 m: 2, 70 n: 2, 71}); 72const squircle = Primitives.squircle({ 73 sx: 1, 74 sy: 1, 75 radius: 0.5, 76 segments: 128, 77 innerSegments: 16, 78 theta: Math.PI * 2, 79 thetaOffset: 0, 80 mergeCentroid: true, 81 mapping: mappings.fgSquircular, 82 squareness: 0.95, 83}); 84const annulus = Primitives.annulus({ 85 sx: 1, 86 sy: 1, 87 radius: 0.5, 88 segments: 32, 89 innerSegments: 16, 90 theta: Math.PI * 2, 91 thetaOffset: 0, 92 innerRadius: 0.25, 93 mapping: mappings.concentric, 94}); 95const reuleux = Primitives.reuleux({ 96 radius: 0.5, 97 segments: 32, 98 innerSegments: 16, 99 theta: Math.PI * 2, 100 thetaOffset: 0, 101 mergeCentroid: true, 102 mapping: mappings.concentric, 103 n: 3, 104}); 105 106const cubeGeometry = Primitives.cube({ 107 sx: 1, 108 sy: 1, 109 sz: 1, 110 nx: 1, 111 ny: 1, 112 nz: 1, 113}); 114const roundedCubeGeometry = Primitives.roundedCube({ 115 sx: 1, 116 sy: 1, 117 sz: 1, 118 nx: 1, 119 ny: 1, 120 nz: 1, 121 radius: 0.25, 122 roundSegments: 8, 123 edgeSegments: 1, 124}); 125 126const sphereGeometry = Primitives.sphere({ 127 radius: 0.5, 128 nx: 32, 129 ny: 16, 130 theta: Math.PI, 131 thetaOffset: 0, 132 phi: Math.PI * 2, 133 phiOffset: 0, 134}); 135const icosphereGeometry = Primitives.icosphere({ 136 radius: 0.5, 137 subdivisions: 2, 138}); 139const ellipsoidGeometry = Primitives.ellipsoid({ 140 radius: 1, 141 nx: 32, 142 ny: 16, 143 rx: 0.5, 144 ry: 0.25, 145 rz: 0.25, 146 theta: Math.PI, 147 thetaOffset: 0, 148 phi: Math.PI * 2, 149 phiOffset: 0, 150}); 151 152const cylinderGeometry = Primitives.cylinder({ 153 height: 1, 154 radius: 0.25, 155 nx: 16, 156 ny: 1, 157 radiusApex: 0.25, 158 capSegments: 1, 159 capApex: true, 160 capBase: true, 161 capBaseSegments: 1, 162 phi: Math.PI * 2, 163}); 164const coneGeometry = Primitives.cone({ 165 height: 1, 166 radius: 0.25, 167 nx: 16, 168 ny: 1, 169 capSegments: 1, 170 capBase: true, 171 theta: Math.PI * 2, 172}); 173const capsuleGeometry = Primitives.capsule({ 174 height: 0.5, 175 radius: 0.25, 176 nx: 16, 177 ny: 1, 178 roundSegments: 16, 179 theta: Math.PI * 2, 180}); 181const torusGeometry = Primitives.torus({ 182 radius: 0.4, 183 segments: 64, 184 minorRadius: 0.1, 185 minorSegments: 32, 186 theta: Math.PI * 2, 187 thetaOffset: 0, 188 phi: Math.PI * 2, 189 phiOffset: 0, 190}); 191 192const tetrahedron = Primitives.tetrahedron({ 193 radius: 0.5, 194}); 195const icosahedron = Primitives.icosahedron({ 196 radius: 0.5, 197}); 198 199// without normals/uvs 200const boxGeometry = Primitives.box({ 201 sx: 1, 202 sy: 1, 203 sz: 1, 204}); 205const circleGeometry = Primitives.circle({ 206 radius: 0.5, 207 segments: 32, 208 closed: false, 209 theta: Math.PI * 2, 210 thetaOffset: 0, 211});
Re-export all geometries, UV mappings functions and utils.
object
Geometry definition without normals and UVs.
object
Geometry definition.
Re-export all geometries, UV mappings functions and utils.
SimplicialComplex
⏏
object
SimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | AnnulusOptions | {} |
object
Kind: inner typedef of annulus
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] | function | mappings.concentric |
BasicSimplicialComplex
⏏
object
BasicSimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | BoxOptions | {} |
object
Kind: inner typedef of box
Properties
Name | Type | Default |
---|---|---|
[sx] | number | 1 |
[sy] | number | sx |
[sz] | number | sx |
SimplicialComplex
⏏
object
SimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | CapsuleOptions | {} |
object
Kind: inner typedef of capsule
Properties
Name | Type | Default |
---|---|---|
[height] | number | 0.5 |
[radius] | number | 0.25 |
[nx] | number | 16 |
[ny] | number | 1 |
[roundSegments] | number | 32 |
[phi] | number | TAU |
BasicSimplicialComplex
⏏
object
BasicSimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | CircleOptions | {} |
object
Kind: inner typedef of circle
Properties
Name | Type | Default |
---|---|---|
[radius] | number | 0.5 |
[segments] | number | 32 |
[theta] | number | TAU |
[thetaOffset] | number | 0 |
[closed] | boolean | false |
SimplicialComplex
⏏
object
SimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | ConeOptions | {} |
object
Kind: inner typedef of cone
Properties
Name | Type | Default |
---|---|---|
[height] | number | 1 |
[radius] | number | 0.25 |
[nx] | number | 16 |
[ny] | number | 1 |
[capSegments] | number | 1 |
[capBase] | boolean | true |
[phi] | number | TAU |
SimplicialComplex
⏏
object
SimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | CubeOptions | {} |
object
Kind: inner typedef of cube
Properties
Name | Type | Default |
---|---|---|
[sx] | number | 1 |
[sy] | number | sx |
[sz] | number | sx |
[nx] | number | 1 |
[ny] | number | nx |
[nz] | number | nx |
SimplicialComplex
⏏
object
SimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | CylinderOptions | {} |
object
Kind: inner typedef of cylinder
Properties
Name | Type | Default |
---|---|---|
[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 |
[phi] | number | TAU |
SimplicialComplex
⏏
object
SimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | DiscOptions | {} |
object
Kind: inner typedef of disc
Properties
Name | Type | Default |
---|---|---|
[radius] | number | 0.5 |
[segments] | number | 32 |
[innerSegments] | number | 16 |
[theta] | number | TAU |
[thetaOffset] | number | 0 |
[mergeCentroid] | boolean | true |
[mapping] | function | mappings.concentric |
SimplicialComplex
⏏
object
SimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | EllipseOptions | {} |
object
Kind: inner typedef of ellipse
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] | function | mappings.elliptical |
SimplicialComplex
⏏
object
SimplicialComplex
⏏Default to an oblate spheroid.
Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | EllipsoidOptions | {} |
object
Kind: inner typedef of ellipsoid
Properties
Name | Type | Default |
---|---|---|
[radius] | number | 0.5 |
[nx] | number | 32 |
[ny] | number | 16 |
[rx] | number | 1 |
[ry] | number | 0.5 |
[rz] | number | ry |
[theta] | number | Math.PI |
[thetaOffset] | number | 0 |
[phi] | number | TAU |
[phiOffset] | number | 0 |
SimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | IcosahedronOptions | {} |
object
Kind: inner typedef of icosahedron
Properties
Name | Type | Default |
---|---|---|
[radius] | number | 0.5 |
SimplicialComplex
⏏
object
SimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | IcosphereOptions | {} |
object
Kind: inner typedef of icosphere
Properties
Name | Type | Default |
---|---|---|
[radius] | number | 0.5 |
[subdivisions] | number | 2 |
SimplicialComplex
⏏
object
"x"
| "-x"
| "y"
| "-y"
| "z"
| "-z"
SimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | PlaneOptions | {} |
object
Kind: inner typedef of plane
Properties
Name | Type | Default |
---|---|---|
[sx] | number | 1 |
[sy] | number | sx |
[nx] | number | 1 |
[ny] | number | nx |
[direction] | PlaneDirection | "z" |
[quads] | boolean | false |
"x"
| "-x"
| "y"
| "-y"
| "z"
| "-z"
Kind: inner typedef of plane
SimplicialComplex
⏏
object
SimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | QuadOptions | {} |
object
Kind: inner typedef of quad
Properties
Name | Type | Default |
---|---|---|
[scale] | number | 0.5 |
SimplicialComplex
⏏
object
SimplicialComplex
⏏Kind: Exported function See: Parametric equations for regular and Reuleaux polygons
Param | Type | Default |
---|---|---|
[options] | ReuleuxOptions | {} |
object
Kind: inner typedef of reuleux
Properties
Name | Type | Default |
---|---|---|
[radius] | number | 0.5 |
[segments] | number | 32 |
[innerSegments] | number | 16 |
[theta] | number | TAU |
[thetaOffset] | number | 0 |
[mergeCentroid] | boolean | true |
[mapping] | function | mappings.concentric |
[n] | number | 3 |
SimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | RoundedCubeOptions | {} |
object
Kind: inner typedef of roundedCube
Properties
Name | Type | Default |
---|---|---|
[sx] | number | 1 |
[sy] | number | sx |
[sz] | number | sx |
[nx] | number | 1 |
[ny] | number | nx |
[nz] | number | nx |
[radius] | number | sx * 0.25 |
[roundSegments] | number | 8 |
[edgeSegments] | number | 1 |
SimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | RoundedCubeOptions | {} |
object
Kind: inner typedef of roundedRectangle
Properties
Name | Type | Default |
---|---|---|
[sx] | number | 1 |
[sy] | number | sx |
[nx] | number | 1 |
[ny] | number | nx |
[radius] | number | sx * 0.25 |
[roundSegments] | number | 8 |
[edgeSegments] | number | 1 |
SimplicialComplex
⏏
object
SimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | SphereOptions | {} |
object
Kind: inner typedef of sphere
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 |
SimplicialComplex
⏏
object
SimplicialComplex
⏏Fernández-Guasti squircle
Kind: Exported function See: Squircular Calculations – Chamberlain Fong
Param | Type | Default |
---|---|---|
[options] | SquircleOptions | {} |
object
Kind: inner typedef of squircle
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] | function | mappings.fgSquircular | |
[squareness] | number | 0.95 | Squareness (0 < s <= 1) |
SimplicialComplex
⏏
object
SimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | StadiumOptions | {} |
object
Kind: inner typedef of stadium
Properties
Name | Type | Default |
---|---|---|
[sx] | number | 1 |
[sy] | number | sx |
[nx] | number | 1 |
[ny] | number | nx |
[roundSegments] | number | 8 |
[edgeSegments] | number | 1 |
SimplicialComplex
⏏Lamé curve See elliptical-mapping example for a few special cases
Kind: Exported function See
Param | Type | Default |
---|---|---|
[options] | SuperellipseOptions | {} |
object
Kind: inner typedef of superellipse
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] | function | mappings.lamé |
[m] | number | 2 |
[n] | number | m |
SimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | TetrahedronOptions | {} |
object
Kind: inner typedef of tetrahedron
Properties
Name | Type | Default |
---|---|---|
[radius] | number | 0.5 |
SimplicialComplex
⏏
object
SimplicialComplex
⏏Kind: Exported function
Param | Type | Default |
---|---|---|
[options] | TorusOptions | {} |
object
Kind: inner typedef of torus
Properties
Name | Type | Default |
---|---|---|
[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 |
number
number
number
Uint8Array
| Uint16Array
| Uint32Array
Array.<number>
number
Two times PI.
Kind: static constant of utils
number
Two times PI.
Kind: static constant of utils
number
Square root of 2.
Kind: static constant of utils
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 |
Array.<number>
Normalize a vector 3.
Kind: static method of utils
Returns: Array.<number>
- Normalized vector
Param | Type | Description |
---|---|---|
v | Array.<number> | Vector 3 array |
Ensure first argument passed to the primitive functions is an object
Kind: static method of utils
Param | Type |
---|---|
...args | * |
Enforce a typed array constructor for cells
Kind: static method of utils
Param | Type |
---|---|
type | Class.<Uint8Array> | Class.<Uint16Array> | Class.<Uint32Array> |
object
Geometry definition without normals and UVs.
Kind: global typedef Properties
Name | Type |
---|---|
positions | Float32Array |
cells | Uint8Array | Uint16Array | Uint32Array |
object
Geometry definition.
Kind: global typedef Properties
Name | Type |
---|---|
positions | Float32Array |
normals | Float32Array |
uvs | Float32Array |
cells | Uint8Array | Uint16Array | Uint32Array |
See original packages used in v1:
Differences with v1:
MIT. See license file.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
8 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 6
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More