scnnode

How to draw dashed line in ARKit (SceneKit) like in the Measure app?

时间秒杀一切 提交于 2021-02-05 05:00:24
问题 Just wanted to know is it possible (I know it is, but how) to draw dashed line in ARSCNView like in the Measure app? Maybe there is a way to use scene nodes out of the box, idk. I've been using the SCNCylinder to draw a straight line and IDK is it possible to reuse it and adjust or we have to use a really different way to make the dashed line. import SceneKit class CylinderLineNode: SCNNode { private(set) var cylinder: SCNCylinder private(set) var positionA: SCNVector3 private(set) var

How to draw dashed line in ARKit (SceneKit) like in the Measure app?

蹲街弑〆低调 提交于 2021-02-05 04:59:06
问题 Just wanted to know is it possible (I know it is, but how) to draw dashed line in ARSCNView like in the Measure app? Maybe there is a way to use scene nodes out of the box, idk. I've been using the SCNCylinder to draw a straight line and IDK is it possible to reuse it and adjust or we have to use a really different way to make the dashed line. import SceneKit class CylinderLineNode: SCNNode { private(set) var cylinder: SCNCylinder private(set) var positionA: SCNVector3 private(set) var

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

Get the index of the face pointing up of SCNNode

只愿长相守 提交于 2020-06-16 19:12:11
问题 I am stuck in a difficult scenario as I had never worked with scenekit earlier. I had to create a dice that when rolled should print the number selected. I had implemented the dice using scenekit and then rolled it using the below function: func roll(dice: SCNNode) { let randomX = Float(arc4random_uniform(4) + 1) * (Float.pi / 2) let randomZ = Float(arc4random_uniform(4) + 1) * (Float.pi / 2) dice.runAction( SCNAction.rotateBy(x: CGFloat(randomX * 5), y: 0, z: CGFloat(randomZ * 5), duration:

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 -How to update ARAnchor to follow Camera's position

霸气de小男生 提交于 2020-03-04 19:35:15
问题 I followed this code from @rickster which 100% works and looks great. In the video he's animating a SCNNode that is set using an ARAnchor from 1 position to another and back. I tried to do something similar except I want the node that is set with the ARAnchor to follow/update it's position to another node that is a child of the camera. I'm having a problem updating the position in func renderer(_ renderer: SCNSceneRenderer, willRenderScene scene: SCNScene, atTime time: TimeInterval) { } I

Swift - How to find direction of target node i.e. Left or Right from Current Camera Position

为君一笑 提交于 2020-01-16 19:35:08
问题 I am trying to achieve a scenario where i need to find a way to reach from one SCNNode to another SCNNode . I have added the node to sceneView on the click of screen i.e. tapEvent using following code. override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { guard let touch = touches.first else { return } let result = sceneView.hitTest(touch.location(in: sceneView), types: [.featurePoint]) guard let hitResult = result.last else { return } let hitTransform = SCNMatrix4

Swift - How to find direction of target node i.e. Left or Right from Current Camera Position

ぃ、小莉子 提交于 2020-01-16 19:34:28
问题 I am trying to achieve a scenario where i need to find a way to reach from one SCNNode to another SCNNode . I have added the node to sceneView on the click of screen i.e. tapEvent using following code. override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { guard let touch = touches.first else { return } let result = sceneView.hitTest(touch.location(in: sceneView), types: [.featurePoint]) guard let hitResult = result.last else { return } let hitTransform = SCNMatrix4

SCNLevelOfDetails delegate/notification

时光毁灭记忆、已成空白 提交于 2020-01-16 14:35:40
问题 I'm using SCNLevelOfDetails with SceneKit. I was wondering if there's a way to know when the engine changes the levelOfDetails for a particular node's geometry. Many thanks. 回答1: I'm answering my own question. To give more context, we needed to know when the LOD would change in order to stop an idle animation, our model is skinned. What happens if you don't disable this animation when the LOD changes is that the geo goes all over the place and it looks wrong. The solution for us was to clone