
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
org.webjars.npm:github-com-mattdesl-svg-mesh-3d
Advanced tools
](http://mattdesl.github.io/svg-mesh-3d/)
A high-level module to convert a SVG <path> string into a 3D triangulated mesh. Best suited for silhouettes, like font icon SVGs.
Built on top of cdt2d by @mikolalysenko, and various other modules.
npm install svg-mesh-3d --save
Here is an example using a simple path:
var svgMesh3d = require('svg-mesh-3d')
var path = 'M305.214,374.779c2.463,0,3.45,0.493...'
var mesh = svgMesh3d(path)
The returned mesh is a 3D indexed "simplicial complex" that can be used in ThreeJS, StackGL, etc. It uses arrays for vectors and follows the format:
{
positions: [ [x1, y1, z1], [x2, y2, z2], ... ],
cells: [ [a, b, c], [d, e, f] ]
}
Or, to load a mesh in the browser from an SVG file:
var loadSvg = require('load-svg')
var parsePath = require('extract-svg-path').parse
var svgMesh3d = require('svg-mesh-3d')
loadSvg('svg/logo.svg', function (err, svg) {
if (err) throw err
var svgPath = parsePath(svg)
var mesh = svgMesh3d(svgPath, {
delaunay: false,
scale: 4
})
})
Source:
To run the demos from source:
git clone https://github.com/mattdesl/svg-mesh-3d.git
cd svg-mesh-3d
# install dependencies
npm install
# ThreeJS demo
npm run start
# Canvas2D demo
npm run 2d
mesh = svgMesh3d(svgPath, [opt])Triangulates the svgPath string into a 3D simplicial complex. The positions in the 3D mesh are normalized to a -1.0 ... 1.0 range.
Options:
delaunay (default true)
clean (default true)
simplify (default 0)
scale (default 1)
normalize (default true) a boolean, whether to normalize the positions to -1 .. 1randomization (default 0)
Other options are passed to cdt2d, such as exterior (default false) and interior (default true).
<path> data from SVGMIT, see LICENSE.md for details.
FAQs
WebJar for svg-mesh-3d
We found that org.webjars.npm:github-com-mattdesl-svg-mesh-3d demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.