OpenJSCAD.org: v2: hangs when using extrudeRotate, polygon and union
I have a minimal code to reproduce the issue.
const { primitives, booleans, extrusions } = require('@jscad/modeling');
const { union } = booleans;
const { extrudeRotate } = extrusions;
const { polygon, cylinder } = primitives;
module.exports.main = () => {
const points = [
[0, 0],
[10, 0],
[10, 5],
[0, 5]
]
const p = extrudeRotate({}, polygon({ points }));
const c = cylinder({radius: 2, height: 20} );
// return [p, c];
return union(p, c)
}
without the union(return them in an array), it renders like this:
Expected Behavior
It should render properly (looks the same as the version without union)
Actual Behavior
It hanges forever and cpu usage is high.
The issue actually happens for all boolean operation on the object returns from extrudeRotate
Steps to Reproduce the Problem
-
download the reproduce file reproduce.js.zip
-
unzip it and drag it into v2 website: https://www.jscad.xyz/
-
you will see that it doesn’t render.
-
replace
return union(p, c)
withreturn [p, c]
, it renders properly.
Specifications
- Version: v2
- Platform: mac
- Environment: browser Chrome Version 86.0.4240.80
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 21 (10 by maintainers)
@crysislinux there’s a new pull request for the fixes. here’s the result from the original example.
I tested several different variations of 2D shapes that start from X=0, as well as shapes that overlap the X axis (-/+). And actually discovered another issue. 🐛
You’ll see these fixes in the next ALPHA release, sometime next week. Or you can pull the branch with the fix and use locally.
And thanks all for the great discussion and examples. Those small tidbits of information excellerated the development.
For now, make sure the 2D shape has X > 0. It can be a very small X.
The above example works if the X > 0.0001
See the discussion on Issue #696 I’m working on some changes now to snap, to triangulate, and to manifold 3D geometries.
UG… Here’s what’s happening.
In the normal case, the ‘walls’ between previous and current slices are created as ‘triangles’. All fine when the slices have unique edges (no overlap).
But in this special case, the slices actually have overlapping edges. This makes ‘trangles’ that also overlap.
And of course, those boolean functions will die a horible death.
Definitely an issue with the top / bottom polygons as there are duplicated polygons. Here’s the polygons from the top.
Now that I know the issue, a fix is probably possible.