Getting SCNNode Bounding Size in Meters

限于喜欢 提交于 2019-12-24 06:38:09

问题


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.

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)

回答1:


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.



来源:https://stackoverflow.com/questions/45775887/getting-scnnode-bounding-size-in-meters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!