Group Group Group Group Group Group Group Group Group

ARSCNView device

#1

On page 300 in chapter 15 the user is instructed to add the following method:

func createFaceGeometry() {
    updateMessage(text: "Creating face geometry.")

    let device = sceneView.device!

    let maskGeometry = ARSCNFaceGeometry(device: device)!
    mask = Mask(geometry: maskGeometry, maskType: maskType)
}

There is an error on the let device line indicating that ARSCNView has no member named device. I checked the final version of the project and that one also does not build because of the same issue.

I am on Xcode 9.4. Thanks.

Janie

1 Like
#2

I looked into this error. This code also broke in a piece of Appleā€™s sample code. I believe the device they are referring to is the Metal system device, so I resolve this by replacing that code with:

func createFaceGeometry() {
        updateMessage(text: "Creating face geometry.")
        
        let device = MTLCreateSystemDefaultDevice()
        
        let maskGeometry = ARSCNFaceGeometry(device: device!)!
        mask = Mask(geometry: maskGeometry)
}

Please pardon the double bangs. This could be written more safely, but at least wanted to give a starting point to anyone else encountering this error while working through the book.

Janie

1 Like
#3

Hi @redqueencoder, thank you for looking into the error and providing us with an update. Glad you were able to resolve the issue.

Best,
Gina