mapbox / mapbox-scenekit

Other
231 stars 51 forks source link

Adding child nodes to terraine nodes on ARSCNView #46

Open paulsUsername opened 6 years ago

paulsUsername commented 6 years ago

I have tried a good few different combinations but once I'm on ARSCNView I can't seem to add any child nodes. Even If I don't use terrainNode.convertPosition and just try to add a child to the root node, nothing shows.

The child is being added as if I check the count of arView?.scene.rootNode.childNodes it is increasing every time I add a child node but visually I see nothing.

I am adding them like this with a button once everything loaded:

` let endSphere = SCNNode(geometry: SCNSphere(radius: 100.0)) endSphere.geometry?.firstMaterial?.diffuse.contents = UIColor.red endSphere.position = (arView?.scene.rootNode.position)!

    arView?.scene.rootNode.addChildNode(endSphere)

    print(arView?.scene.rootNode.childNodes.count)`
natalia-osa commented 6 years ago

Can you please try this:

let node = SCNNode(geometry: SCNSphere(radius: 100.0))
node.geometry?.firstMaterial?.diffuse.contents = .red
let position = positionForLocation(CLLocationValue)
node.position = convertPosition(position, to: self.terrainNode)
terrainNode.addChildNode(firstNode)

Or you can simply use my PR to do it easily (https://github.com/mapbox/mapbox-scenekit/pull/24) by using terrainNode.projectedSphere method.