I am trying to play a specific skeletal animation on my 3D object (loaded from a USDZ file). The animation file is also in format of USDZ.
I tried the following:
Entity.loadAsync(contentsOf: Bundle.main.url(forResource: "Character", withExtension: "usdz")!)
.append(Entity.loadAsync(contentsOf: Bundle.main.url(forResource: "Animation", withExtension: "usdz")!))
.collect()
.sink(receiveCompletion: {
if case .failure(let error) = $0 {
print(error)
}
}, receiveValue: { data in
let character = data[0]
self.anchorEntity?.addChild(character)
DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
let animationEntity = data[1]
animationEntity.transform.matrix = character.transform.matrix
if let animation = animationEntity.availableAnimations.first {
character.playAnimation(animation, startsPaused: false)
}
}
})
.store(in: &self.cancellables)
I am seeing these in the console:
[Animation] Invalid bind path: Ann_Body_anim_Neutral.RootNode.root.Root_M_bnd.Spine1_M_bnd.Spine2_M_bnd.Spine3_M_bnd.Chest_M_bnd.Scapula_R_bnd.Shoulder_R_bnd.Elbow_R_bnd.Transform.transform
[Animation] Invalid bind path: Ann_Body_anim_Neutral.RootNode.root.Root_M_bnd.Spine1_M_bnd.Spine2_M_bnd.Spine3_M_bnd.Chest_M_bnd.Scapula_R_bnd.Shoulder_R_bnd.ShoulderPart1_R_bnd.Transform.transform
[Animation] Invalid bind path: Ann_Body_anim_Neutral.RootNode.root.Root_M_bnd.Spine1_M_bnd.Spine2_M_bnd.Spine3_M_bnd.Chest_M_bnd.Scapula_R_bnd.Shoulder_R_bnd.ShoulderPart2_R_bnd.Transform.transform
...
It seems that the transform is different between the animation file joints/nodes and the character ones.
Is there any way to fix this in code? If not, how I can make it work?
I am receiving the animation as FBX
file and then I am converting it into gtlf
using the fbx2gltf
tool, then I am converting the gltf
into usdz
using usdzconvert
.
let task = Process()
task.executableURL = Self.fbx2gltfBinURL
task.arguments = [
"-i",
url.path,
"-o",
temporaryURL.path,
"-b",
"--blend-shape-normals",
"--blend-shape-tangents",
"--fbx-temp-dir",
temporaryDirectory.path,
]
try task.run()