func renderer(_ renderer: SCNSceneRenderer,dIDAdd node: SCNNode,for anchor: aranchor) { guard let imageAnchor = anchor as? ARImageAnchor else { return } let referenceImage = imageAnchor.referenceImage updateQueue.async { // Add a virtual cup at the position of the found image self.virtualObject.addVirtualObjectWith(scenename: "cup.dae",childNodename: nil,position: SCNVector3(x: imageAnchor.transform.columns.3.x,y: imageAnchor.transform.columns.3.y,z: imageAnchor.transform.columns.3.z),recursively: true,imageAnchor: imageAnchor) }}
问题是当我移动设备方向时,杯子将不能很好地保持在图像的中间位置.即使我删除图像,我也希望将杯子放在同一位置.我没有遇到问题,因为当您使用平面检测和命中测试添加对象时,还有一个用于飞机的aranchor.
更新05/14/2018
func addVirtualObjectWith(scenename: String,childNodename: String,objectname: String,position: SCNVector3,recursively: Bool,node: SCNNode?){ print("VirtualObject: Added virtual object with scene name: \(scenename)") let scene = SCNScene(named: "art.scnassets/\(scenename)")! var sceneNode = scene.rootNode.childNode(withname: childNodename,recursively: recursively)! sceneNode.name = objectname sceneNode.position = position add(object: sceneNode,toNode: node)}func add(object: SCNNode,toNode: SCNNode?){ if toNode != nil { toNode?.addChildNode(object) } else { sceneVIEw.scene.rootNode.addChildNode(object) }}解决方法 我终于找到了解决方案,结果是在属性检查器中没有正确设置AR参考图像的大小.当尺寸不正确时,图像的锚点将不稳定. 总结
以上是内存溢出为你收集整理的ios – ARKit:将3D对象放置在图像上方全部内容,希望文章能够帮你解决ios – ARKit:将3D对象放置在图像上方所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)