Initializer

init(anchor:)

Initializes a new anchor by copying custom information from another anchor.

Required.

Declaration

init(anchor: ARAnchor)

Parameters

anchor

The other anchor from which to copy information.

Discussion

Each time ARKit generates a new ARFrame object (corresponding to an incoming frame of live camera video at 60 fps), ARKit calls this initializer to copy each of the anchors associated with the previous frame.

If you subclass ARAnchor to add extra properties, your implementation of this initializer should copy the values of those properties, then chain to the superclass initializer. For example, an AR game might define a BoardAnchor class to encode the position and size of a game board, so its version of this initializer would copy that size property:

required init(anchor: ARAnchor) {
    let other = anchor as! BoardAnchor
    self.size = other.size
    super.init(anchor: other)
}