Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing an arc with SCNShape and UIBezierPath

I am trying to draw a piece of pie in SCNShape using the following code:

UIBezierPath *piePiece = [UIBezierPath bezierPath];
[piePiece addArcWithCenter: CGPointZero radius:  0.150 startAngle: 0.0 endAngle: M_PI/6  clockwise: YES];
[piePiece closePath];
SCNShape *pieShape = [SCNShape shapeWithPath: piePiece extrusionDepth: 0];
pieShape.firstMaterial.diffuse.contents = [UIColor blueColor];
pieShape.firstMaterial.doubleSided = YES;
SCNNode *pieNode = [SCNNode nodeWithGeometry: pieShape];

But I get the following shape:

Sample I don't see the arc. What am I doing wrong?

Thanks

like image 936
Alex Avatar asked Oct 29 '22 00:10

Alex


1 Answers

You must change the flatness of the UIBezierPath to a lower value. In Swift:

pieShape.flatness = 0.0003
like image 97
Enno Maurice Avatar answered Nov 15 '22 05:11

Enno Maurice