I've been trying to overlay a simple 2D interface over a 3D Scenekit node using SpriteKit. The goal is to have the user interact with a virtual object.
Something like the above.
To create the other "selectionBorder" node I tried using SpriteKit scene with a SKShapeNode.
let borderSKNode = SKShapeNode(rectOf: CGSize(width: 200, height: 200)) borderSKNode.name = "border" borderSKNode.fillColor = colorLiteral(red: 0.807843148708344, green: 0.0274509806185961, blue: 0.333333343267441, alpha: 1.0) borderSKNode.strokeColor = colorLiteral(red: 0.439215689897537, green: 0.0117647061124444, blue: 0.192156866192818, alpha: 1.0) borderSKNode.lineWidth = 5 let skScene = SKScene(size: CGSize(width: 100 + selectionMargin, height: 100 + selectionMargin)) skScene.anchorPoint = CGPoint(x: 0.5, y: 0.5) skScene.backgroundColor = .clear print("adding border to the spritekit scene") skScene.addChild(borderSKNode) let labelGeometry = SCNPlane(width: width, height: height) labelGeometry.firstMaterial!.diffuse.contents = skScene let originLabelNode = SCNNode(geometry: labelGeometry) originLabelNode.name = "border" let constraint = SCNBillboardConstraint() constraint.freeAxes = [.Y, .X] originLabelNode.constraints = [constraint] print("trying to addd border node") self.addChildNode(originLabelNode)
Each time I try running this it fails with a cryptic message that says: "
validateDepthStencilState:3671: failed assertion `MTLDepthStencilDescriptor uses frontFaceStencil but MTLRenderPassDescriptor has a nil stencilAttachment texture'
Is this a bug in xCode 9 beta 6 or iOS 11 beta 7?
I still get the same thing, even after the GM release. I do almost the same as you, create a SKShapeNode and set the fillColor like you do in line 3 of your code:
borderSKNode.fillColor = colorLiteral(red: 0.807843148708344, green: 0.0274509806185961, blue: 0.333333343267441, alpha: 1.0)
I know that when running on the device it works and doesn't crash, but this "error" makes it impossible to debug, have you sort any sort of solution?
Maybe Apple can comment on this since it hasn't seemed to be solved even after release?