Skip to content

Instantly share code, notes, and snippets.

@wizard1066
Last active January 5, 2023 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wizard1066/0610c137dd2f4cf300492cadb7a08632 to your computer and use it in GitHub Desktop.
Save wizard1066/0610c137dd2f4cf300492cadb7a08632 to your computer and use it in GitHub Desktop.
self.cubeNode.simdOrientation = faceAnchor!.leftEyeTransform.orientation
let newX = (satelliteNode.worldPosition.x * 100).rounded() / 100
let newY = (satelliteNode.worldPosition.y * 100).rounded() / 100
let formatter = NumberFormatter()
formatter.numberStyle = .decimal
formatter.maximumFractionDigits = 2
let number = NSNumber(value: newX)
let formattedValue = formatter.string(from: number)!
let number2 = NSNumber(value: newY)
let formattedValue2 = formatter.string(from: number2)!
looked.gazeX = formattedValue
looked.gazeY = formattedValue2
if newX < 0.9 && newY < 0.9 {
sphereNode.simdPosition = SIMD3(x: 0, y: 0, z: -6)
}
if (newX > 0.7 || newX < -0.7) {
changeX = newX > 0 ? 2.0 : -2.0
sphereNode.simdPosition = SIMD3(x: changeX, y: 0, z: -6)
}
if (newY > 0.3 || newY < -0.3) {
changeY = newY > 0 ? 1.0 : -1.0
sphereNode.simdPosition = SIMD3(x: 0, y: changeY, z: -6)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment