我尝试在SCNNode内放置一个Node(图像)。我希望它在右上角。但是我该如何实现呢?
所以:我想将buttonNode放在urlNode内:
Help me please
createWebView:
let urlNode = createWebView(url: url)
urlNode.scale = SCNVector3(x: 0.3, y: 0.3, z: 0.3)
let image = UIImage(named: "arrows-expand")
let buttonNode = SCNNode(geometry: SCNPlane(width: 1, height: 1))
buttonNode.geometry?.firstMaterial?.diffuse.contents = image
urlNode.addChildNode(buttonNode)
currentNode?.addChildNode(urlNode)
答案 0 :(得分:0)
您的urlNode是一个SCNPlane,其大小为4 x 2.75。 您的buttonNode也是一个SCNPlane,其大小为1 x 1。 创建urlNode之后,创建按钮节点并计算其位置: x = urlNode宽度/ 2.0-imageNode宽度/ 2.0 y = urlNode高度/ 2.0 + imageNode高度/ 2.0
let urlNode = createWebView(url: url)
let buttonNode = SCNNode(geometry: SCNPlane(width: 1, height: 1))
let image = UIImage(named: "arrows-expand")
buttonNode.geometry?.firstMaterial?.diffuse.contents = image
// Clean this up to get both the urlNode and buttonPlane SCNPlane geometry with a method of your choice here
buttonNode.postion = SCNVector3(x: urlNodePlane.width / 2.0 - buttonPlane.width / 2.0, y: urlNodePlane.height / 2.0 + buttonPlane.width / 2.0)
urlNode.addChildNode(buttonNode)
urlNode.scale = SCNVector3(x: 0.3, y: 0.3, z: 0.3)
currentNode?.addChildNode(urlNode)