making the arkit camera vertical rather than horizontal

后端 未结 2 413
死守一世寂寞
死守一世寂寞 2021-01-15 19:04

I am trying to make an app where the user enters some text in a textfield and then the app displays this text in front of the ar camera to the user. I positioned the text co

相关标签:
2条回答
  • 2021-01-15 19:15

    If you mean that you don't want the orientation of the device to change along with the rotation, then:

    Go to Project > General > Deployment Info
    

    Under device orientation, uncheck all boxes except 'Portrait'.

    If this does not solve your problem and what you really want is to fix the euler angles of your text node, let me know, I'll be happy to help.

    0 讨论(0)
  • 2021-01-15 19:24

    You cannot use the matrix identity for any orientation, it has to be rotated depending on device orientation. I have a function in my apps that I call to update that before I perform the matrix multiplication :

    var translation = matrix_identity_float4x4
    
    func updateTranslationMatrix() {
    
        switch UIDevice.current.orientation{
        case .portrait, .portraitUpsideDown, .unknown, .faceDown, .faceUp:
            print("portrait ")
            translation.columns.0.x = -cos(.pi/2)
            translation.columns.0.y = sin(.pi/2)
            translation.columns.1.x = -sin(.pi/2)
            translation.columns.1.y = -cos(.pi/2)
        case .landscapeLeft :
            print("landscape left")
            translation.columns.0.x = 1
            translation.columns.0.y = 0
            translation.columns.1.x = 0
            translation.columns.1.y = 1
        case .landscapeRight :
            print("landscape right")
            translation.columns.0.x = cos(.pi)
            translation.columns.0.y = -sin(.pi)
            translation.columns.1.x = sin(.pi)
            translation.columns.1.y = cos(.pi)
        }
        translation.columns.3.z = -0.6 //60cm in front of the camera
    }
    
    0 讨论(0)
提交回复
热议问题