我正在从事AR导航。我已经从源到目的地画了一条ar线。现在我正在尝试做淡入淡出线,该线应该显示一定的距离,当我向前移动时,应该显示剩余的线。这是我想要的输出结果的屏幕截图
此处是从源到目标绘制线的代码:
private func placeCylinder(source: SCNVector3, destination: SCNVector3) {
var height = source.distance(receiver: destination)
let anchor:ARPlaneAnchor
height = anchor.extent.x
// let anchorValue = anchor.extent.x
let cylinder = SCNCylinder(radius: ArkitNodeDimension.cylinderRadius, height: CGFloat(height))
cylinder.firstMaterial?.diffuse.contents = UIColor.white.withAlphaComponent(0.85)
let node = SCNNode(geometry: cylinder)
node.position = SCNVector3((source.x + destination.x) / 2, Float(-(ArkitNodeDimension.nodeYPosition)), (source.z + destination.z) / 2)
let dirVector = SCNVector3Make(destination.x - source.x, destination.y - source.y, destination.z - source.z)
let yAngle = atan(dirVector.x / dirVector.z)
print("yangle::\(yAngle)")
node.eulerAngles.x = .pi / 2
node.eulerAngles.y = yAngle
// scnplane //
sceneView.scene.rootNode.addChildNode(node)
}