I have drawn some 2D spheres and added them in the Nodes Array, then I used cylinderNodes to connect the sphere Nodes, It forms a Closed Shape. What I want here is to assign an image to this closed Path.
func DrawPath() {
// Ensure there are nodes in the nodesArray
guard !nodesArray.isEmpty else {
return
}
// Create a UIBezierPath
let path = UIBezierPath()
for (index, child) in nodesArray.enumerated() {
if index == 0 {
path.move(to: CGPoint(x: CGFloat(child.position.x), y: CGFloat(child.position.y)))
} else {
path.addLine(to: CGPoint(x: CGFloat(child.position.x), y: CGFloat(child.position.y)))
}
}
// Close the path to create a shape
path.close()
// Create an SCNShape
// let shape = SCNShape(path: path, extrusionDepth: 0.1)
if I use SCNPlane Instead of SCNShape , I'm getting these results .
`let size = SCNVector3(
max.x - min.x,
max.y - min.y,
max.z - min.z
)
// Create a plane geometry
let plane = SCNPlane(width: CGFloat(size.x), height: CGFloat(size.z))
let imageMaterial = SCNMaterial()
imageMaterial.diffuse.contents = UIImage(named: "grass")
// Apply the material to the plane's geometry
shape.materials = [imageMaterial]
// Create an SCNNode with the shape geometry
let planeNode = SCNNode(geometry: shape)
planeNode.position.z = -2
arScnView.scene.rootNode.addChildNode(planeNode)
}


