swiftscenekitios11xcode9-betaarkit

Cannot convert value of type 'SCNMatrix4' to expected argument type 'matrix_float4x4' (aka 'simd_float4x4')


I got this error while using iOS 11 ARKit(Scenekit - Xcode 9 beta) when i try to set the simdPosition of virtual object. I need to know if it is possible to convert SCNMatrix4 to matrix_float4x4 in swift. If so how to convert it.


Solution

  • With iOS SDK 11, you can use initializers to convert between SCNMatrix4 and simd_float4x4.

    import SceneKit
    
    var mat4 = SCNMatrix4()
    
    let f4x4 = simd_float4x4(mat4)
    
    mat4 = SCNMatrix4(f4x4)