Axel Guilmin
Axel Guilmin

Reputation: 11746

UIView as a SCNGeometry's diffuse material glitch

I use a UIView as a diffuse material for a SCNPlane so I can display a 2D menu inside my 3D scene.

This works as I expected :

var node:SCNNode = // A child of my ARSCNView's scene
var menuVC:UIViewController = // I keep a strong reference to this view controller

let menuPlane:SCNPlane = // Newly created plane
menuPlane.firstMaterial?.diffuse.contents = menuVC.view
let menuPlaneNode = SCNNode(geometry: menuPlane)
menuPlaneNode.eulerAngles.x = -.pi / 2
node.addChildNode(menuPlaneNode)

However, I can notice a "flash" when the node is added to the scene; further inspection reveals it is the view of menuVC displayed in fullscreen in front of the ARSCNView for 1 frame, then it is rendered inside the scene.

Upvotes: 1

Views: 70

Answers (1)

Axel Guilmin
Axel Guilmin

Reputation: 11746

I found a workaround, in the Storyboard, setting the simulated size of the view controller to Freeform instead of Fixed solves the issue :

enter image description here

I have no clue why though.

Upvotes: 1

Related Questions