JsClipper | Original : http : //sourceforge.net/projects/jsclipper
kandi X-RAY | JsClipper Summary
kandi X-RAY | JsClipper Summary
a javascript library to perform boolean operations (union, difference etc…) between two svg paths. online demo : 5.0.2.1 - 12 january 2013 * update: clipper library updated to version 5.0.2. the area algorithm has been updated and is faster. checkinputs parameter of the offsetpolygons function has been renamed autofix. * added: clipperlib.clean(), which removes too near vertices to avoid micro-self-intersection-artifacts when offsetting. * added: clipperlib.lighten(), which reduces count of vertices using perpendicular distance reduction algorithm. * added: clipperlib.clone(), which make true clone of polygons. several updates to the main demo: * added: clean, simplify, lighten buttons * change: custom polygons: input boxes to textareas to
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of JsClipper
JsClipper Key Features
JsClipper Examples and Code Snippets
Community Discussions
Trending Discussions on JsClipper
QUESTION
I try to display geometry which is constructed by constructpath commands like moveto lineto beziercurveto in Three.js. Therefore I create a THREE.ShapePath(); and execute the command toShapes(isClockwise). After this I use THREE.ExtrudeBufferGeometry to create the 3D shape.
Unfortunately the shapes are sometimes really complex and are not created correctly which means they are distorted.
Using libtess as triangulation library solves some issues. But I have still distorted geometry.
Now I want to use jsclipper to simplify the shapes prior triangulation.
I modified three.js in such way:
in the method addShape in ExtrudeBufferGeometry I have added:
...ANSWER
Answered 2019-Mar-20 at 06:53A bit hard to figure out what the problem is actually. Clipper (also when using SimplifyPolygons or SimplifyPolygon) can only produce weakly-simple polygons, which means that there can be pseudo-duplicate points: although sequential coordinates are quaranteed to be not indentical, some of the next points can share the same coordinate. Also a coordinate can be on the line between two points.
After simplifying (or any other boolean operation) you could make a cleaning step using Offsetting with a small negative value: https://sourceforge.net/p/jsclipper/wiki/documentation/#clipperlibclipperoffsetexecute.
This possibly removes all of the pseudo-duplicate points.
I have made also a float version of Clipper (http://jsclipper.sourceforge.net/6.4.2.2_fpoint/). It is extensively tested, but because Angus Johnson, the author of the original C# Clipper (of which JS-version is ported from), has thought that using floats causes robustness problems although according to my tests the are no such, the original C# float version does not exists. The float version is simpler to use and you can try there a small negative offset: eg. -0.001 or -0.01.
You could also give a try to PolyTree or ExPolygons (https://sourceforge.net/p/jsclipper/wiki/ExPolygons%20and%20PolyTree%206/). ExPolygons can be used to get holes and contours and PolyTree can be used to get the full parent-child-relationship of holes and contours.
The last resort is a broken-pen-nib -function. It detects all pseudo-duplicate points and make a broken-pen-nib -effect to them, so that the result is free of any duplicates. The attached images shows what this effect means using large nib-effect-value to make the effect meaning clearer. Three.js polygon triangulation fails in pseudo duplicate points. There are a discussion https://github.com/mrdoob/three.js/issues/3386 of this subject.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install JsClipper
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page