如何在iOS Swift中基于CLLocation在arkit中画一条线?

时间:2018-11-20 17:24:01

标签: ios swift mapbox arkit

我正在尝试使用using System.Web.Script.Serialization; // ... JavaScriptSerializer jss = new JavaScriptSerializer(); string output = jss.Serialize(myList); UnityWebRequest www = UnityWebRequest.Post("http://ipaddress:5000/", output); yield return www.SendWebRequest(); 进行户外导航。我使用ARKit进行AR导航,并使用mapboxmapboxarkit椰子足。

节点显示为路径。我能够将路径显示为虚线的碎片或平面,但无法将其显示为线。这是我的输出屏幕截图

这是节点,我试图将其显示为断行并尝试将mapboxDirection调整为直线并显示为线: This is the node, which I have tried to show as a line breaking and tried to adjust <code>scnbox</code> to be straight and show as a line

这是我期望的结果:

I want an AR line like this.

这是我到目前为止尝试过的代码-这是添加AR注释和AR行的代码。

scnbox

以下是用于创建if let route = routes?.first, let leg = route.legs.first { var polyline = [CLLocationCoordinate2D]() // Add an AR node and map view annotation for every defined "step" in the route for step in leg.steps { let coordinate = step.coordinates!.first! polyline.append(coordinate) let stepLocation = CLLocation(latitude: coordinate.latitude, longitude: coordinate.longitude) // Update feature collection for map view self.updateShapeCollectionFeature(&self.waypointShapeCollectionFeature, with: stepLocation, typeKey: "waypoint-type", typeAttribute: "big") // Add an AR node let annotation = Annotation(location: stepLocation, calloutImage: self.calloutImage(for: step.description)) annotationsToAdd.append(annotation) } let metersPerNode: CLLocationDistance = 1 let turfPolyline = Polyline(polyline) // Walk the route line and add a small AR node and map view annotation every metersPerNode for i in stride(from: metersPerNode, to: turfPolyline.distance() - metersPerNode, by: metersPerNode) { // Use Turf to find the coordinate of each incremented distance along the polyline if let nextCoordinate = turfPolyline.coordinateFromStart(distance: i) { let interpolatedStepLocation = CLLocation(latitude: nextCoordinate.latitude, longitude: nextCoordinate.longitude) // Update feature collection for map view self.updateShapeCollectionFeature(&self.waypointShapeCollectionFeature, with: interpolatedStepLocation, typeKey: "waypoint-type", typeAttribute: "small") // Add an AR node let annotation = Annotation(location: interpolatedStepLocation, calloutImage: nil) annotationsToAdd.append(annotation) } } } 的代码:

scnplane

0 个答案:

没有答案