Disable live video feed in ARSCNView?

As described on the ARSCNView documentation: "The view automatically renders the live video feed from the device camera as the scene background."


Is there a way to programmatically disable/enable this behavior? For example, if I have an ARKit app using Scenekit and I have added several virtual objects into scene, is these some way to only display the virtual objects with a black background?

Replies

The bellow code works for me (use touch to on / off):


var originalSource: Any? = nil

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {

if originalSource == nil {

originalSource = sceneView.scene.background.contents

sceneView.scene.background.contents = UIColor.black

} else {

sceneView.scene.background.contents = originalSource

}

}

This works, but one time only during whole session, wondering why....

@YojimboMaster the example above only works once because it's always checking if

originalSource
is
nil
. Just change it to something like
if originalSource == nil || scene.background.contents as? UIColor != UIColor.black
and you'll be able to toggle between the video and solid background.

Hi J27.Kyle, Thanks for the solution but I can't make it work. How do you use that code? Thanks!