scenekit

How to change SCNPlane color as clear color

China☆狼群 提交于 2019-12-05 17:12:47
I am working on a ARKit project which needs Ripple animation effect when tapped on Horizontal Plane. For that I have took UIView object and pass that as contents for material of SCNPlane object. I have added Ripple animation to UIView object. Everything works fine. But I can't change the SCNPlane colour to clear color. I can use transparency property for the material. But it is hiding Ripple animation too. So, what I need here is, the background colour of SCNPlane object should be transparent and only Ripple animation should appear to user. Can someone help me on this. This is my code. let

Overlay SKScene is not showing

大憨熊 提交于 2019-12-05 16:53:49
I'm trying to overlay an SKScene over a SCNScene. When I run my app on the simulator and an iPhone6+, the overlayScene(SKScene) is shown as intended, but when I tried running it on the iPhone5 (tried 2 different devices) the overlayScene does not appear. Does anyone have an idea why? Both device run on iOS 9.2.1. I have only tested the app on those two models. Here's my code inside the GameViewController.Swift //Configure the view sceneView = self.view as? SCNView //Configure the scene sceneView.scene = gameScene sceneView.playing = true sceneView.backgroundColor = UIColor.blackColor()

How to solve SceneKit double not supported error?

强颜欢笑 提交于 2019-12-05 15:51:31
I have been looking into SceneKit for iOS over the past couple of days. I came across an issue when trying to create custom geometry. Whenever I tried to display the geometry, it would not draw, and show me this error during runtime. SceneKit: error, C3DRendererContextSetupResidentMeshSourceAtLocation - double not supported I created a playground targeting iOS to test a more simple example of custom geometry, and looked into this question about custom geometry using swift vs objective c. I tried another project using objective c and still received the same error message. The error does not

Why is SCNNode “jiggling” when dropped onto SCNPlane?

半城伤御伤魂 提交于 2019-12-05 14:49:31
I have a SCNPlane that is added to the scene when a sufficient area is detected for a horizontal surface. The plane appears to be placed in a correct spot, according to the floor/table it's being placed on. The problem is when I drop a SCNNode(this has been consistent whether it was a box, pyramid, 3D-model, etc.) onto the plane, it will eventually find a spot to land and 99% start jiggling all crazy. Very few times has it just landed and not moved at all. I also think this may be cause by the node being dropped and landing slightly below the plane surface. It is not "on top" neither "below"

How to put text over node in scenekit?

徘徊边缘 提交于 2019-12-05 13:31:36
Really simple question which for some reason I cannot find anywhere. How can I write 2D text on a 3D face of a SCNNode ? For example, on something like this: let geo = SCNBox(width: 20, height: 20, length: 20, chamferRadius: 0.0); //geo.writeFace(postion, text) let box = SCNNode(geometry: geo); Of course the comment is made up. Anything like it? You'll need to create a texture of the desired font and text, then apply that as a part of the material on the object. Though I've not seen anything like UVW mapping in Scene Kit to let you control the placement. It must be there. If you're only

Swift 3.0 how to use startDeviceMotionUpdates(to: withHandler)?

廉价感情. 提交于 2019-12-05 12:50:32
Swift 3.0 was released alongside Xcode 8.0 and apparently a lot has changed. I'm very unfamiliar with the new syntax in swift. Can someone help me out? I'm trying to figure out what goes in motionManager.startDeviceMotionUpdates( to: OperationQueue.current()!, withHandler: ) after the "withHandler:" I am trying to get my SceneKit program be able to utilize the accelerometer to determine the orientation of an SCNNode platform. I am also fairly new to swift (about 5 days into programming in Swift) so if there's something fundamental I am messing up, let me know. Reference You must pass the block

How can I remove all nodes from a scenekit scene?

别来无恙 提交于 2019-12-05 11:19:24
问题 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! 回答1: Try this (assuming you are using Swift):

SceneKit: how to reproduce iOS 9 lighting color effect (one directional, one ambient) on iOS 10 without disabling PBR?

大兔子大兔子 提交于 2019-12-05 10:14:14
As this thread on the Apple forums mentions, lights on iOS 10 are now weaker and change how scenes look. The thread suggests setting SCNDisableLinearSpaceRendering to YES, but this did not work. Put another way, using SCNDisableLinearSpaceRendering will not make your scene look the same on iOS 10 as on iOS 9 -- at least not in our testing. We also tried: floorNode.geometry?.firstMaterial?.lightingModel = SCNMaterial.LightingModel.blinn Screenshots below show the difference between the same scene. Notice how the floor turns from green to yellow even though the lighting is the same. The scene

SceneKit pass uniform vector to shader modifiers

情到浓时终转凉″ 提交于 2019-12-05 10:02:46
I'm trying to pass a GLKVector4 to a shader that should receive it as a vec4 . I'm using a fragment shader modifier: material.shaderModifiers = [ SCNShaderModifierEntryPoint.fragment: shaderModifier ] where shaderModifier is: // color changes uniform float colorModifier; uniform vec4 colorOffset; vec4 color = _output.color; color = color + colorOffset; color = color + vec4(0.0, colorModifier, 0.0, 0.0); _output.color = color; (I'm simply adding a color offset) I've tried: material.setValue(GLKVector4(v: (250.0, 0.0, 0.0, 0.0)), "colorOffset") which doesn't work (no offset is added and the

Optimizing SceneKit performance with high-res textures

放肆的年华 提交于 2019-12-05 09:49:39
I'm a fairly experienced iOS developer but a total SceneKit newbie, trying to simulate some planets in a basic app. To that end, I'm using high-res normal and diffuse maps of Mars, Venus, etc, applied to basic spheres. And they work! They look awesome, exactly what I was going for. The problem is, I'm getting killed by the quality/memory tradeoff. I can scale down the dimensions of the textures to reduce the memory footprint, but below a certain resolution the results (especially the normal map) start to look really mushy and terrible. The app needs to be able to zoom at least to where the