I'm building an ARKit app using SceneKit. I have a 3D model in a
.dae
file that has 3 SCNMorpher targets (namely blendShapes). They are all attributes of a node called rightEyeBrow
.The .dae file was exported from Blender. I opened the .dae file using a text editor and replaced "instance_geometry" entry with "instance_controller" for this node. If you would like to know why I did that please check out this post.
Here's a list of morph targets as viewed on Xcode's SceneKit editor.
I can list the array of targets of the node simply by printing them to the console line.
print(rightEyeBrow.morpher?.targets)
What I need to do now is to set a certain weight to one of the morpher's targets:
rightEyeBrow.morpher?.setWeight(browInnerUp, forTargetNamed: "browInnerUp"
For some reason this approach doesn't work. It appears XCode can't find targets named "browDownRight", "browOuterUpRight" and "browInnerUp". However, they are listed in the array of targets at index 0, 1 and 2. For instance, I can easily do it this way:
rightEyeBrow.morpher?.setWeight(browInnerUp, forTargetAt: 2)
This works, but when there are lots of morpher targets it gets really confusing to reach them by their index. Would anybody know why reaching the target by it's name doesn't work?
Note: When I try to reach the target by its name, it doesn't work, but doesn't throw any kind of error. A similar question was asked here.