Anyone know how to change the zFar or ARKIT ARCamera? Or get the current value of it.
I have a very large model thats being clipped. I think. In blender I had same issue and fixed it by setting far value on Frustum.
I can create a projection matrix for each camera frame but cant set it.
func session(_ session: ARSession, cameraDidChangeTrackingState camera: ARCamera) {
textManager.showTrackingQualityInfo(for: camera.trackingState, autoHide: true)
let projectionMatrix: matrix_float4x4 = camera.projectionMatrix(withViewportSize: camera.viewport.size,
orientation: .portrait,
zNear: 0.1,
zFar: 5000)
//ERROR - readonly
camera.projectionMatrix = matrix_float4x4
...
ARCamera
has nothing do to with rendering your 3D virtual content. As its docs say, it's just "information about the camera position and imaging characteristics for a captured video frame in an AR session." That is, it provides data that helps you set up whatever technology you're using to render (be that SceneKit, a custom renderer using Metal, etc).The
camera.projectionMatrix(...)
method is part of that information-providing role — it uses what ARKit knows about the orientation of your physical device camera, plus the zNear and zFar values you provide, to construct a matrix you can use in your renderer.If you're using SceneKit, you can pass that matrix to
SCNCamera
. (You probably need to convert fromsimd_float4x4
toSCNMatrix4
.) If you're using some other renderer, you can use that matrix there.