# unified-3d-loader

> Unified 3D file loader. Intended for use as a frontend for triangle-based 3D processing.

Latest version **1.1.5** (published 2022-04-06) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install unified-3d-loader
pnpm add unified-3d-loader
yarn add unified-3d-loader
bun add unified-3d-loader
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.5 |
| Published | 2022-04-06 |
| First published | 2020-08-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 5 |
| Unpacked size | 1.4 MB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Cloud-CNC |
| Maintainers | cloud-cnc-bot |
| Keywords | 3mf, amf, ply, obj, stl, file, loader, parser, cloud-cnc |

## Links

- npm: https://www.npmjs.com/package/unified-3d-loader
- Repository: https://github.com/Cloud-CNC/unified-3d-loader
- Homepage: https://github.com/Cloud-CNC/unified-3d-loader#readme
- Issues: https://github.com/Cloud-CNC/unified-3d-loader/issues
- npm.io page: https://npm.io/package/unified-3d-loader

## Dependencies (5)

- [jszip](https://npm.io/package/jszip.md) ^3.5.0
- [earcut](https://npm.io/package/earcut.md) ^2.2.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.20
- [mathjs](https://npm.io/package/mathjs.md) ^7.2.0
- [fast-xml-parser](https://npm.io/package/fast-xml-parser.md) ^3.17.4

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.1.5 (latest) — 2022-04-06
- 1.1.4 — 2020-11-25
- 1.1.3 — 2020-10-14
- 1.1.2 — 2020-10-13
- 1.1.2-beta.0 — 2020-09-13
- 1.1.1-beta.0 — 2020-09-13
- 1.1.0-beta.0 — 2020-09-13
- 1.0.0-beta.1 — 2020-09-10
- 1.0.0-beta.0 — 2020-08-15

## README

# Unified 3D Loader
![status](https://img.shields.io/badge/status-release-brightgreen)
[![npm](https://img.shields.io/npm/v/unified-3d-loader)](https://npmjs.com/package/unified-3d-loader)
[![tests](https://img.shields.io/github/workflow/status/Cloud-CNC/unified-3d-loader/Tests?label=tests)](https://github.com/Cloud-CNC/unified-3d-loader/actions)
[![issues](https://img.shields.io/github/issues/Cloud-CNC/unified-3d-loader)](https://github.com/Cloud-CNC/unified-3d-loader/issues)
[![last commit](https://img.shields.io/github/last-commit/Cloud-CNC/unified-3d-loader)](https://github.com/Cloud-CNC/unified-3d-loader/commits/master)

A 3D file loader designed to produce consistent mesh data regardless of file format. Intended for use as a front-end for triangle-based 3D processing.

## Features
* Get indexed or non-indexed (raw) vertices and normals regardless of input format
* Support for many files associated with CNC machine workflows
* Written in modern TypeScript
* Thoroughly commented

## Documentation
### File Formats
Name | Extension | Status | ThreeJS Loader | Cura Reader | Specification | Specification Compliance | Comment
--- | --- | --- | --- | --- | --- | --- | ---
3D Manufacturing Format | `.3mf` | ✔️ | [3MFLoader](https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/3MFLoader.js) | [3MFReader](https://github.com/Ultimaker/Cura/tree/master/plugins/3MFReader) | [3MF.io](https://3mf.io/specification/) | ~70% | Does not support print tickets or many other [OPC](https://en.wikipedia.org/wiki/Open_Packaging_Conventions) features. Always recalculates normals.
Additive Manufacturing Format | `.amf` | ✔️ | [AMFLoader](https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/AMFLoader.js) | [AMFReader](https://github.com/Ultimaker/Cura/blob/master/plugins/AMFReader/AMFReader.py) | [ISO/ASTM 52915:2020](https://www.iso.org/standard/74640.html) | ~99% | Does not specifically extract model name metadata (This can be extracted from the metadata mesh property). Always recalculates normals.
Stanford Triangle Format | `.ply` | ✔️ | [PLYLoader](https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/PLYLoader.js) | [TrimeshReader](https://github.com/Ultimaker/Cura/blob/master/plugins/TrimeshReader/TrimeshReader.py) | [Gamma Research Group (University of North Carolina)](https://gamma.cs.unc.edu/POWERPLANT/papers/ply.pdf) | ~100% | Supports non-triangular, planar polygons. Always recalculates normals.
Wavefront OBJ Format | `.obj` | ✔️ | [OBJLoader2](https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/OBJLoader2.js) | N/A | [Wikipedia](http://paulbourke.net/dataformats/obj/) | ~30% | Supports non-triangular, planar polygons. Does not support complex geometries (Basis Matrixes, Beizer/NURBS/Cardinal/Taylor surfaces and/or curves). Always recalculates normals.
Stereolithography Format | `.stl` | ✔️ | [STLLoader](https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/STLLoader.js) | N/A | [Wikipedia](https://en.wikipedia.org/wiki/STL_(file_format)#ASCII_STLs) | 100% | Never recalculates normals (Always uses user-supplied instead).

### Example
```Javascript
//Imports
import {FileFormats, Unified3dLoader} from 'unified-3d-loader';

const main = async () =>
{
  //Instantiate a new loader
  const loader = new Unified3dLoader();

  //Progress logger (Ranges from 0 to 100)
  loader.on('progress', percent =>
  {
    console.log(`Progress: ${percent}%`);
  });

  //Load a file (in indexed mode)
  const indexedObjects = await loader.load(/* <ArrayBuffer> */, FileFormats.STL);

  console.log(indexedObjects);
  /**
   * name: 'Cube',
   * normals: {
   *  indices: number[]
   *  vectors: number[]
   * },
   * vertices: {
   *  indices: number[]
   *  vectors: number[]
   * }
   */

  //Load a file (in non-indexed mode)
  const nonIndexedObjects = await loader.load(/* <ArrayBuffer> */, FileFormats.STL, false);

  console.log(nonIndexedObjects);
  /**
   * name: 'Cube',
   * normals: number[],
   * vertices: number[]
   */
};

main();
```

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