Post

Replies

Boosts

Views

Activity

Hit test a particle system in ARKit
I made a particle system attached to a base (a cylinder node) in the SceneKit editor. Screenshot - https://github.com/zjohnzheng/DeveloperAssets/blob/master/Shot%202020-06-19%20at%201.09.00%20PM.png I then added it to the root node of the sceneView's scene via a hit test. I'm using ARWorldTrackingConfiguration. /* crossHairPoint is the 2D point where I want to place the particle */ let results = sceneView.hitTest(crossHairPoint, types: .existingPlaneUsingExtent)     if let hitResult = results.first {               let particleScene = SCNScene(named: "art.scnassets/lights.scn")!               let rootNode = particleScene.rootNode               rootNode.position = SCNVector3(         x: hitResult.worldTransform.columns.3.x,         y: hitResult.worldTransform.columns.3.y,         z: hitResult.worldTransform.columns.3.z       )               sceneView.scene.rootNode.addChildNode(rootNode)     } Then, I would like to be able to move the particle system + cylinder when I drag it. Hit testing works if I tap the base of the particle system (the cylinder), but hit testing the particle system itself doesn't work. Any suggestions? let hitNodeResults = sceneView.hitTest(location, options: [SCNHitTestOption.searchMode: 1]) /* `searchMode` is from this Stack Overflow answer: https://stackoverflow.com/a/50109757 It's supposed to be able to hit multiple nodes and objects even when in front or behind of each other */   for hitResult in hitNodeResults { /* ... never gets called when I tap the particle system */ } I also tried wrapping the particle system in its own node, but it didn't work.
1
0
953
Jun ’20
Links with '%' (percent symbol) have '25' added in the Forums
Whenever I link to URLs containing a '%' (percent symbol) in the Forums, a '25' is automatically added after each of them. Example: original URL https://github.com/zjohnzheng/DeveloperAssets/blob/master/Shot%202020-06-19%20at%201.09.00%20PM.png becomes https://github.com/zjohnzheng/DeveloperAssets/blob/master/Shot%25202020-06-19%2520at%25201.09.00%2520PM.png when clicked, resulting in a 404. I don't have any web development experience but I think this bug is due to percent encoding (Wikipedia says - https://en.wikipedia.org/wiki/Percent-encoding#Character_data '%' is a reserved character, and is encoded as... '%25').
2
0
895
Jun ’20
Best way to ask for Camera Permissions in App Clips
Normally, in an app that needs access to the camera, I would: make a view with some explanation of what the camera is used for, along with a button to ask for permissions. when pressed, this button will bring up the system popup (with another short description) for accepting camera permissions. But for app clips, should I directly bring up the system popup and skip the view with the explanation? I know that the system popup can contain a description as well, but when it pops up all of a sudden, the user might accidentally click "Don't Allow".
1
0
2.7k
Jun ’20
Get callback from @UIApplicationDelegateAdaptor
I'm using @UIApplicationDelegateAdaptor to detect if the user launched the app by pressing a home screen quick action, like this: import SwiftUI class AppDelegate: NSObject, UIApplicationDelegate {   func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {     if let shortcutItem = launchOptions?[UIApplication.LaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem {       if shortcutItem.type == "com.example.ExampleApp.exampleAction" {         print("Action Pressed!")       }     }     return true   } } @main struct SwiftUI_AppApp: App {       @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate       var body: some Scene {     WindowGroup {       ContentView()     }   } } This seems to work fine, but how can I notify ContentView that the user had pressed a quick action?
1
0
1.3k
Jun ’20
DragGesture freezes when a second finger is added
I have a DragGesture set up like this: let drag = DragGesture(minimumDistance: 0) .onChanged { _ in     print("changed") } .onEnded { _ in 		print("ended") } content.gesture(drag) /// content is the View that I'm adding the gesture to This works fine with just one finger. However, once I press down with a second finger, .onEnded is never called. Is there a way to allow only one finger for the gesture? I've seen similar issues here - https://stackoverflow.com/questions/60253490/swiftui-detect-draggesture-cancellation-when-ipad-dock-is-pulled-up and here - https://stackoverflow.com/questions/58807357/detect-draggesture-cancelation-in-swiftui, but they didn't work for me.
2
0
3.1k
Sep ’20
Are 'LearningTrail.xml' files allowed in the Swift Student Challenge submission?
I noticed that some of the built-in playgrounds have a file called LearningTrail.xml, with contents that look like this: ?xml version="1.0" encoding="UTF-8"? trail version="1.1" name="0103"   steps     step type="context"       blocks         block type="title"           title id="MfZ-Gx-dNg"What’s An Action?/title         /block         block type="image" source="content-whats-an-action" height="0.75"           description id="AcK-pe-jkX"A snail with four circles above it, showing the snail can scale, move forward and back, rotate, and fade in and out./description         /block         block type="text"           text id="jYg-QZ-KMx"In addition to animations, you can also scale, move, rotate, and fade your models using actions./text         /block                  block type="buttons" alignment="trailing"           button href="@nextStep" symbol="arrow.right.circle.fill"             text id="BMD-jU-Xiz"Ready?/text           /button         /block       /blocks     /step ... lots more The result looks like this: image link - https://github.com/aheze/DeveloperAssets/blob/master/IMG_5DAB4F43BA78-1.jpeg I can't find any documentation on this... will this be considered a private API? Are we allowed to make our own LearningTrail for our Swift Student Challenge submission?
1
0
854
Apr ’21