Hello,
I experienced a strange behavior with SceneView and a .frame() modifier. Here is a minimal example:
import SwiftUI
import SceneKit
struct MinimalSceneKitExample: View {
var simpleScene: SCNScene {
let scene = SCNScene()
let boxGeometry = SCNBox(width: 0.1, height: 0.1, length: 0.1, chamferRadius: 0)
let boxNode = SCNNode(geometry: boxGeometry)
boxNode.position = SCNVector3(0, 0, 0)
scene.rootNode.addChildNode(boxNode)
return scene
}
var body: some View {
SceneView(
scene: SCNScene(),
options: [.allowsCameraControl, .autoenablesDefaultLighting]
)
.frame(maxWidth: .infinity, maxHeight: 312.6)
}
}
This code turns the SceneView into a black view. Only some height values are causing this behavior. For example the height value 312.3 is fine. In my app, I'm using a dynamic height value that depends on the device's screen size which results in this behavior on some devices. Took me days to find this cause. So far integer values seem to always work which is what I will use as a quick fix for now.
Should I file a bug ticket for this?