arscnview

ARKit: Finding the coordinates of a SCNNode on the screen

℡╲_俬逩灬. 提交于 2020-06-27 08:17:17
问题 I have a simple Swift ARKit setup where I have a SCNNode with a 3D object that is visible in an ARSCNView. I want to determine the 2D coordinates of this object on the ARSCNView. By this I mean the x- and y-coordinates the object has when it is drawn onto the screen. I have provided a sketch to illustrate what I mean: Is there a way to get these coordinates, or at least an approximation? I need this in order to do some further processing with the camera frame. Basically I am interested in the

SCNNode not showing in ARFrame's capturedImage

家住魔仙堡 提交于 2020-05-15 09:18:55
问题 I added a SCNNode to a ARSCNView: func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? { guard let faceAnchor = anchor as? ARFaceAnchor else { return nil } guard let device = sceneView.device else { return nil } guard let faceGeometry = ARSCNFaceGeometry(device: device, fillMesh: true) else { return nil } let faceNode = FaceNode(faceGeometry) // Node is a custom SCNNode class let glassesNode = Node(image: UIImage(named: "glasses")!, position: .glasses, anchor:

SCNNode not showing in ARFrame's capturedImage

馋奶兔 提交于 2020-05-15 09:17:56
问题 I added a SCNNode to a ARSCNView: func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? { guard let faceAnchor = anchor as? ARFaceAnchor else { return nil } guard let device = sceneView.device else { return nil } guard let faceGeometry = ARSCNFaceGeometry(device: device, fillMesh: true) else { return nil } let faceNode = FaceNode(faceGeometry) // Node is a custom SCNNode class let glassesNode = Node(image: UIImage(named: "glasses")!, position: .glasses, anchor:

Swift ARKit How do you fully kill an ARSession?

烂漫一生 提交于 2020-01-14 10:23:53
问题 I have an ARSCNView running an ARSession . You can pause the session with session.pause() sure, but that still in effect, leaves the session running. I have tried deallocating the ARSCNView by removing it from its superview. The ARSCNView indeed deallocates but the ARSession is still running afterwards!! You can't assign nil to ARSession either. I can see the ARSessionDelegate 's func session(_ session: ARSession, didUpdate frame: ARFrame) is still being called! How do you completely wipe the

Swift ARKit How do you fully kill an ARSession?

北慕城南 提交于 2020-01-14 10:23:11
问题 I have an ARSCNView running an ARSession . You can pause the session with session.pause() sure, but that still in effect, leaves the session running. I have tried deallocating the ARSCNView by removing it from its superview. The ARSCNView indeed deallocates but the ARSession is still running afterwards!! You can't assign nil to ARSession either. I can see the ARSessionDelegate 's func session(_ session: ARSession, didUpdate frame: ARFrame) is still being called! How do you completely wipe the

Swift ARKit How do you fully kill an ARSession?

房东的猫 提交于 2020-01-14 10:22:48
问题 I have an ARSCNView running an ARSession . You can pause the session with session.pause() sure, but that still in effect, leaves the session running. I have tried deallocating the ARSCNView by removing it from its superview. The ARSCNView indeed deallocates but the ARSession is still running afterwards!! You can't assign nil to ARSession either. I can see the ARSessionDelegate 's func session(_ session: ARSession, didUpdate frame: ARFrame) is still being called! How do you completely wipe the

Is it possible to run two ARSCNView at the same time?

跟風遠走 提交于 2020-01-06 01:18:09
问题 I was thinking to do some modification to my existing AR app, and I wanted to split the view and add inside 2 ARSCNView in this way users can use the VR Card Box and have a different experience but Xcode is always returning me: Session (0x102617d10): did fail with error: Error Domain=com.apple.arkit.error Code=102 "Required sensor failed." So, I'm supposing that I can't run 2 ARSCNView sessions at the same time, or am I wrong? 回答1: The answer is: Yes, it's possible . Use the following code to

Is it possible to run two ARSCNView at the same time?

你离开我真会死。 提交于 2020-01-06 01:18:08
问题 I was thinking to do some modification to my existing AR app, and I wanted to split the view and add inside 2 ARSCNView in this way users can use the VR Card Box and have a different experience but Xcode is always returning me: Session (0x102617d10): did fail with error: Error Domain=com.apple.arkit.error Code=102 "Required sensor failed." So, I'm supposing that I can't run 2 ARSCNView sessions at the same time, or am I wrong? 回答1: The answer is: Yes, it's possible . Use the following code to

ARKit hitTest(_:options:) to select placed 3d-objects not working

狂风中的少年 提交于 2019-12-12 01:16:35
问题 I am trying to select an object which has been placed on a detected plane in order to perform various task on it such as rotating through gestures. In order to search for placed objects and avoid getting hitTestResults of irrelevant nature (eg. selecting the plane or the ARWorldMap itself) I am trying to use hitTest(_:options:) with SCNHitTestOption.categoryBitMask. However it seems as the hitTest returns results of all types, not just objects with the selected categoryBitMask = 5, even

ARKit Place a SCNNode facing the camera

做~自己de王妃 提交于 2019-12-09 04:27:58
问题 I'm using ARKit to display 3D objects. I managed to place the nodes in the real world in front of the user (aka the camera). But I don't manage to make them to face the camera when I drop them. let tap_point=CGPoint(x: x, y: y) let results=arscn_view.hitTest(tap_point, types: .estimatedHorizontalPlane) guard results.count>0 else{ return } guard let r=results.first else{ return } let hit_tf=SCNMatrix4(r.worldTransform) let new_pos=SCNVector3Make(hit_tf.m41, hit_tf.m42+Float(0.2), hit_tf.m43)