0

I am trying to generate a background that automatically conforms to the size of the 3D that my program generates using ARKit. Is their a way to do that using swift/xCode or is there a way to calculate what size the background would have to be?

For example: text1 = "abc"

would only need a small background, where as: text2 = "abcdefg \n 1234567 \n testing123"

would need a bigger background, and the text and background would also vary with the size of the text.

Alok Subedi
  • 1,601
  • 14
  • 26
user9242640
  • 103
  • 1
  • 3

1 Answers1

1

look into boundingBox

let text = SCNText(string: "123", extrusionDepth: 0.1)
let textNode = SCNNode(geometry: text)

let (min, max) = textNode.boundingBox
print("width :",max.x - min.x,"height :",max.y - min.y,"depth :",max.z - min.z)
Alok Subedi
  • 1,601
  • 14
  • 26