SceneView selective draw since concurrency

I have used SceneKit for several years but recently have a problem where a scene with fewer than 50 nodes is partially drawn, i.e., some nodes are, some aren't, and greater than 50 nodes are always draw correctly. This seems to have happened since concurrency was introduced. (w.r.t. concurrency, I had been using DispatchQueue successfully before then.)

Since all nodes (few or many) are constructed and implemented by the same functions etc. I'm baffled.

When I print the node hierarchy all nodes are present whether few or many. SceneView() has [.rendersContinually] option selected. Every node created (few or many) has .opacity = 1.0, .isHidden = false

I haven't tried setting-back the compiler version as that is not a long term solution, and I know the same code worked fine then.

Hello @G.U.T.explorer,

An unexpected visual appearance of a scene is often the result of a coordinate space issue, try implementing some of the debugging strategies described in TN3124: Debugging coordinate space issues.

-- Greg

Thanks for replying Greg

The only thing I hadn't tried in TN3124 was logging .boundingBox, which proved consistent whether few or many nodes. I even tried setting the box (for every childNode) larger to no effect. The parentNode has nil boundingBox.

In playing with the camera options, if .usesOrthographicProjection is false, no nodes appear whether few or many. The default is false per documentation. Yet OP is otherwise not necessary nor desired for my app.

Again, since the common code creates all nodes into a common scene with common camera etc. the only difference I can see is the time required to delete the previous nodes, load-from-file the pattern for the nodes to be drawn. Many nodes take more time than fewer. Yet again, .rendersContinuously is set. |-(

Oh, I almost forgot to cite a potentially important clue. To a view in ContentView I had attached

.onChange(of: scene.rootNode.childNode(withName: "parent-to-few-or-many", recursively: true).childNodes { flushAllChildNodes-reloadFileDescibingChildNodes-reDrawChildNodes }

which had the effect of constantly and alternatively blanking the scene and flashing the desired "fewer" nodes. Proving the childNodes are recognized by SceneKit in the proper position, scale etc. before getting wiped by unknown code. Before you ask, I had also disabled all calls to my own code that removes childNodes just in case poor coding was calling it somewhere. No luck, the fewer were not displayed any the many had subsequent childNodes added for a real mess.

The saga continues. So I thought I'd add sixty dummy childNodes complete with the same geometry as all the other children... just setting isHidden = true. It worked... in part. The unHidden children are not all visible. About 1/3 are. lol

Thanks for applying those debugging strategies!

Can you provide a focused sample project that reproduces the issue you describe?

-- Greg

Let's start with my scene, some of the oldest code and I was just starting coding after many years.

internal func makeAScene() -> SCNScene {
 let firstNode                      = SCNNode()
 let secondNode                = SCNNode()
 firstNode.name                 = “firstNode”
 firstNode.simdPosition      = SIMD3<Float>(0,0,0)
 firstNode.simdTransform   = float4x4([Float(0.5.squareRoot()),Float(0.5.squareRoot()),0,0],[-Float(0.5.squareRoot()),Float(0.5.squareRoot()),0,0],[0,0,1,0],[0,0,0,0])
 secondNode.name            = “secondNode”
 secondNode.simdPosition = SIMD3<Float>(0,0,0)

 let newScene                              = SCNScene()
 newScene.rootNode.addChildNode(firstNode)
 newScene.rootNode.childNode(withName: “firstNode”, recursively: true)?.addChoildNode(secondNode)
 newScene.background.contents = NSColor.black

 newScene.rootNode.camera                                                 = SCNCamera()
 newScene.rootNode.camera?.usesOrthographicProjection  = true
 newScene.rootNode.camera?.orthographicScale                  = 20
 newScene.rootNode.camera?.zNear                                     = -20
 newScene.rootNode.camera?.zFar                                       = 100
 newScene.rootNode.camera?.automaticallyAdjustsZRange = false

return newScene
}

.zNear bothers me because the default is 1 (not a negative number) but doesn't show otherwise. .zFar defaults to 100.

The SceneView is the first view listed within a ZStack{} and is therefore under much Text() and Pickers() etc. The figure constructed by the many elements and drawn in the scene are no wider nor deeper than 10 units in scale. The center of the figure is @ (0,0,0) of the scene's coordinate system.

SceneView selective draw since concurrency
 
 
Q