i have a function that should create a Sphere. and that is working fine. But if i call this function multiple times i can just see the last created Objekt in the scene.
var AllObjekts = [SCNNode]()
func createSphere(X: Float, Y: Float, Z: Float, NumObj: Int, Color: NSColor){
let sceneView = BrainView
let scene = SCNScene(named: "Brain.scn")
sceneView?.scene = scene
let geometry:SCNGeometry = SCNSphere(radius: 0.1)
geometry.materials.first?.diffuse.contents = Color //NSColor.red
let geometryNode = SCNNode(geometry: geometry)
AllObjekts.append(geometryNode)
geometryNode.position = SCNVector3(x: CGFloat(X), y: CGFloat(Y), z: CGFloat(Z))
scene?.rootNode.addChildNode(AllObjekts[NumObj])
}
createSphere(X: 0, Y: 0, Z: 0, NumObj: 0, Color: .green)
createSphere(X: 1, Y: 0, Z: 0, NumObj: 1, Color: .blue)
how the fuck can i fix it?