SCNCylinder上的设置内容(图像)反转(翻转)

我试图使用以下代码在SCNCylinder对象上呈现图像:

let coinGeometry = SCNCylinder(radius: 50, height: 55) coinNode = SCNNode(geometry: coinGeometry) coinNode.position = SCNVector3Make(0.0, 25.0, 25.0) coinScene.rootNode.addChildNode(coinNode) //Add image on cylinder shape let frontFacingImageMaterial = SCNMaterial() frontFacingImageMaterial.diffuse.contents = UIImage(named: "map") frontFacingImageMaterial.specular.contents = UIColor.blueColor() frontFacingImageMaterial.shininess = 5.0 coinGeometry.firstMaterial = frontFacingImageMaterial 

在圆柱体上,此图像显示为反转(翻转)。 我该如何解决?

谢谢

不要翻转原始的图像数据,只是将其映射到几何体上。 将frontFacingImageMaterial.diffuse.contentsTransform设置为翻转X或Y的matrix。

从如何水平翻转UIImage? :

 UIImage* sourceImage = [UIImage imageNamed:@"whatever.png"]; UIImage* flippedImage = [UIImage imageWithCGImage:sourceImage.CGImage scale:sourceImage.scale orientation:UIImageOrientationUpMirrored]; 

所以在Swift中,像这样:

 if let originalImage = UIImage(named: "map") { let materialImage = UIImage(CGImage: originalImage.CGImage!, scale: originalImage.scale, orientation: .UpMirrored) }