So I am trying to create a certain amount of spheres in a SceneKit scene based on the number of objects in a list. So I think I would put an addChild in a for loop, but how would I assign them all to the same type of model? Especially because sometimes the list will be empty, so the model would not need to show up at all.
Figured it out, this works:
for sensor in self.sensors{
node = SCNNode(geometry: SCNSphere(radius: 0.04))
node.geometry?.firstMaterial?.diffuse.contents = UIColor.black
node.castsShadow = true
node.simdPosition = sensor.getLocation()
node.name = "Sensor: \(sensor.getTag())"
scene?.rootNode.addChildNode(node)
}
Sensor is a data class that I wrote, it could be replaced with any other method of assigning a name or position.