Convert Scene's (x, y) to screen's (x, y)

后端 未结 1 1004
一向
一向 2021-01-17 01:41

I have an application built with SceneKit that is currently displaying several nodes. I can figure out which node is pressed and want to use that to make a label appear belo

相关标签:
1条回答
  • 2021-01-17 02:22

    You can use the projectPoint: method:

    var projected = view.projectPoint(result.node.position))   
    //projected is an SCNVector3
    //projected.x and y are the node's position in screen coordinates
    //projected.z is its depth relative to the near and far clipping planes
    nameLabel.center = CGPointMake(CGFloat(projected.x), CGFloat(projected.y+20)
    
    0 讨论(0)
提交回复
热议问题