Fetch SVG + mesh

node v14.20.1
version: 2.0.0
endpointsharetweet
const fetch = require("fetch").fetchUrl const parsePath = require("extract-svg-path").parse; const svgMesh3d = require("svg-mesh-3d"); fetch("https://stcitiespublic.blob.core.windows.net/assets/icons/svg/bench.svg", function(error, meta, body){ const svg = body.toString() console.log({ svg }); const svgPath = parsePath(svg); console.log({ svgPath }); const mesh = svgMesh3d(svgPath, { // delaunay: false, scale: 1, simplify: 1, // clean: false, // simplify: 0, // normalize: false, // randomization: 0, }); console.log({ mesh }) const flippedMesh = { positions: mesh.positions.map(([x, y, z]) => [x, y * -1, z]), cells: mesh.cells, }; console.log(JSON.stringify(flippedMesh)) })
Loading…

no comments

    sign in to comment