Post

Replies

Boosts

Views

Activity

Apply blur to SCNNode
I have a basic ARSCNView that detects images and displays information about them. The image detected is currently covered in a slightly transparent black with the text overlaid in a transparent white colour. Ideally I'd like the background behind the text to be a blur view with that transparent black tint, so it blurs the image that is being detected. I started trying to implement a UIVisualEffectView with a UIBlurEffect but that didn't work. I also looked up SKEffectNode with a CIFilter but that resulted in nothing changing. Can you use UIBlurEffect or an alternative blur view to apply to the plane or planeNode? All solutions appreciated. Swift func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) - SCNNode? { guard let imageAnchor = anchor as? ARImageAnchor, let name = imageAnchor.referenceImage.name, let datum = data[name] else { return nil } let spacing = Float(0.005) let node = SCNNode() let plane = SCNPlane(width: imageAnchor.referenceImage.physicalSize.width, height: imageAnchor.referenceImage.physicalSize.height) plane.firstMaterial?.diffuse.contents = UIColor.black.withAlphaComponent(0.99) // add blur to this plane with the black tint let planeNode = SCNNode(geometry: plane) planeNode.eulerAngles.x = -.pi / 2 node.addChildNode(planeNode) let titleNode = textNode(datum.title, font: UIFont.boldSystemFont(ofSize: 10)) titleNode.pivot = SCNMatrix4MakeTranslation(titleNode.boundingBox.min.x, titleNode.boundingBox.max.y, .zero) titleNode.position.x -= Float(plane.width) / 2 - spacing titleNode.position.y += Float(plane.height) / 2 - spacing planeNode.addChildNode(titleNode) let descriptionNode = textNode(datum.description, font: UIFont.systemFont(ofSize: 4), maxWidth: Int(imageAnchor.referenceImage.physicalSize.width * 500)) descriptionNode.pivot = SCNMatrix4MakeTranslation(descriptionNode.boundingBox.min.x, descriptionNode.boundingBox.max.y, .zero) descriptionNode.position.x -= Float(plane.width) / 2 - spacing descriptionNode.position.y = titleNode.position.y - titleNode.height - spacing planeNode.addChildNode(descriptionNode) return node } private func textNode(_ string: String, font: UIFont, maxWidth: Int? = nil) - SCNNode { let text = SCNText(string: string, extrusionDepth: 0.5) text.flatness = 0.1 text.font = font text.firstMaterial?.diffuse.contents = UIColor.lightText if let maxWidth = maxWidth { text.containerFrame = CGRect(origin: .zero, size: CGSize(width: maxWidth, height: 100)) text.isWrapped = true } let textNode = SCNNode(geometry: text) textNode.scale = SCNVector3(0.002, 0.002, 0.002) return textNode }
0
0
1.4k
Feb ’21
Change Xcode theme based on appearance
I have decided to try out a light theme in Xcode (don’t ask why), when light mode is on, and then use a dark theme when the system switches to dark mode. However, when Xcode goes dark, the editor stays with the light theme and doesn’t switch to an equivalent dark one. I would like to know if there is a way to have Xcode automatically do this - for example, in light mode use Presentation (Light) and in dark mode use Presentation (Dark). As of yet, I haven’t found a solution within Xcode, but maybe there is a way to control this by using a custom theme?
0
1
1.7k
May ’21