以米为单位获取SCNNode边界大小 [英] Getting SCNNode Bounding Size in Meters
问题描述
我正在尝试将SCNPlane包裹在SCNNode周围.我正在使用ARKit,因此所有内容均以米为单位进行度量,但是当我得到boundingBox
时,我会以其他单位获得度量.我查看了Apple的文档,但没有指定单位是什么.
I'm trying to wrap an SCNPlane around a SCNNode. I'm using ARKit so everything is measured in meters, but when I get the boundingBox
, I get measurements in some other unit. I looked at Apple's documentation, and they don't specify what the units are.
例如,其中一个节点大约3米宽,但是它说有26个单位.
For example, one of nodes is roughly 3 meters wide, but it says its 26 units.
我可以做一个粗略的除法以获得一个常数,并使用该常数进行单位转换,但是我想知道是否有一种更简单的方法?
I could do a rough division to get a constant and use that to do the unit conversions, but I was wondering if there's a less hacky way to do it?
let textContainerSize = textBodyNode.boundingBox
let xSize = textContainerSize.max.x - textContainerSize.min.x
let ySize = textContainerSize.max.y - textContainerSize.min.y
print("size")
print(xSize, ySize) // <-- returns (26,2)
let planeGeometry = SCNPlane(width: xSize, height: ySize)
推荐答案
One SceneKit unit is one meter in ARKit
but the boundingBox
is defined in the nodes local coordinate system. So your node probably has a parent with a scale different from 1.
这篇关于以米为单位获取SCNNode边界大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!