I made a particle system attached to a base (a cylinder node) in the SceneKit editor. Screenshot
I then added it to the root node of the sceneView's scene via a hit test. I'm using ARWorldTrackingConfiguration.
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?
I also tried wrapping the particle system in its own node, but it didn't work.
I then added it to the root node of the sceneView's scene via a hit test. I'm using ARWorldTrackingConfiguration.
Code Block swift /* 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?
Code Block language 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.