I have the following code to create a circle Path and a SCNShape from this path. orbit_gradient.png is a horizontal 1px high image that represents a gradient.

let material = SCNMaterial()  
material.isDoubleSided = true  
material.lightingModel = .constant       
material.diffuse.contents = UIImage(named: "art.scnassets/orbit_gradient.png")  

let shapePath = Path.circle(radius: radius, segments: 512)  

let orbitShape = SCNShape(shapePath)  
orbitShape.materials = [material]    
self.orbitNode.geometry = orbitShape 

The problem I have is that when applying the texture to this geometry I'm just left with a white circle. If I set the diffuse to be UIColor.red it displays as red. What I want to accomplish is a stroked circle that appears to gradually fade, creating a rotating trail effect.


Got there in the end by using SCNGeometrySource and SCNGeometryElement.

  1. Generate vertices
  2. Generate texture coordinates
  3. Generate indices
  4. Set material (my horizontal, 1px tall gradient)

I made a gist of a class I made incase it's useful to anyone else.



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .