# @matthewcpp/binary-gltf

> "Simple library to parse chunks from a binary gltf file"

Latest version **0.2.0** (published 2022-02-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install @matthewcpp/binary-gltf
pnpm add @matthewcpp/binary-gltf
yarn add @matthewcpp/binary-gltf
bun add @matthewcpp/binary-gltf
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2022-02-27 |
| First published | 2021-06-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Matthew LaRocca |
| Maintainers | matthewcpp |
| Keywords | gltf, glb |

## Links

- npm: https://www.npmjs.com/package/@matthewcpp/binary-gltf
- Repository: https://github.com/matthewcpp/parse-binary-gltf
- Homepage: https://github.com/matthewcpp/binary-gltf#readme
- Issues: https://github.com/matthewcpp/binary-gltf/issues
- npm.io page: https://npm.io/package/@matthewcpp/binary-gltf

## Recent versions

- 0.2.0 (latest) — 2022-02-27
- 0.1.0 — 2021-06-09

## README

# binary-gltf
Simpe library for working with binary glTF files.

The library exposes a single `parse` method that takes an `ArrayBuffer` of a GLB file and returns an object with the following structure:
```
{
    json: Object,
    binary: DataView,
    extras: [
        {
            type: number,
            view: DataView
        }
    ]
}
```

If any error is encountered during parsing, an exception will be thrown.

### Usage

Example use in browser (rollup):

```javascript
import {BinaryGltf} from "@matthewcpp/binary-gltf";

try {
    const response = await fetch(url);
    const buffer = await response.arrayBuffer();
    const binaryGltf = BinaryGltf.parse(buffer);
} catch (e) {
    console.log(e.toString());
}
```

Example use in NodeJS:

```javascript
const { BinaryGltf } = require("@matthewcpp/binary-gltf");
const fs = require("fs");

try {
    const data = fs.readFileSync(filePath);
    const binaryGltf = BinaryGltf.parse(data.buffer);
} catch (e) {
    console.log(e.toString());
}
```

### Testing
1. Build the library by running `npm run build`
1. Test Browser usage: `npm run test-web`
1. Test NodeJs usage: `npm run test-node`

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