Is it possible to replace the model from one ModelEntity onto another ModelEntity without breaking the animations?
I have a ModelEntity object that I would like to apply animations to, but this ModelEntity is dynamically generated without animations. (baseEntity)
So for each animation, I load an individual usdz with using ModelEntity.loadModel (animEntity). I add the animEntity as a child to their parentEntity. Then I add the materials from the baseEntity onto the animEntity.
animEntity.model?.materials = baseMaterials
parentEntity.addChild(animEntity, preservingWorldTransform: false)
This does work, but causes texture / model issues, due to the baseEntity having a completely different mesh than the animEntity.
Is there a better way to accomplish this?
Other implementations I have tried:
animEntity.model?.mesh = MeshResource.generate(from: baseModel.mesh.contents)
animEntity.model!.mesh.replace(with: baseEntity.model!.mesh.contents)
animEntity.model?.mesh.replaceAsync(with: baseModel.mesh.contents)
animEntity.components[ModelComponent.self] = baseEntity.components[ModelComponent.self]