Skip to content

Commit

Permalink
fix default JS parameter binding for simplify (#1146)
Browse files Browse the repository at this point in the history
fix default parameter binding
  • Loading branch information
elalish authored Feb 16, 2025
1 parent a857f00 commit c149dd5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bindings/wasm/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ EMSCRIPTEN_BINDINGS(whatever) {
.function("numVert", &CrossSection::NumVert)
.function("numContour", &CrossSection::NumContour)
.function("_Bounds", &CrossSection::Bounds)
.function("simplify", &CrossSection::Simplify)
.function("_Simplify", &CrossSection::Simplify)
.function("_Offset", &cross_js::Offset)
.function("_ToPolygons", &CrossSection::ToPolygons)
.function("hull",
Expand Down
4 changes: 4 additions & 0 deletions bindings/wasm/bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ Module.setup = function() {
delta, joinTypeToInt(joinType), miterLimit, circularSegments);
};

Module.CrossSection.prototype.simplify = function(epsilon = 1e-6) {
return this._Simplify(epsilon);
};

Module.CrossSection.prototype.extrude = function(
height, nDivisions = 0, twistDegrees = 0.0, scaleTop = [1.0, 1.0],
center = false) {
Expand Down
6 changes: 6 additions & 0 deletions bindings/wasm/examples/bindings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ suite('CrossSection Bindings', () => {
expect(cs.numContour()).toEqual(1);
expect(cs.area()).to.be.greaterThan(0);
});

test('simplify argument is defaulted', () => {
const cs = manifoldModule.CrossSection.circle(1).simplify();
expect(cs.numContour()).toEqual(1);
expect(cs.area()).to.be.greaterThan(0);
});
});

0 comments on commit c149dd5

Please sign in to comment.