1.1.5 • Published 2 years ago

unified-3d-loader v1.1.5

Weekly downloads
7
License
MIT
Repository
github
Last release
2 years ago

Unified 3D Loader

status npm tests issues last commit

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

NameExtensionStatusThreeJS LoaderCura ReaderSpecificationSpecification ComplianceComment
3D Manufacturing Format.3mf✔️3MFLoader3MFReader3MF.io~70%Does not support print tickets or many other OPC features. Always recalculates normals.
Additive Manufacturing Format.amf✔️AMFLoaderAMFReaderISO/ASTM 52915:2020~99%Does not specifically extract model name metadata (This can be extracted from the metadata mesh property). Always recalculates normals.
Stanford Triangle Format.ply✔️PLYLoaderTrimeshReaderGamma Research Group (University of North Carolina)~100%Supports non-triangular, planar polygons. Always recalculates normals.
Wavefront OBJ Format.obj✔️OBJLoader2N/AWikipedia~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✔️STLLoaderN/AWikipedia100%Never recalculates normals (Always uses user-supplied instead).

Example

//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();