我很难理解节点的多次旋转.
首先,我创建并定位了一架飞机:
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];
Run Code Online (Sandbox Code Playgroud)
然后我定位并设置了这个平面上聚光灯节点的方向:
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];
Run Code Online (Sandbox Code Playgroud)
然后,我将光节点的旋转设置为围绕x轴顺时针旋转90度:
[SCNTransaction begin];
[SCNTransaction setAnimationDuration:2.0];
lightNode.rotation = SCNVector4Make(1, 0, 0, M_PI/2);
[SCNTransaction commit];
Run Code Online (Sandbox Code Playgroud)
但我很困惑为什么以下将光节点旋转回同一轴的原始位置:
[SCNTransaction begin];
[SCNTransaction setAnimationDuration:2.0]; …Run Code Online (Sandbox Code Playgroud)