scnnode

ARKit - How to contain SCNText within another SCNNode (speech bubble)

自作多情 提交于 2019-12-03 20:53:06
I am trying to create a quote generator with simple text within a speech bubble in ARKit. I can show the speech bubble with text, but the text always starts in the middle and overflows outside of the speech bubble. Any help getting it align in the top left of the speech bubble and wrapping within the speech bubble would be appreciated. Result Classes class SpeechBubbleNode: SCNNode { private let textNode = TextNode() var string: String? { didSet { textNode.string = string } } override init() { super.init() // Speech Bubble let plane = SCNPlane(width: 200.0, height: 100.0) plane.cornerRadius =

SceneKit nodes aren't changing position with scene's root node

 ̄綄美尐妖づ 提交于 2019-12-03 20:43:06
I'm using SceneKit with ARKit, and right now have a simple app where I tap on the screen and it adds an ARAnchor and a SCNNode to my scene. At some point, I'm going to want to move the entire scene, so I tried changing sceneView.scene.rootNode.position.x += 10 to test this out. If I call this on any particular node, that node does move appropriately. But calling this on rootNode , nothing happens, where I'd expect every child node (which is every node in the scene) to move along with it. Why are my other nodes not moving appropriately, and is there something I can do to fix this? Or am I

ARkit - Loading .scn file from Web-Server URL in SCNScene

ε祈祈猫儿з 提交于 2019-12-03 07:35:51
问题 I am using ARKit for my application and I try to dynamically load .scn files from my web-server(URL) Here is a part of my code let urlString = "https://da5645f1.ngrok.io/mug.scn" let url = URL.init(string: urlString) let request = URLRequest(url: url!) let session = URLSession.shared let downloadTask = session.downloadTask(with: request, completionHandler: { (location:URL?, response:URLResponse?, error:Error?) -> Void in print("location:\(String(describing: location))") let locationPath =

ARkit - Loading .scn file from Web-Server URL in SCNScene

两盒软妹~` 提交于 2019-12-02 21:04:38
I am using ARKit for my application and I try to dynamically load .scn files from my web-server(URL) Here is a part of my code let urlString = "https://da5645f1.ngrok.io/mug.scn" let url = URL.init(string: urlString) let request = URLRequest(url: url!) let session = URLSession.shared let downloadTask = session.downloadTask(with: request, completionHandler: { (location:URL?, response:URLResponse?, error:Error?) -> Void in print("location:\(String(describing: location))") let locationPath = location!.path let documents:String = NSHomeDirectory() + "/Documents/mug.scn" ls = NSHomeDirectory() + "

Node group's position is reset at the start of SCNNode.runAction

风格不统一 提交于 2019-12-02 12:36:57
I have some code that rotates several SCNNodes around the x axis when the screen is tapped like so: func handleTap(gestureRecognize: UIGestureRecognizer) { let sceneView = self.view as SCNView let slice = self.cubes[0...8] let container = SCNNode() for node: SCNNode in slice { container.addChildNode(node) } sceneView.scene!.rootNode.addChildNode(container) container.runAction(SCNAction.rotateByX(CGFloat(M_PI / 2), y: 0.0, z: 0.0, duration: 1), completionHandler: { () -> Void in println("complete") }) } The issue that I'm running into is that every time this function is called, the nodes seem

Rotate SCNNode relative local coordinates

点点圈 提交于 2019-12-01 20:11:44
I'm trying to rotate a node by SCNAction , but it rotates relative to parent’s coordinate space. Is it possible to rotate a node relative local's coordinate system? Sure. You can obtain parent's space coordinates for rotation axis with convertVector method. For example, this action will do 180 degrees rotation around local x-axis: SCNAction.rotate(by: .pi, around: node.convertVector(SCNVector3(1, 0, 0), to: node.parent), duration: TimeInterval(5)) Have you tried: [node runAction:[SCNAction rotateByX:0 y:1 z:0 duration:5.0]]; //Rotates the node along the y axis for 5 seconds. 来源: https:/

removing SCNNode does not free memory before creating new SCNNode

故事扮演 提交于 2019-12-01 05:55:01
I am building an app that uses Scenekit to display a scene based on information returned from a data base. I have created a custom class with a class func that creates a SCNNode containing everything that needs to be drawn and returns it to my SCNView. Before calling this function I remove any existing nodes. Everything works great until I need to call it a second time. After removing the old SCNNode The memory is not deallocated before creating the new one. Is there a standard way of removing and replacing an SCNNode without overloading memory? I'm new to iOS dev and have never really done

SceneKit: understanding the pivot property of SCNNode

时光怂恿深爱的人放手 提交于 2019-12-01 05:01:16
问题 The goal is to increase the length of a SCNBox such that it only grows in the positive-z direction. This answer suggests playing with the pivot property. However, the documentation for the pivot property is sparse on the SCNNode page, and there is nothing on the SCNBox page. Can someone explain how the pivot property works? 回答1: Changing a node's pivot is conceptually the same as inserting an intermediate node between this node and its parent. This can be useful in different cases. One

SceneKit – Custom geometry does not show up

孤人 提交于 2019-12-01 04:41:14
I should see 2 yellow triangles, but I see nothing. class Terrain { private class func createGeometry () -> SCNGeometry { let sources = [ SCNGeometrySource(vertices:[ SCNVector3(x: -1.0, y: -1.0, z: 0.0), SCNVector3(x: -1.0, y: 1.0, z: 0.0), SCNVector3(x: 1.0, y: 1.0, z: 0.0), SCNVector3(x: 1.0, y: -1.0, z: 0.0)], count:4), SCNGeometrySource(normals:[ SCNVector3(x: 0.0, y: 0.0, z: -1.0), SCNVector3(x: 0.0, y: 0.0, z: -1.0), SCNVector3(x: 0.0, y: 0.0, z: -1.0), SCNVector3(x: 0.0, y: 0.0, z: -1.0)], count:4) ] let elements = [ SCNGeometryElement(indices: [0, 2, 3, 0, 1, 2], primitiveType:

SceneKit – Custom geometry does not show up

大憨熊 提交于 2019-12-01 02:45:15
问题 I should see 2 yellow triangles, but I see nothing. class Terrain { private class func createGeometry () -> SCNGeometry { let sources = [ SCNGeometrySource(vertices:[ SCNVector3(x: -1.0, y: -1.0, z: 0.0), SCNVector3(x: -1.0, y: 1.0, z: 0.0), SCNVector3(x: 1.0, y: 1.0, z: 0.0), SCNVector3(x: 1.0, y: -1.0, z: 0.0)], count:4), SCNGeometrySource(normals:[ SCNVector3(x: 0.0, y: 0.0, z: -1.0), SCNVector3(x: 0.0, y: 0.0, z: -1.0), SCNVector3(x: 0.0, y: 0.0, z: -1.0), SCNVector3(x: 0.0, y: 0.0, z: -1