1.0.1 • Published 10 years ago
refine-mesh v1.0.1
refine-mesh
Iterative mesh refinement based on the technique in
- M. Botsch, L. Kobbelt. 2004 "A Remeshing Approach to Multiresolution Modeling" EUROGRAPHICS 2004
Give this some garbage mesh as input and it will automagically give you a nice uniformly subdivided mesh.
Example
var refine = require('refine-mesh')
var bunny = require('bunny')
var normals = require('normals').vertexNormals(bunny.cells, bunny.positions)
//Refine the bunny from a base mesh to one with a uniform edge length of 0.1
var refined = refine(
bunny.cells,
bunny.positions,
normals,
{
edgeLength: 0.1
})So, a coarse bunny mesh like this:
Becomes a fine mesh like this:
Install
npm i refine-meshAPI
var mesh = require('refine-mesh')(cells, positions, normals[,options])
Applies iterative mesh refinement to a cell complex
cellsis an array of triples representing the faces of the meshpositionsis an array of[x,y,z]triples representing the verticesnormalsis an array of[nx,ny,nz]triples representing the normalsoptionsis an object with the following properties:edgeLengthis the desired edge length (default is median edge length)maxItersis the maximum number of iterations (default5)splitItersmaximum number of edge split iterations (default10)collapseItersmaximum number of edge collapse iterations (default10)flipItersmaximum number of edge flip iterations (default10)smoothItersmaximum number of smoothing iterations (default20)smoothRateconstant controlling rate of smoothing (default0.95)minSplitminimum number of splits per iteration (default0)minCollapseminimum number of collapse operations (default0)minFlipminimum number of flip operations (default0)minSmoothminimum smoothing improvement (default0.01*edgeLength)
Returns An object with the following properties
cellsthe faces of the resulting meshpositionsvertex positions of resultnormalsvertex normals of result
License
(c) 2015 Mikola Lysenko. MIT License