【发布时间】:2019-09-25 22:06:36
【问题描述】:
我将 node1 放置到了sceneview。当点击 node1 时,我还将 node2 作为子节点添加到 node1。但是我无法将 node2 正确放置在 node1 上的点击位置。如何将它准确地放置在 scn 节点的点击位置方舟。
更新
最终代码
let sceneView = sender.view as! ARSCNView
let tapLocation = sender.location(in: sceneView)
let hitTest = sceneView.hitTest(tapLocation, options: [:])
guard let node = hitTest.first?.node.parent
if let hitTest = hitTest.first
{
guard let scene = SCNScene(named: "furnitures.scnassets/(furnitureName).scn") else{return}
let childnode = (scene.rootNode.childNode(withName: furnitureName + " " + "parentnode", recursively: false))!
node.addChildNode(childnode)
childnode.position = hitTest.localCoordinates
childnode.scale = SCNVector3(0.5,0.5,0.5)
}
【问题讨论】:
-
你的代码在哪里?你试过了吗?
-
我发布了请检查和帮助...