├── .gitignore
├── .npmignore
├── LICENSE.md
├── README.md
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | bower_components
2 | node_modules
3 | *.log
4 | .DS_Store
5 | bundle.js
6 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | bower_components
2 | node_modules
3 | *.log
4 | .DS_Store
5 | bundle.js
6 | test
7 | test.js
8 | demo/
9 | .npmignore
10 | LICENSE.md
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | Copyright (c) 2015 glo-js
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
20 | OR OTHER DEALINGS IN THE SOFTWARE.
21 |
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # mesh-primitives
2 |
3 | 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.
4 |
5 | [
](http://glo-js.github.io/primitive-torus/)
6 |
7 | ## modules
8 |
9 | - [primitive-sphere](https://www.npmjs.com/package/primitive-sphere)
10 | - [primitive-icosphere](https://www.npmjs.com/package/primitive-icosphere)
11 | - [primitive-torus](https://www.npmjs.com/package/primitive-torus)
12 | - [primitive-quad](https://www.npmjs.com/package/primitive-quad)
13 | - [primitive-cube](https://www.npmjs.com/package/primitive-cube)
14 |
15 | ## format
16 |
17 | 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.
18 |
19 | They provide indexed meshes with counter-clockwise triangles. The returned object has the following structure:
20 |
21 | ```
22 | {
23 | positions: [ [x, y, z], [x, y, z], ... ],
24 | cells: [ [a, b, c], [a, b, c], ... ],
25 | uvs: [ [u, v], [u, v], ... ],
26 | normals: [ [x, y, z], [x, y, z], ... ]
27 | }
28 | ```
29 |
30 | # generic mesh modules
31 |
32 | ##### a.k.a. "simplicial complexes"
33 |
34 | 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"**.
35 |
36 | ```
37 | {
38 | positions: [ [x, y, z], [x, y, z], ... ], // n-dimensional
39 | cells: [ [a, b, c], [a, b, c], ... ] // optional
40 | }
41 | ```
42 |
43 | 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.
44 |
45 | Examples:
46 |
47 | - [icosphere](https://www.npmjs.com/package/icosphere)
48 | - [sphere-mesh](https://www.npmjs.com/package/sphere-mesh)
49 | - [cube-mesh](https://www.npmjs.com/package/cube-mesh)
50 | - [bunny](https://www.npmjs.com/package/bunny)
51 | - [snowden](https://www.npmjs.com/package/snowden)
52 | - [geo-piecering](https://www.npmjs.com/package/geo-piecering)
53 | - [geo-arc](https://www.npmjs.com/package/geo-arc)
54 | - [geo-asterisk](https://www.npmjs.com/package/geo-asterisk)
55 | - [svg-mesh-3d](https://www.npmjs.com/package/svg-mesh-3d)
56 |
57 | ## manipulation
58 |
59 | There are dozens of modules for manipulating these data structures on npm, such as:
60 |
61 | - [mesh-combine](https://github.com/hughsk/mesh-combine)
62 | - [merge-vertices](https://github.com/thibauts/merge-vertices/blob/master/index.js)
63 | - [remove-degenerate-cells](https://github.com/thibauts/remove-degenerate-cells)
64 | - [normals](https://github.com/mikolalysenko/normals)
65 | - [convex-hull](https://www.npmjs.com/package/convex-hull)
66 | - [cdt2d](https://www.npmjs.com/package/cdt2d)
67 | - [simplify-path](https://www.npmjs.com/package/simplify-path)
68 |
69 | For a larger list of modules, see [stack.gl/packages](http://stack.gl/packages/#hughsk/icosphere) under the "Geometry" heading.
70 |
71 | ## rendering
72 |
73 | There are a variety of modules to facilitate rendering of these 2D and 3D mesh modules.
74 |
75 | #### Canvas2D
76 |
77 | - [draw-triangles-2d](https://www.npmjs.com/package/draw-triangles-2d)
78 |
79 | #### ThreeJS
80 |
81 | - [three-simplicial-complex](https://github.com/Jam3/three-simplicial-complex)
82 |
83 | #### stackgl
84 |
85 | - [mesh-viewer](https://www.npmjs.com/package/mesh-viewer)
86 | - [gl-geometry](https://www.npmjs.com/package/gl-geometry)
87 |
88 | ## License
89 |
90 | MIT, see [LICENSE.md](http://github.com/glo-js/mesh-primitives/blob/master/LICENSE.md) for details.
91 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "mesh-primitives",
3 | "version": "1.0.3",
4 | "description": "a short list of some mesh and primitive modules",
5 | "main": "index.js",
6 | "license": "MIT",
7 | "author": {
8 | "name": "Matt DesLauriers",
9 | "email": "dave.des@gmail.com",
10 | "url": "https://github.com/mattdesl"
11 | },
12 | "dependencies": {},
13 | "devDependencies": {},
14 | "scripts": {
15 | "test": "node test.js"
16 | },
17 | "keywords": [
18 | "mesh",
19 | "primitive",
20 | "glo-js",
21 | "glo",
22 | "stackgl",
23 | "meshes",
24 | "geom",
25 | "geometries",
26 | "geometrty",
27 | "simplicial",
28 | "complex",
29 | "complexes"
30 | ],
31 | "repository": {
32 | "type": "git",
33 | "url": "git://github.com/glo-js/mesh-primitives.git"
34 | },
35 | "homepage": "https://github.com/glo-js/mesh-primitives",
36 | "bugs": {
37 | "url": "https://github.com/glo-js/mesh-primitives/issues"
38 | }
39 | }
40 |
--------------------------------------------------------------------------------