scenekit

Adding a SCNBillboardConstraint makes the node dissapear

只愿长相守 提交于 2019-12-04 00:29:10
问题 After what I've read in the documentation and on the internet a SCNBillboardConstraint would rotate a node to always face the pointOfView node - in the case of ARKit , the user's camera. The thing is, when I add a SCNBillboardConstraint to a child node, it dissapears. The nodes are just some SCNTexts added as a subchild of a more complex model. The hierarchy looks something like this: RootNode - > Text node (two of them). Just after I added the root node to the scene's root node, I add this

How can I remove all nodes from a scenekit scene?

血红的双手。 提交于 2019-12-03 23:19:43
Hi I am trying to remove all nodes from my Scenekit scene but I cannot for the life of me figure out a way. It seems logical to me that there must be a function for doing this automatically but I cannot find it. In context, I am trying to remove all nodes so I can reset my scene, which will happen reasonably often. Perhaps there is another way of doing this and I would be fine with that, I'm not stuck with having to remove all nodes. Thanks! Alan Try this (assuming you are using Swift): rootNode.enumerateChildNodes { (node, stop) in node.removeFromParentNode() } Works for me. Alessandro

SceneKit – Animation with DAE file format

寵の児 提交于 2019-12-03 21:42:06
问题 I'm trying to animate my model on a SceneKit scene: create a simple cube model and export it to cube.dae create a simple skeleton for cube and make a simple rotation animation using bones and export it to animation.dae using Apple sample Fox demo (WWDC 2015), I tried to put model on scene and it works animate box rotation – it is working but after applying animation, the cube changes its position to (0,0,0) Maybe someone has succeeded with skeletal animation and SceneKit using another 3d tool

Convert an image to a SceneKit Node

杀马特。学长 韩版系。学妹 提交于 2019-12-03 20:48:51
I have a bit-map image: ( However this should work with any arbitrary image ) I want to take my image and make it a 3D SCNNode. I've accomplished that much with this code. That takes each pixel in the image and creates a SCNNode with a SCNBox geometry. static inline SCNNode* NodeFromSprite(const UIImage* image) { SCNNode *node = [SCNNode node]; CFDataRef pixelData = CGDataProviderCopyData(CGImageGetDataProvider(image.CGImage)); const UInt8* data = CFDataGetBytePtr(pixelData); for (int x = 0; x < image.size.width; x++) { for (int y = 0; y < image.size.height; y++) { int pixelInfo = ((image.size

Creating custom shapes from primitives

大兔子大兔子 提交于 2019-12-03 20:45:26
I'm trying to create a custom Physics shape with combining primitive shapes. The goal is to create a rounded cube. The appropriate method seems to be init(shapes:transforms:) which I found here https://developer.apple.com/library/prerelease/ios/documentation/SceneKit/Reference/SCNPhysicsShape_Class/index.html#//apple_ref/occ/clm/SCNPhysicsShape/shapeWithShapes:transforms : I'm thinking this could be done with 8 spheres, 12 cylinders and a box in the middle. Can anyone provide an example of doing that? Yes, as you may have noticed, creating a physics body from an SCNBox with rounded corners

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

Drawing a 3D arc and helix in SceneKit

拜拜、爱过 提交于 2019-12-03 20:22:26
问题 A recent question here made me think of SceneKit again, and I remembered a problem I never solved. My app displays antenna designs using SK. Most antennas use metal rods and mesh reflectors so I used SCNCylinder for the rods, SCNPlane for the reflector and SCNFloor for the ground. The whole thing took a couple of hours, and I'm utterly noob at 3D. But some antennas use wires bent into arcs or helixes, and I punted here and made crappy segmented objects using several cylinders end-to-end. It

How to rotate a SCNSphere using a pan gesture recognizer

我与影子孤独终老i 提交于 2019-12-03 20:13:51
I created an SCNSphere so now it looks like a planet kind of. This is exactly what I want. My next goal is to allow users to rotate the sphere using a pan gesture recognizer. They are allowed to rotate it around the X or Y axis. I was just wondering how I can do that. This is what I have so far. origin = sceneView.frame.origin node.geometry = SCNSphere(radius: 1) node.geometry?.firstMaterial?.diffuse.contents = UIImage(named: "world.jpg") let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(CategoryViewController.panGlobe(sender:))) sceneView.addGestureRecognizer

SceneKit on OS X with thousands of objects

笑着哭i 提交于 2019-12-03 18:51:51
问题 I'm following this tutorial: http://blog.bignerdranch.com/754-scenekit-in-mountain-lion/ I'm interested in using Scene Kit, but my scenes might potentially have thousands of spheres. To stress-test Scene Kit I tried this: SCNSphere *sphere = [SCNSphere sphereWithRadius:0.5]; for (int i=0; i<10; i++) { for(int j=0; j<10; j++){ for(int k=0; k<10; k++){ SCNNode *myNode = [SCNNode nodeWithGeometry:sphere]; myNode.position = SCNVector3Make(i,j,k); [root addChildNode:myNode]; } } } This works fine

SceneKit SCNSceneRendererDelegate - renderer function not called

主宰稳场 提交于 2019-12-03 18:08:03
问题 I recently asked a question which had a pretty obvious answer. I'm still working on the same project and running into another problem. I need to implement per frame logic and the SCNSceneRendererDelegate protocol worked perfectly fine on iOS, but on OSX, the renderer function is not firing. I have created a little example project to illustrate my problem. It consists of a Scene Kit View in storyboard and following code in the ViewController class: import Cocoa import SceneKit class