我很难理解节点的多次旋转。
首先,我创建并定位了一个平面:
SCNPlane *plane = [SCNPlane planeWithWidth:10 height:10];
SCNNode *planeNode = [SCNNode nodeWithGeometry:plane];
planeNode.rotation = SCNVector4Make(1, 0, 0, (M_PI/2 * 3));
[scene.rootNode addChildNode:planeNode];
然后我在这个平面上定位和设置了一个聚光灯节点的方向:
SCNLight *light = [[SCNLight alloc] init];
light.type = SCNLightTypeSpot;
light.spotInnerAngle = 70;
light.spotOuterAngle = 100;
light.castsShadow = YES;
lightNode = [SCNNode node];
lightNode.light = light;
lightNode.position = SCNVector3Make(4, 0, 0.5);
lightNode.rotation = SCNVector4Make(0, 1, 0, M_PI/2);
[planeNode addChildNode:lightNode];
然后我对光节点进行旋转动画,以x轴为轴心顺时针旋转90度:
[SCNTransaction begin];
[SCNTransaction setAnimationDuration:2.0];
lightNode.rotation = SCNVector4Make(1, 0, 0, M_PI/2);
[SCNTransaction commit];
但是我不明白为什么以下代码会使光节点绕着相同的轴旋转回原来的位置:
[SCNTransaction begin];
[SCNTransaction setAnimationDuration:2.0];
lightNode.rotation = SCNVector4Make(0, 1, 0, M_PI/2);
[SCNTransaction commit];
在我看来,这意味着我们正在沿着y轴将节点顺时针旋转90度。
有人能解释一下为什么这样可以实现吗?或者更好的方法是什么,可以将节点旋转然后返回到原始位置?