14

I'm adding multiple transparent SCNShape objects to an ARSCNSceneView scene.

  • These shapes are based on user input and should overlap.
  • They are all flat shapes made with UIBezierPath on the same plane
  • Shapes has to be transparent, so the user can see the camera input behind

The problem is that overlapping shapes are very visible, and I'd like it to show as a single shape - the union of all shapes.

Failed approaches:

  • Putting it under same node and use parent opacity.
  • Merging the UIBezier paths.
  • Blend modes
  • Transparency modes
  • Drawing using primitive triangles instead of UIBezierPath

Wanted vs current results

Avishay Cohen
  • 2,418
  • 1
  • 22
  • 40
  • 1
    Not an exact duplicate, but pretty close. There's an article reference here that might help,you. https://stackoverflow.com/questions/19178360/creating-a-union-of-2-bezier-paths – David Berry Aug 20 '17 at 15:22

1 Answers1

3

You could have a look at VectorBoolean which is a swift library to deal with boolean operations like the union you are looking for. I haven't tried it myself but have heard some good things about it.

Fortia
  • 146
  • 3
  • 1
    Awesome. Union works as expected and it's very easy to use. You simply call `path.fb_union(other)` to get them merged with no overlapping. Unlike native `path.append(other)` behavior. I'll pull request that repo to add podspec. – Avishay Cohen Aug 27 '17 at 09:01
  • 1
    Until pull request approved, you may use the pod from my fork `pod 'VectorBoolean', :git => 'https://github.com/avishic/Swift-VectorBoolean.git'` – Avishay Cohen Aug 29 '17 at 15:47
  • Having some issues with VectorBoolean - on some cases it removes the whole path / create unwanted holes in the union. – Avishay Cohen Sep 10 '17 at 07:31