使用Project Dent尝试将3d对象放置在绝对GPS坐标上。
自述文件显示了如何将2D信息注释对象放入AR空间,但无法将其放置在GPS坐标上
Project Dent不使用标准的SceneView,这使得很难根据那里的许多教程来尝试执行此操作。它使用基于ARCL的SceneLocationView
这是2D注释的示例代码
let coordinate = CLLocationCoordinate2D(latitude: 51.504571, longitude: -0.019717)
let location = CLLocation(coordinate: coordinate, altitude: 300)
let view = UIView() // or a custom UIView subclass
let annotationNode = LocationAnnotationNode(location: location, view: view)
sceneLocationView.addLocationNodeWithConfirmedLocation(locationNode: annotationNode)
这就是我一直在尝试使其与3D对象一起使用的方法
let coordinate = CLLocationCoordinate2D(latitude: 51.504571, longitude: -0.019717)
let location = CLLocation(coordinate: coordinate, altitude: 300)
let box = SCNBox(width: 0.1, height: 0.1, length: 0.1, chamferRadius: 0)
let objectNode = LocationNode(location: location, SCNbox: box)
sceneLocationView.addLocationNodeWithConfirmedLocation(locationNode: objectNode)
理想情况下,我希望此代码将3d框简单地放在AR空间中的这些GPS坐标上。
可悲的是,目前我什至无法安装它。
作为对此的更新,我做了以下工作。基于LocationNode在Nodes中创建一个新类,称为ThreeDNode-
open class ThreeDNode: LocationNode {
// Class for placing 3d objects in AR space
public let threeDObjectNode: LocationNode
public init(location: CLLocation?, scene: SCNScene) {
let boxGeometry = SCNBox(width: 1, height: 1, length: 1, chamferRadius: 0)
//let boxNode = SCNNode(geometry: boxGeometry)
threeDObjectNode = LocationNode(location: location)
threeDObjectNode.geometry = boxGeometry
threeDObjectNode.removeFlicker()
super.init(location: location)
addChildNode(threeDObjectNode)
}
required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
然后在POIViewController中,尝试使用以下代码在AR空间中放置3d对象-
//example using 3d box object
let coordinate2 = CLLocationCoordinate2D(latitude: 52.010339, longitude: -8.351157)
let location2 = CLLocation(coordinate: coordinate2, altitude: 300)
let asset = SCNScene(named: "art.scnassets/ship.scn")!
let object = ThreeDNode(location: location2, scene: asset)
//add to scene with confirmed location
sceneLocationView.addLocationNodeWithConfirmedLocation(locationNode: object)
不高兴:(任何帮助,不胜感激。
答案 0 :(得分:0)
您将要创建一个位置节点,然后将其框添加为其几何或子节点:
let boxNode = SCNNode(geometry: box)
let locationNode = LocationNode(location: location)
locationNode.addChildNode(boxNode)
sceneLocationView.addLocationNodeWithConfirmedLocation(locationNode: locationNode)
我没有在Xcode中运行此代码,因此您可能需要进行调整。