Search code examples
swiftscenekitarkitrealitykitaranchor

ARPlaneAnchor's 'extent' property deprecated


I'm using ARKit to build an AR app with SceneKit. When I was creating an SCNPlane object when SceneKit detected a horizontal plane using ARPlaneAnchor's extent of x and y properties I ran into this warning:

// *'extent' was deprecated in iOS 16*

My sample code is below:

let planeAnchor = anchor as! ARPlaneAnchor

let plane = SCNPlane(width: CGFloat(planeAnchor.extent.x), 
                    height: CGFloat(planeAnchor.extent.z))

How can I work around this?


Solution

  • Use planeExtent property instead, with width, height & rotationOnYAxis sub-properties.

    @available(iOS 16.0, *)
    open var planeExtent: ARPlaneExtent { get }
    

    In iOS 16.0 and higher, extend property is deprecated:

    @available(iOS, introduced: 11.0, deprecated: 16.0)
    open var extent: simd_float3 { get }