简体   繁体   English

如何在ARKit中为3D文本自动调整背景大小

[英]How to Auto-Size a Background for 3D text in ARKit

I am trying to generate a background that automatically conforms to the size of the 3D that my program generates using ARKit. 我正在尝试生成一个自动符合我的程序使用ARKit生成的3D大小的背景。 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? 他们是使用swift / xCode做到这一点的一种方法,还是有一种计算背景必须达到的大小的方法?

For example: text1 = "abc" 例如:text1 =“ abc”

would only need a small background, where as: text2 = "abcdefg \\n 1234567 \\n testing123" 只需要一个小的背景,其中为: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. 需要更大的背景,并且文本和背景也将随文本大小而变化。

look into boundingBox 看看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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM