I've added some of my sample test app code below.
From what I understand, I already have the OrbitAnimation startTransform parameter for my starshipEntity setup correctly based on my Reality Composer Pro (RCP) package that includes the transform component definition for my starship entity (see attached screenshot below for the transform component from RCP). Since I already have my starship and Earth entity defined in my RCP package that I import (i.e. import Starship), I don't believe I need to define the sphere or yAxis property, and my startTransform parameter can just be starshipEntity.transform. I took this code approach based on the WWDC23 session "Build Spatial Experiences with RealityKit" (https://developer.apple.com/wwdc23/10080).
In your example code, you show a translation parameter to the Transform struct. Are you saying there is a translation that needs to be set that is beyond what I already have in the RCP Transform component for my starship entity? If so, I don't understand why and I didn't see something like that needed for the moon entity in the WWDC23 session I reference above. A translation parameter is not mentioned in the above referenced WWDC23 session.
Also, can you confirm that I can do the OrbitAnimation directly in the RealityView content closure and that I don't have to put OrbitAnimation in an update: closure?
import SwiftUI
import RealityKit
import Starship
struct ImmersiveView: View {
@Environment(\.dismissImmersiveSpace) var dismissImmersiveSpace
@Environment(\.dismissWindow) var dismissWindow
@Environment(\.openWindow) var openWindow
var body: some View {
RealityView { content, attachments in
//Get Earth model from createEarthModel() function
let earthEntity = await createEarthModel()
//Get Starship model from createStarshipModel() function
let starshipEntity = await createStarshipModel()
//Add to RealityView
content.add(starshipEntity)
content.add(earthEntity)
//Playing an orbit transform animation
let orbit = OrbitAnimation(name: "Orbit",
duration: 30,
axis: [0, 1, 0],
startTransform: starshipEntity.transform,
bindTarget: .transform,
repeatMode: .repeat)
if let animation = try? AnimationResource.generate(with: orbit) {
starshipEntity.playAnimation(animation)
}
}
}
}