https://github.com/dmnsgn/geom-export-obj
Convert one (or more) simplicial complex geometry (positions/cells/normals/uvs) into an OBJ string.
https://github.com/dmnsgn/geom-export-obj
exporter geometry obj simplicial-complex wavefront wavefront-obj
Last synced: 12 months ago
JSON representation
Convert one (or more) simplicial complex geometry (positions/cells/normals/uvs) into an OBJ string.
- Host: GitHub
- URL: https://github.com/dmnsgn/geom-export-obj
- Owner: dmnsgn
- License: mit
- Created: 2021-04-07T20:17:43.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-07-07T14:46:39.000Z (over 1 year ago)
- Last Synced: 2025-01-09T21:37:14.600Z (about 1 year ago)
- Topics: exporter, geometry, obj, simplicial-complex, wavefront, wavefront-obj
- Language: JavaScript
- Homepage: https://dmnsgn.github.io/geom-export-obj/
- Size: 832 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# geom-export-obj
[](https://www.npmjs.com/package/geom-export-obj)
[](https://www.npmjs.com/package/geom-export-obj)
[](https://bundlephobia.com/package/geom-export-obj)
[](https://github.com/dmnsgn/geom-export-obj/blob/main/package.json)
[](https://github.com/microsoft/TypeScript)
[](https://conventionalcommits.org)
[](https://github.com/prettier/prettier)
[](https://github.com/eslint/eslint)
[](https://github.com/dmnsgn/geom-export-obj/blob/main/LICENSE.md)
Convert one (or more) simplicial complex geometry (positions/cells/normals/uvs) into an OBJ string.
[](https://paypal.me/dmnsgn)
[](https://commerce.coinbase.com/checkout/56cbdf28-e323-48d8-9c98-7019e72c97f3)
[](https://twitter.com/dmnsgn)

## Installation
```bash
npm install geom-export-obj
```
## Usage
```js
import geomExportObj from "geom-export-obj";
import { cube } from "primitive-geometry";
console.log(geomExportObj(cube()).output);
```
## API
## Modules
## Typedefs
-
SimplicialComplex :object -
Geometry definition. All optional.
-
GeomExportObjOffsets :object -
Offsets to for cells. Useful if appending to another obj string. Used internally.
-
GeomExportObjOptions :object -
Options for exporter.
-
GeomExportObjReturnValue :object
## geomExportObj
- [geomExportObj](#module_geomExportObj)
- [geomExportObj(geometries, [options])](#exp_module_geomExportObj--geomExportObj) ⇒ [GeomExportObjReturnValue](#GeomExportObjReturnValue) ⏏
- [.parse(geometry, [offsets], [defaultName])](#module_geomExportObj--geomExportObj.parse) ⇒ string
### geomExportObj(geometries, [options]) ⇒ [GeomExportObjReturnValue](#GeomExportObjReturnValue) ⏏
Parse one or more simplicial complex geometry and return an obj string and vertices offsets.
**Kind**: Exported function
| Param | Type | Default |
| ---------- | -------------------------------------------------------------------------------------------------------------------------- | --------------- |
| geometries | [SimplicialComplex](#SimplicialComplex) \| [Array.<SimplicialComplex>](#SimplicialComplex) | |
| [options] | [GeomExportObjOptions](#GeomExportObjOptions) | {} |
#### geomExportObj.parse(geometry, [offsets], [defaultName]) ⇒ string
Parse a simplicial complex and return an obj string
**Kind**: static method of [geomExportObj](#exp_module_geomExportObj--geomExportObj)
**See**: http://paulbourke.net/dataformats/obj/
| Param | Type | Default | Description |
| ------------- | ---------------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------------- |
| geometry | [SimplicialComplex](#SimplicialComplex) | | |
| [offsets] | [GeomExportObjOffsets](#GeomExportObjOffsets) | { positions: 0, normals: 0, uvs: 0 }} | |
| [defaultName] | string | | A name for the object if geometry.name is not specified. |
## SimplicialComplex : object
Geometry definition. All optional.
**Kind**: global typedef
**Properties**
| Name | Type | Description |
| -------------- | --------------------------------- | ------------------------- |
| positions | Array.<number> | |
| normals | Array.<number> | |
| uvs | Array.<number> | |
| cells | Array.<number> | |
| name | string | The object name. |
| [materialName] | string | The object material name. |
## GeomExportObjOffsets : object
Offsets to for cells. Useful if appending to another obj string. Used internally.
**Kind**: global typedef
**Properties**
| Name | Type |
| --------- | ------------------- |
| positions | number |
| normals | number |
| uvs | number |
## GeomExportObjOptions : object
Options for exporter.
**Kind**: global typedef
**Properties**
| Name | Type | Default | Description |
| --------- | ---------------------------------------------------------- | ------------------------------------------------- | ----------------------------------- |
| [header] | string | "# geom-export-obj\\n" | Header to be prepended to the file. |
| [prefix] | string | "Mesh\_" | Prefix for object names. |
| [offsets] | [GeomExportObjOffsets](#GeomExportObjOffsets) | { positions: 0, normals: 0, uvs: 0 } | The initial offsets for cells. |
## GeomExportObjReturnValue : object
**Kind**: global typedef
**Properties**
| Name | Type | Description |
| ------- | ---------------------------------------------------------- | -------------------- |
| output | string | The obj as a string. |
| offsets | [GeomExportObjOffsets](#GeomExportObjOffsets) | |
## License
MIT. See [license file](https://github.com/dmnsgn/geom-export-obj/blob/main/LICENSE.md).