节点不旋转?

时间:2016-12-22 23:35:19

标签: swift rotation scenekit

运行应用程序时,节点不会旋转。无论我将旋转更改为什么,节点都将保持为'0,0,0,0'。

function A ( ) {
    // Never terminates
    while ( true ) {
        // If A() is called here, or before
        // the loop you have infinite 
        // recursion and a stack size error
    }
    // If, instead, A() is called here,
    // you just have an infinite-loop,
    // since this statement is never reached
}

//节点传入GeometryNodes以供用户移动。没有任何反应!

class CustomSCNNode: SCNNode {



var positionToSlideFrom = SCNVector3Zero

convenience init(geometry: SCNGeometry, initialPosition: SCNVector3, rotation: Float) {
    self.init()
    self.geometry = geometry
    self.position = initialPosition
    self.positionToSlideFrom = initialPosition
    self.rotation.y = rotation


}

}

1 个答案:

答案 0 :(得分:0)

要围绕Y轴旋转45度,您需要将旋转指定为:

self.rotation = SCNVector4Make(0, 1, 0, 45 * M_PI / 180.0)

同样,如果绕X轴或Z轴旋转,请确保正确表达XYZ轴。

或者,您也可以使用eulerAngles属性指定轮换:

self.euelerAngles = SCNVector3Make(0, 45 * M_PI / 180.0, 0)