قالب وردپرس درنا توس
Home / IOS Development / How to draw an ARL line based on CLLocation in iOS Swift?

How to draw an ARL line based on CLLocation in iOS Swift?



I'm trying to use ARKit for outdoor navigation. I have used kartbox for AR navigation and used mapboxarkit and mapboxDirection cocoapods.

The nodes are displayed as paths. I can show paths like dashed shperes or planes, but can not show them as lines. Here are my print screens

This is the node that I have attempted to display as a line break, and tried to adjust scnbox to be right and display as a line.

This is the result I expect: I want an AR line like this.

Here's the code I've tried so far – Here's the code to add an AR note and AR line.

     whose route = routes? ben = route.legs.first {
was polyline = [CLLocationCoordinate2D] ()

// Add an AR node and map display ad for each defined "step" in the route
by step in leg.steps {
let coordinate = step coordinates! first!
polyline.append (coordinate)
la stepLocation = CLLocation (latitude: coordinate.latitude, latitude: coordinate.longitude)

// Update the function collection for map view
self.updateShapeCollectionFeature (& self.waypointShapeCollectionFeature, with: stepLocation, typeKey: "waypoint-type", typeAttribute: "big")

// Add an AR node
leave annotation = annotation (location: stepLocation, calloutImage: self.calloutImage (for: step.description))
annotationsToAdd.append (note)
}

la meterPerNode: CLLocationDistance = 1
la turfPolyline = Polyline (polyline) // Go to the root bar and add a small AR node and map view, each meterPerNode because I'm in a hurry (from: meterPerNode to: turfPolyline.distance () - meterPerNode, by: metersPerNode) { // Use Turf to find the coordinate for each extended distance along the polyline if la nextCoordinate = turfPolyline.coordinateFromStart (distance: i) { la interpolatedStepLocation = CLLocation (latitude: nextCoordinate.latitude, latitude: nextCoordinate.longitude) // Update the function collection for map view self.updateShapeCollectionFeature (& self.waypointShapeCollectionFeature, with: interpolatedStepLocation, typeKey: "waypoint-type", typeAttribute: "small") // Add an AR node leave annotation = annotation (placement: interpolatedStepLocation, calloutImage: null) annotationsToAdd.append (note) }

Here is the code for creating a scnplane :

     func createLightBulbNode () -> SCNNode {

let lightBulbNode = collada2SCNNode (filepath: "art.scnassets / cubeSolid.dae")


lightBulbNode.position = SCNVector3 (0, -0.5, 0)

return lightBulbNode
}

func collada2SCNNode (filepath: String) -> SCNNode {
la node = SCNNode ()
let the scene = SCNScene (named: filepath, inDirectory: null, alternatives: [SCNSceneSource.LoadingOption.animationImportPolicy: SCNSceneSource.AnimationImportPolicy.doNotPlay])
la nodeArray = scene! .rootNode.childNodes
for childNode in nodeArray {
node.addChildNode (childNode as SCNNode)
}
Returns hub
}

}

func node (for annotation: annotation) -> SCNNode? {

whose annotation.calloutImage == nil {
// Comment `createLightBulbNode` and add` return nil` to use default node
return createLightBulbNode ()
} other {
let firstColor = UIColor (red: 0.0, green: 99 / 255.0, blue: 175 / 255.0, alpha: 1.0)
return createSphereNode (with: 0.5, firstColor: firstColor, secondColor: UIColor.green)
}
}

Any help much appreciated pls …


Source link