# gltf-lib

> gltf model & functions for nodejs.

Latest version **1.0.3** (published 2023-08-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install gltf-lib
pnpm add gltf-lib
yarn add gltf-lib
bun add gltf-lib
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2023-08-09 |
| First published | 2023-08-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 32.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | batuZ |
| Maintainers | batu_z |
| Keywords | glTF |

## Links

- npm: https://www.npmjs.com/package/gltf-lib
- Repository: https://github.com/batuZ/gltf-lib
- npm.io page: https://npm.io/package/gltf-lib

## Dependencies (1)

- [mathjs](https://npm.io/package/mathjs.md) ^11.9.1

## Recent versions

- 1.0.3 (latest) — 2023-08-09
- 1.0.2 — 2023-08-09
- 1.0.1 — 2023-08-09

## README

# gltf-lib
 gltf model & functions for nodejs.


```js
const { GLTF, Asset, PrimitiveHelper } = require('./gltfLib')
const gltf = new GLTF(new Asset())

const vectors = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]]
const normals = [[0, 0, 1], [0, 0, 1], [0, 0, 1], [0, 0, 1]]
const indices = [0, 1, 3, 2, 3, 1]

// top
let top = new PrimitiveHelper({ vectors, indices, normals })
top.offset([0, 0, 1])
top.color = Array(4).fill([0, 0.5, 1])
gltf.referenceGeometry(top, "sub_bin")
top.destroy()

// bottom
let bottom = new PrimitiveHelper({ vectors, indices, normals })
bottom.rotation([[0, 1, 0], [1, 0, 0], [0, 0, -1]])
bottom.color = Array(4).fill([1, 1, 0.5])
gltf.referenceGeometry(bottom, "sub_bin")
bottom.destroy()

// east
let east = new PrimitiveHelper({ vectors, indices, normals })
east.offset([0, 0, 1])
east.rotation([[0, 1, 0], [0, 0, 1], [1, 0, 0]])
east.color = Array(4).fill([1, 0.5, 0.5])
gltf.referenceGeometry(east, "sub_bin")
east.destroy()

// west
let west = new PrimitiveHelper({ vectors, indices, normals })
west.rotation([[0, -1, 0], [0, 0, 1], [-1, 0, 0]])
west.offset([0, 1, 0])
west.color = Array(4).fill([0.4, 0.8, 0.2])
gltf.referenceGeometry(west, "sub_bin")
west.destroy()

// north
let north = new PrimitiveHelper({ vectors, indices, normals })
north.rotation([[-1, 0, 0], [0, 0, 1], [0, 1, 0]])
north.offset([1, 1, 0])
north.color = Array(4).fill([1, 0.8, 1])
gltf.referenceGeometry(north, "sub_bin")
north.destroy()

// south
let south = new PrimitiveHelper({ vectors, indices, normals })
south.rotation([[1, 0, 0], [0, 0, 1], [0, -1, 0]])
south.color = Array(4).fill([0.4, 1, 1])
gltf.referenceGeometry(south, "sub_bin")
south.destroy()


// gltf
gltf.zup()
gltf.axis(6) // axis helper
gltf.save('test_output/test1.gltf')
gltf.destroy()

```

---
_Source: https://npm.io/package/gltf-lib · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
