Dive into RealityKit 2

RSS for tag

Discuss the WWDC21 session Dive into RealityKit 2.

Posts under wwdc21-10074 tag

8 Posts

Post

Replies

Boosts

Views

Activity

anyone succeeding in playing animation sequence in WWDC example?
https://developer.apple.com/videos/play/wwdc2021/10074/ with example that apple provide, there's dive app. in app sampel code, there's animation sequence which is done by octopus entity. I think this is the only way that I can do multiple animation with swift / USDZ form. the problem is that I can't reproduce animation sequence, so, I tweaked a little bit of sample code. firstly, when scene is up, on UnderwaterView.swift, load models function, uncomment if state so that setupOctopus is triggered. so, when ar app is on, octopus is appear on scene. I changed a little bit of hidingLocation so that after 3seconds of appear octopus, it move with animation. but the problem is octopus is moving but it shows no animation... what may be the problem? struct OctopusSystem: RealityKit.System {     init(scene: RealityKit.Scene) {}     func update(context: SceneUpdateContext) {         let scene = context.scene         for octopus in scene.performQuery(OctopusComponent.query) {             print("oc 1111")             guard octopus.isEnabled else { continue }             print("oc 2222")             guard var component = octopus.components[OctopusComponent.self] as? OctopusComponent else { continue }              //            guard component.settings?.octopus.fearsCamera ?? false else { return }             print("oc 3333\(component.state)")             switch component.state {             case .hiding:                 print("oc 44444")                 guard let camera = scene.performQuery(CameraComponent.query).first(where: { _ in true }) else { continue }                                      print("oc 555")                 let fearDistance: Float = 1.0                 let distanceToCamera = octopus.distance(from: camera)                                      print("oc 5555")                 guard distanceToCamera < fearDistance else { continue }                                      print("oc 6666")                  var hidingLocation = octopus                                          hidingLocation.transform.translation.x=hidingLocation.transform.translation.x-0.01                                      print("oc 7777") //                let distance = octopus.distance(from: hidingLocation) //                guard distance > fearDistance else { continue }                  //                    print("oc 88")                 var duration = 30.5                 print("oc du...")                 // Animations                                  DispatchQueue.main.asyncAfter(deadline: .now() + 3){                     do {                         let fixedTime                             = component.animations.crawl2Swim.definition.duration                             + component.animations.swim2crawl.definition.duration                         duration = max(fixedTime, duration)                         let swimDuration = duration - fixedTime                         let swimCycleDuration = component.animations.swim.definition.duration                         let swimCycles = Int(swimDuration / swimCycleDuration)                         duration = fixedTime + Double(swimCycles) * swimCycleDuration                         if let animation = try? AnimationResource.sequence(with: [                             component.animations.crawl2Swim,                             component.animations.swim.repeat(count: swimCycles),                             component.animations.swim2crawl                         ]) {                             print("oc playanimation")                             octopus.playAnimation(animation)                         }                     }                     octopus.move(to: hidingLocation.transform, relativeTo: nil, duration: duration)                 } //                component.state = .swimming(duration)             case .swimming(var time):                 time -= context.deltaTime                 component.state = time < 0 ? .hiding : .swimming(time)             }             octopus.components.set(component)         }     } }
0
0
861
Feb ’22
How to split USDZ file by animation?
Hello ! The only way that I can use multiple animation is to have multiple USDZ with single animation according to WWDC example https://developer.apple.com/videos/play/wwdc2021/10074/ todo so, I should have file with single animation but many sources like Sketchfab.. etc it has single GLTF , USDZ file with multiple animations, I have blender but it's too difficult to export each animation to each modeling file. can anyone let me know how to split file by animation?
0
0
1.1k
Feb ’22
Animate transparency of blending property in RealityKit 2
Hello, PhysicallyBasedMaterial in RealityKit 2 contains a blending property to adjust the transparency of a material. Is there a way to animate this over time to fade entities in and out? I've tried the new FromToByAnimation API but could not figure out if there is a supported BindPath for the transparency. Ideally what I would like to achieve is something similar to SceneKits SCNAction.fadeIn(duration: …) which also worked on a whole node. I figured I could also go the route of a custom fragment shader here, though that seems overkill. As RealityComposer also supports fade actions I would assume that this is at least supported behind the scenes. Thanks for any help!
2
0
1.9k
Jul ’21
Simple RealityKit 2 ECS example that rotates a simple cube using a Rotate Component?
The new RealityKit 2 ECS enhancements from #WWDC21 are awesome but to learn them I need a simple example! Could someone please post a simple RealityKit 2 ECS example that rotates a simple cube using a Rotate Component? If the Rotate Component is added then the cube should rotate. If the Rotate Component is removed then the cube should stop rotating.
1
0
1.2k
Jul ’21
anyone succeeding in playing animation sequence in WWDC example?
https://developer.apple.com/videos/play/wwdc2021/10074/ with example that apple provide, there's dive app. in app sampel code, there's animation sequence which is done by octopus entity. I think this is the only way that I can do multiple animation with swift / USDZ form. the problem is that I can't reproduce animation sequence, so, I tweaked a little bit of sample code. firstly, when scene is up, on UnderwaterView.swift, load models function, uncomment if state so that setupOctopus is triggered. so, when ar app is on, octopus is appear on scene. I changed a little bit of hidingLocation so that after 3seconds of appear octopus, it move with animation. but the problem is octopus is moving but it shows no animation... what may be the problem? struct OctopusSystem: RealityKit.System {     init(scene: RealityKit.Scene) {}     func update(context: SceneUpdateContext) {         let scene = context.scene         for octopus in scene.performQuery(OctopusComponent.query) {             print("oc 1111")             guard octopus.isEnabled else { continue }             print("oc 2222")             guard var component = octopus.components[OctopusComponent.self] as? OctopusComponent else { continue }              //            guard component.settings?.octopus.fearsCamera ?? false else { return }             print("oc 3333\(component.state)")             switch component.state {             case .hiding:                 print("oc 44444")                 guard let camera = scene.performQuery(CameraComponent.query).first(where: { _ in true }) else { continue }                                      print("oc 555")                 let fearDistance: Float = 1.0                 let distanceToCamera = octopus.distance(from: camera)                                      print("oc 5555")                 guard distanceToCamera < fearDistance else { continue }                                      print("oc 6666")                  var hidingLocation = octopus                                          hidingLocation.transform.translation.x=hidingLocation.transform.translation.x-0.01                                      print("oc 7777") //                let distance = octopus.distance(from: hidingLocation) //                guard distance > fearDistance else { continue }                  //                    print("oc 88")                 var duration = 30.5                 print("oc du...")                 // Animations                                  DispatchQueue.main.asyncAfter(deadline: .now() + 3){                     do {                         let fixedTime                             = component.animations.crawl2Swim.definition.duration                             + component.animations.swim2crawl.definition.duration                         duration = max(fixedTime, duration)                         let swimDuration = duration - fixedTime                         let swimCycleDuration = component.animations.swim.definition.duration                         let swimCycles = Int(swimDuration / swimCycleDuration)                         duration = fixedTime + Double(swimCycles) * swimCycleDuration                         if let animation = try? AnimationResource.sequence(with: [                             component.animations.crawl2Swim,                             component.animations.swim.repeat(count: swimCycles),                             component.animations.swim2crawl                         ]) {                             print("oc playanimation")                             octopus.playAnimation(animation)                         }                     }                     octopus.move(to: hidingLocation.transform, relativeTo: nil, duration: duration)                 } //                component.state = .swimming(duration)             case .swimming(var time):                 time -= context.deltaTime                 component.state = time < 0 ? .hiding : .swimming(time)             }             octopus.components.set(component)         }     } }
Replies
0
Boosts
0
Views
861
Activity
Feb ’22
How to split USDZ file by animation?
Hello ! The only way that I can use multiple animation is to have multiple USDZ with single animation according to WWDC example https://developer.apple.com/videos/play/wwdc2021/10074/ todo so, I should have file with single animation but many sources like Sketchfab.. etc it has single GLTF , USDZ file with multiple animations, I have blender but it's too difficult to export each animation to each modeling file. can anyone let me know how to split file by animation?
Replies
0
Boosts
0
Views
1.1k
Activity
Feb ’22
Unable to build the sample code for WWDC RealityKit 2 session
Hi I'm trying to become familiar with RealityKit 2. I'm trying to build the code in the session, but I'm getting compile errors. Any advice? Link to the sample code below https://developer.apple.com/documentation/realitykit/building_an_immersive_experience_with_realitykit
Replies
3
Boosts
0
Views
1.8k
Activity
Nov ’21
Demo code not compiling…
Loved the session, wanted to try out the demo code and then work through understanding it. 25 build errors that appear to be swift syntax related… is that just recent code changes or is there an easy fix?
Replies
10
Boosts
0
Views
2.9k
Activity
Nov ’21
I’m new
how can I view my main Device on another device transfer data
Replies
1
Boosts
0
Views
660
Activity
Aug ’21
Can i use PhotogrammetrySession on linux
Can i use PhotogrammetrySession on the centos7
Replies
0
Boosts
0
Views
920
Activity
Aug ’21
Animate transparency of blending property in RealityKit 2
Hello, PhysicallyBasedMaterial in RealityKit 2 contains a blending property to adjust the transparency of a material. Is there a way to animate this over time to fade entities in and out? I've tried the new FromToByAnimation API but could not figure out if there is a supported BindPath for the transparency. Ideally what I would like to achieve is something similar to SceneKits SCNAction.fadeIn(duration: …) which also worked on a whole node. I figured I could also go the route of a custom fragment shader here, though that seems overkill. As RealityComposer also supports fade actions I would assume that this is at least supported behind the scenes. Thanks for any help!
Replies
2
Boosts
0
Views
1.9k
Activity
Jul ’21
Simple RealityKit 2 ECS example that rotates a simple cube using a Rotate Component?
The new RealityKit 2 ECS enhancements from #WWDC21 are awesome but to learn them I need a simple example! Could someone please post a simple RealityKit 2 ECS example that rotates a simple cube using a Rotate Component? If the Rotate Component is added then the cube should rotate. If the Rotate Component is removed then the cube should stop rotating.
Replies
1
Boosts
0
Views
1.2k
Activity
Jul ’21