Reputation: 35953
I have created this SceneKit text by dragging a 3D Text to the scene using Interface Builder.
It was created like this:
The axis is on the lower left. Is there a way to center the axis on that text using interface builder?
Upvotes: 0
Views: 1121
Reputation: 46
Update for 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
)
Upvotes: 1
Reputation: 126137
Not in the Scene Editor.
In code, you can change a node's pivot to match the center point of its geometry by examining the bounding box. For example:
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
)
}
Upvotes: 4