JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q40534F
  • License MIT

quadratic error mesh decimation. simplified interface for npm mesh-simplifier - use simple triangles instead of Three.js geometry.

Package Exports

  • simplify-triangles
  • simplify-triangles/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (simplify-triangles) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

simplify-triangles

quadratic error mesh decimation.

simplified interface for mesh-simplifier - use simple triangles instead of Three.js geometry.

similar to mesh-simplify but based on mesh-simplifier because it is much faster.

all are based on or influenced by this code by sp4cerat.

Installation

npm i simplify-triangles

Usage

var fs = require("fs");
var stl = require("stl");
var st = require('simplify-triangles');

//each triangle has format [ [x,y,z], [x,y,z], [x,y,z] ]

//load triangles from stl file
var triangles = stl.toObject(fs.readFileSync('./skull.stl')).facets.map(f=>f.verts);

//simplify the triangle mesh, result will have 0.125x as many triangles
//format is same as input
var simplifiedTriangles = st.simplify(triangles,0.125); 

//optional - view the result with ascii-raytracer
var config = {
    triangles: simplifiedTriangles, 
    cameraPos: [45.82,22.11,61.08],
    cameraRot: [1.87,-2.25],
    aspectRatio: 4/3,
    screenShotDir: "/Users/user/Desktop/"
}
require('ascii-raytracer').runScene(config);

skull-before original skull-after simplified

See Also

stonks