microsoft / microsoft/maker.js

Unexpected behaviour for combineSubtraction

Open
#377 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2k
Forks
302
Avg merge
21h 28m
Merged PRs (30d)
5

Description

Loving this project so far - I'm planning on using this for my CNC-designs going forward. In order to do that I will need to understand the library, and I'm currently struggling with the combine methods. I'm trying to "cut out" a part from another part. but not all paths are removed.

See the example below. I'm trying to cut out one corner from the box, but the only paths that are removed are the ones from the corner, not from the box itself. Those two paths (ShapeLine2 & ShapeLine3 on the 'box') are instead split into two paths each..

I would have expected to end up with an "L" shaped model below. What am I doing wrong?

var makerjs = require('makerjs');

var lShape = {
  models : {
    toprightcorner: makerjs.model.move(new makerjs.models.Rectangle(50, 50), [50, 50]),
    box: new makerjs.models.Rectangle(100, 100)
  }
};

makerjs.model.combineSubtraction(lShape.models.box, lShape.models.toprightcorner);

var svg = makerjs.exporter.toSVG(lShape);

document.write(svg);

Thankful for any feedback.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the combineSubtraction entry point and reproduce the supplied Rectangle example before inspecting how the box and corner paths are processed. Compare the generated SVG with the expected L-shaped model; done means the corner is removed from the box without leaving the box paths split incorrectly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.