Do you have an example of adding a component to a ModelSortGroup and then setting the order?
something like:
let myGroup = ModelSortGroup(depthPass: ModelSortGroup.DepthPass.postPass)
let mySort = ModelSortGroupComponent(group: myGroup, order: 2)
How do I setup the group to let the sort order know what components to reference when I set the order?
Post
Replies
Boosts
Views
Activity
Hello! Sorry for the late response -
Here is a repo with the usdz file
This file was exported from Blender 4.0 Alpha USD branch with the default export settings for materials.
Nice! Getting closer - however now my animation does not start paused when it is loaded, and the animation.speed toggle stops working if I allow the animation to play all the way through. Am I instantiating the AnimationPlaybackController class correctly?
import RealityKit
import RealityKitContent
struct ModelView: View {
var isPlaying: Bool
@State private var scene: Entity? = nil
@State private var animationController: AnimationPlaybackController? = nil
@State private var playerDefinition: AnimationDefinition?
@State private var playerResource: AnimationResource? = nil
var body: some View {
RealityView { content in
// Specify the name of the Entity you want
scene = try? await Entity(named: "TestAsset", in: realityKitContentBundle)
scene!.generateCollisionShapes(recursive: true)
scene!.components.set(InputTargetComponent())
content.add(scene!)
playerDefinition = scene?.availableAnimations[0].definition
playerDefinition?.repeatMode = .none
playerResource = try! AnimationResource.generate(with: playerDefinition!)
animationController = scene!.playAnimation(playerResource!, startsPaused: true)
} .installGestures()
.onChange(of: isPlaying) {
animationController?.speed = isPlaying ? -1.0 : 1.0
}
}
}