init(_ path: String)
{
super.init()
self.name = "modelEy"
var cancellable: AnyCancellable? = nil
cancellable = Entity.loadAsync(contentsOf: URL(fileURLWithPath: path))
.sink(receiveCompletion: { error in
DispatchQueue.main.async {
cancellable?.cancel()
cancellable = nil
}
}, receiveValue: { [weak self] ey in
guard let `self` = self else { return }
ey.name = "animationEy"
self.addChild(ey)
let entityBounds = ey.visualBounds(relativeTo: ey.parent)
let extents: SIMD3<Float> = [entityBounds.extents.x, entityBounds.extents.y, entityBounds.extents.z]
self.collision = CollisionComponent(shapes: [ShapeResource.generateBox(size: extents).offsetBy(translation: entityBounds.center)])
DispatchQueue.main.async {
cancellable?.cancel()
cancellable = nil
}
})
}
ey.availableAnimations.forEach {
if #available(iOS 15.0, *)
{
ey.playAnimation($0.repeat())
}
}
The animation does not play. Skeletal animation!