Code Monkey home page Code Monkey logo

unified-3d-loader's Introduction

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

Name Extension Status ThreeJS Loader Cura Reader Specification Specification Compliance Comment
3D Manufacturing Format .3mf ✔️ 3MFLoader 3MFReader 3MF.io ~70% Does not support print tickets or many other OPC features. Always recalculates normals.
Additive Manufacturing Format .amf ✔️ AMFLoader AMFReader ISO/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 ✔️ PLYLoader TrimeshReader Gamma Research Group (University of North Carolina) ~100% Supports non-triangular, planar polygons. Always recalculates normals.
Wavefront OBJ Format .obj ✔️ OBJLoader2 N/A Wikipedia ~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 N/A Wikipedia 100% 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();

unified-3d-loader's People

Contributors

wakeful-cloud avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.