Home IOS Development ios – Digital camera rotation to place would not work appropriately

ios – Digital camera rotation to place would not work appropriately

0
ios – Digital camera rotation to place would not work appropriately

[ad_1]

I’ve a 3D globe represented by SCNNodes (dots). I additionally add a spotlight on the node within the location of New York. After the view renders I attempt to rotate the view to indicate the highlighted node. My calculations to take action are fallacious as a result of the globe is rotated to the other facet from the place the purpose is.

func alignPointToPositiveZ(for sphereNode: SCNNode, targetPoint: SCNVector3) {
    // Compute normalized vector from Earth's heart to the goal level
    let targetDirection = targetPoint.normalized()
    
    // Compute quaternion rotation
    let up = SCNVector3(0, 0, 1)
    let rotationQuaternion = SCNQuaternion.fromVectorRotate(from: up, to: targetDirection)
    
    sphereNode.orientation = rotationQuaternion
}

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here