Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SCNShape with bezier path

I am tying to draw a 3d line in Scenekit iOS, i am trying below code to draw line,

func path() -> UIBezierPath
    {
        var bPath = UIBezierPath()
        bPath.moveToPoint(CGPointMake(0, 0))
        bPath.addLineToPoint(CGPointMake(10, 10))
        bPath.addLineToPoint(CGPointMake(5, 5))
        bPath.closePath()
        return bPath
    }

and the below code is to load the line in SCNNode,

let sap = SCNShape()
    sap.path = path()
    let carbonNode = SCNNode(geometry: sap)
    carbonNode.position = SCNVector3Make(0, 0, 15)
    scene.rootNode.addChildNode(carbonNode)

But, i am getting blank screen.

like image 510
user2781412 Avatar asked Aug 31 '25 16:08

user2781412


2 Answers

try changing your geometry's materials. You might have a white object on a white background.

edit: it also turns out that the vertices of your triangle are colinear. You thus end up with a degenerate triangle.

like image 139
mnuages Avatar answered Sep 02 '25 15:09

mnuages


Your path has no surface area since you start at (0,0), draw a line to (10, 10) and then a second line to (5,5) which is already on the line between (0,0) and (10, 10). Then you close the path by drawing another line to (0,0).

Changing either of the three points creates a path with a surface area.

Also, the z-axis points out of the screen. This means that depending on where your camera is positioned, you may be placing the carbonNode behind the camera. If instead you meant to position it further into the scene you should likely use a negative z value.

like image 41
David Rönnqvist Avatar answered Sep 02 '25 17:09

David Rönnqvist