SceneKit 中的子类 SCNReferenceNode

Subclass SCNReferenceNode within SceneKit

Swift5.5,iOS15

我想子类化 SCNReferenceNode,但这样做后我收到了这个错误消息?我在这里做错了什么?下面的代码编译...

class CustomRNode: SCNReferenceNode {
    var tip:Tip!
    var x: Double!
    var y: Double!
    var tag: String!

    init(tip:Tip, x:Double!, y:Double!, tag:String, url: URL) {
        super.init(url: url)!
        self.tip = tip
        self.x = x
        self.y = y
        self.tag = tag
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

但是当我尝试使用它时...

let gameURL = Bundle.main.url(forResource: "GameModel", withExtension: "scn")
let gameReferenceNode = CustomRNode(url: gameURL)

我收到错误消息?

// Cannot convert value of type 'URL?' to expected argument type 'NSCoder'. 

您需要提供初始化参数值:

let refNode = CustomRNode(tip: tip, x: 0.12, y: 0.25, tag: "ref_01", url: url)

...或使用便利的初始值设定项:

class CustomRNode: SCNReferenceNode {
    var tip: String!
    var x: Double!
    var y: Double!
    var tag: String!

    convenience init(tip:String!, x:Double!, y:Double!, tag:String, url:URL) {
        self.init(url: url)!
        self.tip = tip
        self.x = x
        self.y = y
        self.tag = tag
    }
}

let gameURL = Bundle.main.url(forResource: "GameModel", withExtension: "usdz")!
let refNode = CustomRNode(url: gameURL)

(refNode?.referenceURL)!                    // file:///<folder>/<folder>...