我有一个SCNPlane
和两个坐标(SCNVector3
)。我是从对另一个SCNPlane
(墙)的命中测试中获得的
我试图绘制SCNPlane
,但它们之间没有距离,但是SCNPlane
并没有询问两点之间的宽度。
这是我尝试过的:
guard let nodesWithDistance = self.getLastTwoNodeWithDistance(linkList: self.linkList) else {return}
print(nodesWithDistance) // This will return last two nodes with distance between them which is `sqrtf((vector1.x - vector2.x) * (vector1.x - vector2.x) + (vector1.y - vector2.y) * (vector1.y - vector2.y) + (vector1.z - vector2.z) * (vector1.z - vector2.z)`
let node = SCNNode(geometry: SCNPlane(width: CGFloat( nodesWithDistance.distance) , height: CGFloat(nodesWithDistance.distance) ))
node.geometry?.firstMaterial?.isDoubleSided = true
node.name = "TV"
node.geometry?.firstMaterial?.diffuse.contents = UIColor.red.withAlphaComponent(1)
node.renderOnTop()
node.geometry?.firstMaterial?.diffuse.contents = UIColor.red.withAlphaComponent(1)
node.position = nodesWithDistance.previous.node.mainNode.position
node.eulerAngles = first.node.eulerAngles
self.sceneView.scene.rootNode.addChildNode(node)
查看屏幕截图