Skip to content

[WIP] an icosphere mesh with normals, texture coordinates and indices

License

Notifications You must be signed in to change notification settings

Erkaman/primitive-icosphere

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

primitive-icosphere

stable

demo

(demo)

A minimal icosphere geometry for 3D rendering, including normals, UVs and cell indices.

This uses icosphere under the hood, but includes some routines to reduce texture seams. However, at certain angles and subdivisions, the seams will still be visible.

The UV seam fixes have been adapted from UV Mapping a Sphere.

Example

var radius = 1
var mesh = require('primitive-icosphere')(radius, {
  subdivisions: 3
})

// 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 icosphere mesh with the given radius (default 1) and options:

  • subdivisions number of subdivisions, defaults to 2. Determines the mesh quality (recommended between 0 and 5)

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], ... ]
}

License

MIT, see LICENSE.md for details.

About

[WIP] an icosphere mesh with normals, texture coordinates and indices

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 94.5%
  • HTML 5.5%