ARCamera

ARCamera是一个相机,连接虚拟场景与现实场景的枢纽

它的API大致只需要了解即可,ARKit会默认帮我们进行配置好

API

/**
 4x4矩阵表示相机位置,同ARAnchor
 */
@property (nonatomic, readonly) matrix_float4x4 transform;

/**
相机方向(旋转)的矢量欧拉角
分别是x/y/z
 */
@property (nonatomic, readonly) vector_float3 eulerAngles;

/**
 相机追踪状态(在下方会有枚举值介绍)
 */
@property (nonatomic, readonly) ARTrackingState trackingState NS_REFINED_FOR_SWIFT;

/**
追踪运动类型
 */
@property (nonatomic, readonly) ARTrackingStateReason trackingStateReason NS_REFINED_FOR_SWIFT;

/**
相机内参矩阵
3x3矩阵
 fx 0   px
 0  fy  py
 0  0   1
 */
@property (nonatomic, readonly) matrix_float3x3 intrinsics;

/**
摄像头分辨率
 */
@property (nonatomic, readonly) CGSize imageResolution;

/**
投影矩阵
*/
@property (nonatomic, readonly) matrix_float4x4 projectionMatrix;

/**
创建相机投影矩阵
 */
- (matrix_float4x4)projectionMatrixWithViewportSize:(CGSize)viewportSize orientation:(UIInterfaceOrientation)orientation zNear:(CGFloat)zNear zFar:(CGFloat)zFar;

@end

//相机追踪状态枚举
typedef NS_ENUM(NSInteger, ARTrackingState) {

    /** 不被允许 */
    ARTrackingStateNotAvailable,

    /** 被限制 限值原因ARTrackingStateReason */
    ARTrackingStateLimited,

    /** 正常. */
    ARTrackingStateNormal,
} NS_REFINED_FOR_SWIFT;

/**
 追踪运动类型
 */
API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(macos, watchos, tvos)
typedef NS_ENUM(NSInteger, ARTrackingStateReason) {
    /** 无. */
    ARTrackingStateReasonNone,
    
    /** 初始化追踪 */
    ARTrackingStateReasonInitializing,

    /** 过度运动. */
    ARTrackingStateReasonExcessiveMotion,

    /** 未找到可见特征 缺少纹理 */
    ARTrackingStateReasonInsufficientFeatures,
} NS_REFINED_FOR_SWIFT;