JSPM

primitive-sphere

3.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2139
  • Score
    100M100P100Q112930F
  • License MIT

a sphere mesh with normals, texture coordinates and indices

Package Exports

  • primitive-sphere

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (primitive-sphere) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

primitive-sphere

stable

screen

(demo)

A minimal UV sphere geometry for 3D rendering, including normals, UVs and cell indices. The algorithm has been adapted from BabylonJS.

Example

var radius = 1
var mesh = require('primitive-sphere')(radius, {
  segments: 16
})

// the simplicial complex
console.log(mesh.positions, mesh.cells)

// rendering attributes
console.log(mesh.uvs)
console.log(mesh.normals)

Usage

NPM

mesh = sphere(radius, [opt])

Creates a new UV sphere mesh with the given radius (default 1) and options:

  • segments number of segments to use, defaults to 32

The returned mesh is an object with the following data:

{
  positions: [ [x, y, z], [x, y, z], ... ],
  cells: [ [a, b, c], [a, b, c], ... ],
  uvs: [ [u, v], [u, v], ... ],
  normals: [ [x, y, z], [x, y, z], ... ]
}

See Also

License

MIT, see LICENSE.md for details.