swift - cannot invoke initializer (ARKit) -
trying follow tutorial here https://www.youtube.com/watch?v=tgpv_crf2ha&feature=youtu.be&t=272
but getting following compile error on line
let cubenode = scnnode(geometry:...
cannot invoke initializer type 'scnbox' argument list of type '(width: double, height: double, chamferradius: int)'
import uikit import arkit import scenekit class viewcontroller: uiviewcontroller { @iboutlet weak var sceneview: arscnview! override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. let configuration = arworldtrackingsessionconfiguration() configuration.planedetection = .horizontal sceneview.session.run(configuration) } @ibaction func addcube(_ sender: any) { let cubenode = scnnode(geometry: scnbox(width:0.1, height:0.1, chamferradius:0)) cubenode.position = scnvector3(0,0,-0.2)//this in metres sceneview.scene.rootnode.addchildnode(cubenode) } @ibaction func addcup(_ sender: any) { } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } }
according apple documentation, constructor scnbox object has 4 parameters:
init(width: cgfloat, height: cgfloat, length: cgfloat, chamferradius: cgfloat)
so need add lenght parameter constructor, see api reference:
https://developer.apple.com/documentation/scenekit/scnbox
perhaps better approach make constant of object before using in constructor scnnode , use intellisense:
let box = scnbox(width:0.1, height:0.1,lenght: 0.1, chamferradius:0) let cubenode = scnnode(geometry: box)
Comments
Post a Comment