Apress / Mastering-ARKit

source code
Other
9 stars 5 forks source link

Chapter 16 : Section Incorporating RealityKit Animoji in ArView - Steps needed to load "Face.rcproject" properly. #8

Closed erikuecke closed 2 years ago

erikuecke commented 2 years ago

Hello Fellow Readers! If your in the starter projects and getting warnings about Face not existing. Here are the steps need to make it work.

Step 1 Click on Face.rcproject file In the Inspector Menu on the right side under “Target Membership”, make sure “FaceTracking” is checked or else Xcode will not see the “Face” reality composer project

Step 2 After clicking on Face.rcproject Click “Open in Reality Composer Button” In reality composer rename Scene to “StealHead” or if you don’t like the typo “SteelHead”

Step 3 In reality composer you may see a warning indicator in the top right menu and when tapped will tell you that objects used in scene are not downloaded. Tap download all so that you can see the tophat, pool balls, and banana.

Step 4 In reality composer don't foreget to save before exiting.

These step should allow you to load the prebuilt Face scene and then load objects from scene.

jayvenn commented 2 years ago

@erikuecke Thanks for pointing this out.

Changes made to Chapter 16's starter project:

  1. Included Face.rcproject in FaceTracking target membership.
  2. Updated Face.rcproject's box with steel head identifier.
  3. Added isPlayingEyebrowsAnimation to ViewController.swift.

Note to readers

The following code:

// MARK: - Initializers
required init?(coder: NSCoder) {
  guard let smileyFace = try? Face.loadSteelHead(),
    let leftEyeEntity = smileyFace.findEntity(named: "leftEye"),
    let rightEyeEntity = smileyFace.findEntity(named: "rightEye"),
    let mouthEntity = smileyFace.findEntity(named: "mouth") else {
    fatalError("Unable to load completely load Face.Smiley components.")
  }
  mouthEntityTransformOrigin = mouthEntity.transform
  self.smileyFace = smileyFace
  self.leftEyeEntity = leftEyeEntity
  self.rightEyeEntity = rightEyeEntity
  self.mouthEntity = mouthEntity
  super.init(coder: coder)
}

Should be:

required init?(coder: NSCoder) {
  guard let smileyFace = try? Face.loadSteelHead(),
    let leftEyeEntity = smileyFace.findEntity(named: "leftEye"),
    let rightEyeEntity = smileyFace.findEntity(named: "rightEye"),
    let mouthEntity = smileyFace.findEntity(named: "mouth") else {
    fatalError("Unable to load completely load Face.Smiley components.")
  }
  mouthEntityTransformOrigin = mouthEntity.transform
  self.steelHead = smileyFace
  self.leftEyeEntity = leftEyeEntity
  self.rightEyeEntity = rightEyeEntity
  self.mouthEntity = mouthEntity
  super.init(coder: coder)
}

And the following sentences:

Next, you'll do something similar but for the eyebrows. Add the following code to the end of updateSmileyFace(from:):

Should be:

Next, you'll do something similar but for the eyebrows. Add the following code to the end of updateSteelHead(from:):