Ios 场景工具包节点未旋转

Ios 场景工具包节点未旋转,ios,scenekit,Ios,Scenekit,我尝试按场景工具包节点旋转,但它不旋转 我想让它绕y轴旋转。它是一个球体 let node = SCNNode() node.geometry = SCNSphere(radius: 1) node.geometry?.firstMaterial?.diffuse.contents = UIImage(named: "diffuse.png") node.geometry?.firstMaterial?.specular.contents = UIImage(named: "specular.p

我尝试按场景工具包节点旋转,但它不旋转

我想让它绕y轴旋转。它是一个球体

let node = SCNNode()
node.geometry = SCNSphere(radius: 1)
node.geometry?.firstMaterial?.diffuse.contents = UIImage(named: "diffuse.png")
node.geometry?.firstMaterial?.specular.contents = UIImage(named: "specular.png")
node.geometry?.firstMaterial?.emission.contents = UIImage(named: "emission.png")
scene.rootNode.addChildNode(node)


let action = SCNAction.rotate(by:360 * CGFloat((Double.pi)/180.0), around: SCNVector3(x: 0, y: 1, z: 0), duration: 8)

let repeatAction = SCNAction.repeatForever(action)
node.runAction(repeatAction)

你确定它没有旋转吗?我不确定你的漫反射、镜面反射和发射图像是什么,但可能是因为它是一个球体,它看起来不像是旋转的,因为它从各个角度看都是一样的

在ViewDidAspect中的立方体上运行相同的操作对我来说很有效,所以可能只是你没有注意到球体在旋转。我使用了以下代码:

    let node = SCNNode()

    node.geometry = SCNBox (width: 0.5, height: 0.5, length: 0.5, chamferRadius: 0.1)
    node.position = SCNVector3Make(0, 0, -1)
    sceneView.scene.rootNode.addChildNode(node)

    let action = SCNAction.rotate(by:360 * CGFloat((Double.pi)/180.0), around: SCNVector3(x: 0, y: 1, z: 0), duration: 8)

    let repeatAction = SCNAction.repeatForever(action)
    node.runAction(repeatAction)
立方体正在以旋转SCNNode的方式进行良好旋转

希望这有帮助