Transparent NSHostingController in SceneKit

I'm doing an experiment integrating SwiftUI views as Materials for a SceneKit scene SCNPanel node.

It is working perfectly in iOS using UIHostingController with the following code:
Code Block Swift
func createInfoPanel() {
let panel = SCNPlane(width: 6.0, height: 6.0)
let panelNode = SCNNode(geometry: panel)
let infoPanelHost = SCNHostingController(rootView: helloWorld)
infoPanelHost.view.isOpaque = false
infoPanelHost.view.backgroundColor = SCNColor.clear
infoPanelHost.view.frame = CGRect(x: 0, y: 0, width: 256, height: 256)
panel.materials.first?.diffuse.contents = infoPanelHost.view
panel.materials.first?.emission.contents = infoPanelHost.view
panel.materials.first?.emission.intensity = 3.0
[... BillBoardConstraint etc here ...]
addNodeToScene(panelNode)
}


Yet, when I tried to apply the same to macOS, I don't seem to be able to make the view created by NSHostingController transparent.
Invoking <infoPanelHost.view.isOpaque = false> returns an error, saying isOpaque is read-only and can't be set.

I tried subclassing NSHostingController and overriding viewWillAppear to try and make the view transparent / non-opaque, to no avail.

Code Block Swift
override func viewWillAppear() {
super.viewWillAppear()
self.view.wantsLayer = true
self.view.layer?.backgroundColor = NSColor.clear.cgColor
self.view.layer?.isOpaque = false
self.view.opaqueAncestor?.layer?.backgroundColor = NSColor.clear.cgColor
self.view.opaqueAncestor?.layer?.isOpaque = false
self.view.opaqueAncestor?.alphaValue = 0.0
self.view.alphaValue = 0.0
self.view.window?.isOpaque = false
self.view.window?.backgroundColor = NSColor.clear
    }


Tried setting everything I could think of to non-opaque as you can see, and still, the panels are opaque, show no info, and obscure the 3D entity they should overlay...

Can someone please advise?

Hey there, any chance you have a solution for this lying around? I'm trying to use a set of views instead of rendered view images for the sake of performance, and this would be a great tool to try.

I have reported this to Apple during WWDC'21 and have not touched the code since then. I might be working now, or not, I'd have to check...

What do you need exactly, @TikiMcFee ? Maybe I can give you some code examples 😀

Transparent NSHostingController in SceneKit
 
 
Q