scenekit

SCNShape not drawing with UIBezierPath under certain circumstances

痴心易碎 提交于 2019-12-08 11:48:14
问题 I believe this may be an iOS bug, and I've reported it to Apple via Bug Report. I'll post it here in case there's some workaround I can use, or explanation of the cause. I'm wanting to draw the stroke of a UIBezierPath within SceneKit. I'm using the CGPath copyStrokingWithWidth function, and then creating a SCNShape using the given path. This works fine for lines with 2 points, but on lines with 3 points, the SCNShape doesn't display anything. I've determined that this is only the case when

Detect touch on SCNNode in ARKit

自作多情 提交于 2019-12-08 08:49:24
问题 I have placed a SCNNode (a plane) at the location of a recognized image in ARKit 1.5 beta. I would like to print a message to the console when the plane is tapped on. So far I have this code: // MARK: - ARSCNViewDelegate (Image detection results) /// - Tag: ARImageAnchor-Visualizing func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) { guard let imageAnchor = anchor as? ARImageAnchor else { return } let referenceImage = imageAnchor.referenceImage

Make a line thicker in 3D?

此生再无相见时 提交于 2019-12-08 08:34:44
问题 In reference to this question Drawing a line between two points using SceneKit I'm drawing a line in 3D and want to make it thicker by using this code func renderer(aRenderer: SCNSceneRenderer, willRenderScene scene: SCNScene, atTime time: NSTimeInterval) { //Makes the lines thicker glLineWidth(20) } but it doesn't work, iOS 8.2. Is there another way? Update From the docs https://developer.apple.com/library/prerelease/ios/documentation/SceneKit/Reference/SCNSceneRendererDelegate_Protocol

iOS: drawbacks of disabling Metal API Validation in order to fix pipeline failed assertion?

隐身守侯 提交于 2019-12-08 07:20:46
问题 Adding a SKEmitterNode to a SceneKit Scene via a SpriteKit overlay generates the following exception: -[MTLDebugRenderCommandEncoder validateFramebufferWithRenderPipelineState:]:1196: failed assertion `For color attachment 0, the render pipeline's pixelFormat (MTLPixelFormatRGBA8Unorm_sRGB) does not match the framebuffer's pixelFormat (MTLPixelFormatBGR10_XR).' This exception occurs on an iPhone 7 device, but does not appear in the simulator. Searching online yielded one valid workaround:

How to import a dae to SceneKit for ARKit

北城以北 提交于 2019-12-08 05:57:42
问题 If I run Xcode's ARKit project template, I can move around the default ship as expected. I have tried importing some dae models that I have exported from Blender, switching the ship to the new item but keeping the code the same. They always show in view but position in front the camera. If I try to move around the model it sticks infront of the camera and doesn't stay in the same virtual space. I have also tried importing a dae from another tutorial and that works as expected. Does anything

Wider and smoother lines in Metal shader

放肆的年华 提交于 2019-12-08 05:08:08
问题 I’m converting some glsl / opengl code to Metal for a SceneKit app so it can be rendered by Metal. I have a SCNNode (solidNode) created with primitive type SCNGeometryPrimitiveTypePolygon, and a childNode (wireframeNode) created with primitive type SCNGeometryPrimitiveTypeLine. The child node has the same vertices, ie. is the same model, and is placed slightly closer to the camera/eye position to prevent z-fighting. In OpenGL I simply used glLineWidth to draw lines more than 1px wide but it

SceneKit shadows on wall

青春壹個敷衍的年華 提交于 2019-12-08 04:28:26
问题 I have a cube, a wall and two lightNodes in my SceneKit application and I would like to make the cube throw a shadow onto the wall. My lightNodes are here: let lightNode = SCNNode() lightNode.light = SCNLight() lightNode.light!.type = SCNLightTypeSpot lightNode.position = SCNVector3(x: 0, y: 0, z: 15) lightNode.castsShadow = true scene.rootNode.addChildNode(lightNode) // create and add an ambient light to the scene let ambientLightNode = SCNNode() ambientLightNode.light = SCNLight()

SCNText Not Displaying

对着背影说爱祢 提交于 2019-12-08 04:03:41
问题 I have the following code in my SceneKit application but for some reason the text never shows up on the screen. let text = SCNText(string: item.label, extrusionDepth: 4.0) text.firstMaterial?.diffuse.contents = UIColor.white text.font = UIFont(name: "Arial", size: 35) let textNode = SCNNode(geometry: text) textNode.position = SCNVector3(-0.2 + x, -0.9 + delta, -1) self.node.addChildNode(textNode) 回答1: With a size of 35, that text will be huge. It's not 35 points tall, but 35 SceneKit units

SceneKit editor set custom class for node

醉酒当歌 提交于 2019-12-08 03:59:51
问题 In the SpriteKit editor, I can assign a custom class to an SKNode, like so: However, I can't seem to find the equivalent functionality in the SceneKit editor. Does it even exist? And if I can't set a custom class for an SCNNode, is there a reason the feature isn't there, or has the Xcode team just not gotten around to it? (In other words, should I file a radar?) 回答1: You can't do it in the scene editor. And you probably shouldn't do it at all. You'll have to implement your own serialization

SceneKit physics add velocity in local space

ε祈祈猫儿з 提交于 2019-12-08 03:47:13
问题 I am trying to manipulate the player node using physicsBody.velocity by adding or subtracting velocity to the axis for different directions. The problem is that I'm having trouble finding the method for applying that to local space or at least applying the velocity in relation to the direction the object is facing. In other words, it works fine if I have not rotated the object's node. If I do it will still add the velocity to the unrotated space. I know there is a way to add velocity to the