缩放SCNNode

时间:2018-01-08 15:35:26

标签: swift xcode scenekit arkit scnnode

我知道SCNPhysicsBody在节点缩放时不会扩展,但我还没有找到解决这个问题的好方法。我想缩放节点,然后在缩放之后将SCNPhysicsBody更新为节点。

let box = SCNBox(width: 0.2, height: 0.3, length: 0.4, chamferRadius: 0.1)
box.firstMaterial?.diffuse.contents = UIColor.blue
var boxNode = SCNNode(geometry: box)
boxNode.scale = SCNVector3(0.5, 0.5, 0.5)
boxNode.position.x += 0.5

boxNode.physicsBody = SCNPhysicsBody(type: SCNPhysicsBodyType.static, shape: SCNPhysicsShape(geometry: box, options: nil))

sceneView.scene.rootNode.addChildNode(boxNode)

enter image description here

有没有人想出一个解决这个问题的好方法?

1 个答案:

答案 0 :(得分:4)

试试这个

let nodeScale = SCNVector3(0.5,0.5,0.5)

 boxNode.physicsBody = SCNPhysicsBody(type: SCNPhysicsBodyType.static, shape: SCNPhysicsShape(geometry: box, options:  [SCNPhysicsShape.Option.scale: nodeScale]))
相关问题