具有SKScene纹理的SCNSphere仅渲染球体的四分之一

时间:2017-10-05 13:27:07

标签: ios swift sprite-kit scenekit arkit

所以我有一个SceneKit球体对象:

let mySphere = SCNSphere(radius: 0.1)
let ballNode = SCNNode(geometry: mySphere)

我将SpriteKit场景添加为纹理:

someNode = SKSpriteNode(imageNamed: textureAtlas.textureNames[0])
someNode.size = CGSize(width:1500, height:1500)
someNode.position = CGPoint(x: 0, y: 0)

let scene2 = SKScene(size: someNode.size)
scene2.addChild(someNode)

ballNode.geometry!.firstMaterial?.diffuse.contents = scene2

该纹理仅在球体的四分之一上渲染:

enter image description here

为什么?

1 个答案:

答案 0 :(得分:0)

对我有帮助:

let textureImage = UIImage(named: "texture")!
let skScene = SKScene(size: textureImage.size)
let texture = SKTexture(image: textureImage)
let spriteNode = SKSpriteNode(texture: texture)

spriteNode.position = CGPoint(x: textureImage.size.width / 2, y: textureImage.size.height / 2)
spriteNode.zRotation = Transforms.degreesToRadians(180).cgFloat()
spriteNode.xScale *= -1