ARKit – 为什么没有 'ARPlaneDetection' Enum 了?
ARKit – Why there's no 'ARPlaneDetection' Enum anymore?
为什么 Apple 的软件工程师确实删除了 ARPlaneDetection
enum 并制作了 ARWorldTrackingConfiguration.PlaneDetection
struct?
是:
public enum ARPlaneDetection: UInt {
case .none
case .horizontal
}
现在:
public struct PlaneDetection: OptionSet {
public init(rawValue: UInt)
public var horizontal: ARWorldTrackingConfiguration.PlaneDetection { get }
public var vertical: ARWorldTrackingConfiguration.PlaneDetection { get }
}
新的 PlaneDetection
struct 比 ARKit 中过时的 ARPlaneDetection
enum 有什么优势?
这一切都是因为PlaneDetection
结构符合OptionSet
协议,它允许你为一些设置设置多个选项,比如这个平面检测
let options: ARWorldTrackingConfiguration.PlaneDetection = [.horizontal, .vertical]
let options: ARWorldTrackingConfiguration.PlaneDetection = []
...这是 OptionSet
的优势,仅使用枚举是不可能的。
为什么 Apple 的软件工程师确实删除了 ARPlaneDetection
enum 并制作了 ARWorldTrackingConfiguration.PlaneDetection
struct?
是:
public enum ARPlaneDetection: UInt {
case .none
case .horizontal
}
现在:
public struct PlaneDetection: OptionSet {
public init(rawValue: UInt)
public var horizontal: ARWorldTrackingConfiguration.PlaneDetection { get }
public var vertical: ARWorldTrackingConfiguration.PlaneDetection { get }
}
新的 PlaneDetection
struct 比 ARKit 中过时的 ARPlaneDetection
enum 有什么优势?
这一切都是因为PlaneDetection
结构符合OptionSet
协议,它允许你为一些设置设置多个选项,比如这个平面检测
let options: ARWorldTrackingConfiguration.PlaneDetection = [.horizontal, .vertical]
let options: ARWorldTrackingConfiguration.PlaneDetection = []
...这是 OptionSet
的优势,仅使用枚举是不可能的。