【发布时间】:2016-06-14 03:32:17
【问题描述】:
【问题讨论】:
标签: ios iphone scenekit scnnode
【问题讨论】:
标签: ios iphone scenekit scnnode
不在场景编辑器中。
在代码中,您可以通过检查边界框来更改节点的轴心以匹配其几何图形的中心点。例如:
func centerPivot(for node: SCNNode) {
var min = SCNVector3Zero
var max = SCNVector3Zero
node.getBoundingBoxMin(&min, max: &max)
node.pivot = SCNMatrix4MakeTranslation(
min.x + (max.x - min.x)/2,
min.y + (max.y - min.y)/2,
min.z + (max.z - min.z)/2
)
}
【讨论】:
Swift 4 更新
let min = node.boundingBox.min
let max = node.boundingBox.max
node.pivot = SCNMatrix4MakeTranslation(
min.x + (max.x - min.x)/2,
min.y + (max.y - min.y)/2,
min.z + (max.z - min.z)/2
)
【讨论】: