SceneKit - SCNText centering incorrectly

前端 未结 4 1593
醉话见心
醉话见心 2020-12-31 23:13

I have tried to make a text string (SCNText) fit inside a box (SCNBox) in the code below. The size of the box looks correct but the text is not in the right center of the bo

4条回答
  •  甜味超标
    2020-12-31 23:53

    To find the center of the bounding box you need to add (not subtract) the min and max before you divide by 2.

    textNode.position = SCNVector3(x: (minVec.x + maxVec.x) / 2, y: minVec.y + maxVec.y, z: 0)
    

提交回复
热议问题