What is the type of SCNVector3 components? CGFloat or Float?

前端 未结 1 1925
天涯浪人
天涯浪人 2021-01-14 05:13

The apple documentation gives the declaration of SCNVector3 :

typedef struct SCNVector3 { CGFloat x, y , z; } SCNVector3;

Or whe

相关标签:
1条回答
  • 2021-01-14 05:34

    In the iOS 8.1 SDK headers, the SCNVectorX types are based on Float, as can be seen by command-clicking on SCNVector3:

    struct SCNVector3 {
        var x: Float
        var y: Float
        var z: Float
    }
    
    func SCNVector3Make(x: Float, y: Float, z: Float) -> SCNVector3
    

    This is different from the OS X 10.10 SDK where CGFloat is used. So the documentation seems to be wrong. The following compiles in an iOS project:

    func * (left: SCNVector3, right: Float) -> SCNVector3 {
        return SCNVector3Make(left.x * right, left.y * right, left.z * right)
    }
    
    0 讨论(0)
提交回复
热议问题