Post

Replies

Boosts

Views

Activity

Reply to Can’t Figure Out How to Get My Earth Entity to Rotate on its Axis
I’d appreciate if you can provide some more information about systems. I’ve watched the WWDC session that shows a slide trying to relate entities components and systems. However, I still don’t really understand the relationship and when systems are used. Maybe your explanation can help me better understand that, and the relationships with entities and components and also help others. Also, can you explain what you mean by my app’s initializer code? Can you explain that in terms of my feedback sample test project code in the cross referencedDeveloper forum post that I provided previously and linked you to. I need to understand it in terms of my actual code in my sample test app because I don’t know what you mean by my app’s initializer code. I don’t understand that context. Finally, can you explain why I need to use a system versus an entity animation like I previously did for an orbit animation. I’m trying to work everything by defining them in Reality Composer Pro as entities with transform components, but I don’t understand why this has to be treated separately as a system and what is the point of registering that system. It seems inconsistent in the use of RealityKit entities and how we animate certain things. For instance, animating an orbit of entities seems was handled differently than doing a rotation of an earth entity. Orbit animation was basically handled through animation with a play animation method. Yet this earth rotation approach that you show here seems not to be an animation, but some other type of method for the Earth to rotate. It doesn’t make sense to me why the orbit of an entity is handled differently than a rotation of an entity. Any further explanation you can give to try to explain why this system is like this would be appreciated.
Topic: Spatial Computing SubTopic: General Tags:
Jul ’24
Reply to Can't Get OrbitAnimation() to work on my project
Thanks for the advice. In my code I actually didn't need to create the starship or earth entities because I already had them fully defined in Reality Composer Pro. I just added the orientToPath: true parameter and that kept the starship at the same orientation throughout the orbit path. Also, I fixed the orbit plane problem by resetting the Earth (parent) transform component, rotation z value to 0, instead of 23. Now the starship orbits the earth on a level tilt around the earth. Once last thing (I hope, :)) how would I have the earth (parent) entity rotate CCW underneath the orbiting starship child? I tried adding the following code block to the RealityView but it is not working: if let rotatingEarth = starshipEntity.findEntity(named: "Earth") { rotatingEarth.transform.rotation = simd_quatf.init(angle: 360, axis: SIMD3(x: 0, y: 1, z: 0)) if let animation = try? AnimationResource.generate(with: rotatingEarth as! AnimationDefinition) { rotatingEarth.playAnimation(animation) } } Any advice on getting the earth to rotate? I tried reviewing the Hello World WWDC23 project code, but I was unable to understand the complexity and how that sample project got the earth to rotate.
Topic: Spatial Computing SubTopic: General Tags:
Jul ’24
Reply to Can't Get OrbitAnimation() to work on my project
I have some progress but still need help. I needed to make a new scene in RCP where the starship is a child to the Earth. The OrbitAnimation struct causes a child entity to orbit around a parent entity. It now works, but I have a lot to fix to make the starship rotate its orientation so the same side always faces the earth and I need to adjust the angle of the orbit and other parameters. So help is still needed.
Topic: Spatial Computing SubTopic: General Tags:
Jul ’24
Reply to Can't Get OrbitAnimation() to work on my project
I figured out what I was doing wrong. I needed to make a new scene in RCP where the starship is a child to the Earth. The OrbitAnimation struct causes a child entity to orbit around a parent entity. It now works, but I have a lot to fix to make the starship rotate its orientation so the same side always faces the earth and I need to adjust the angle of the orbit and other parameters.
Topic: Spatial Computing SubTopic: General Tags:
Jul ’24
Reply to Can't Get OrbitAnimation() to work on my project
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) } } } }
Topic: Spatial Computing SubTopic: General Tags:
Jul ’24
Reply to App Becomes Unresponsive for iOS/iPadOS 18 Regular Size Class Interactions When Selecting One Particular View in Sidebar
I've narrowed down the issue further as follows: Reference the FB13917278_Sample_App Xcode project I placed in the feedback running on iPadOS 18.0 Simulator If I change the SidebarView to make the FunctionView() launch as the detail view, the FunctionView displays correctly and works correctly when the user interacts with the List and children. However, if I navigate to the StartingView (works ok), then navigate back to the FunctionView, the problem is seen and the FunctionView does not appear. Therefore, the problem appears to be with the NavigationSplitView and NavigationStack going from another view in the sidebar list to the FunctionView. When doing step 1 and launching the app I get the following console log messages: NSBundle file:///Library/Developer/CoreSimulator/Volumes/iOS_22A5282m/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS%2018.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/MetalTools.framework/ principal class is nil because all fallbacks have failed If I don't interact with the simulator within a few seconds, I get these additional messages: [C:4-1] Error received: Invalidated by remote connection. Found no UIEvent for backing event of type: 3; contextId: 0xACBED546 If I interact with the FunctionView list, I get this additional message: Failed to create 0x88 image slot (alpha=1 wide=1) (client=0xd02d59c7) [0x5 (os/kern) failure] If I change the SidebarView to back to make the StartingView() launch as the detail view, I get the following console messages upon launch into Portrait orientation: Failed to send CA Event for app launch measurements for ca_event_type: 0 event_name: com.apple.app_launch_measurement.FirstFramePresentationMetric Failed to send CA Event for app launch measurements for ca_event_type: 1 event_name: com.apple.app_launch_measurement.ExtendedLaunchMetrics If I then switch to Landscape orientation, I get the following additional console messages: [C:4-1] Error received: Invalidated by remote connection. Found no UIEvent for backing event of type: 3; contextId: 0xD9737857 If I launch into Portrait orientation then immediately switch to Landscape orientation, I get no console messages, but trying to navigate to the FunctionView displays nothing and the app becomes unresponsive.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’24