mesh-primitives

1.0.3 • Public • Published

mesh-primitives

In this context a "mesh primitive" is a plain JavaScript object which approximates a renderable 2D or 3D mesh. It is not tied to any larger frameworks or engines.

modules

format

The primitive-* modules are tailored for rendering purposes (lighting, texturing, etc) and are typically used in prototypes and demos. Often, they are often not numerically robust.

They provide indexed meshes with counter-clockwise triangles. The returned object has the following structure:

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

generic mesh modules

a.k.a. "simplicial complexes"

There are a number of other generalized mesh modules on npm. Some of them are numerically robust. These general purpose meshes are often referred to as "simplicial complexes".

{
  positions: [ [x, y, z], [x, y, z], ... ], // n-dimensional
  cells: [ [a, b, c], [a, b, c], ... ]      // optional
}

The positions are not always indexed, and may not provide uvs or normals. They don't always represent 2D or 3D meshes, and the winding order might not always be consistent.

Examples:

manipulation

There are dozens of modules for manipulating these data structures on npm, such as:

For a larger list of modules, see stack.gl/packages under the "Geometry" heading.

rendering

There are a variety of modules to facilitate rendering of these 2D and 3D mesh modules.

Canvas2D

ThreeJS

stackgl

License

MIT, see LICENSE.md for details.

Dependents (0)

Package Sidebar

Install

npm i mesh-primitives

Weekly Downloads

1

Version

1.0.3

License

MIT

Last publish

Collaborators

  • mattdesl