UNPKG

stlfiletools

Version:

Basic tools to create a 3d model in a STL file for 3d printing.Maps a function which takes a position and returns a height onto a rectangle or sphere.eg model generated from perlin noise.

18 lines (11 loc) 459 B
const stl = require('./main.js'); var test = new stl.STLfile("test.stl","test"); var soMatix = [[2,1,0],[-1,3,0],[0,0,4]]; //User defined function which returns value based on position function cosGrath(x,y){ return Math.cos(Math.sqrt(((x-50)/10)*((x-50)/10) + ((y-50)/10) * ((y-50)/10))); } var offset = new stl.cord(0,0,15); test.RectMeshFromFunction(0.1,100,100,1,cosGrath,offset,5); test.MatrixMult(soMatix); test.CreateSTLfile();