SceneKit(OpenGL)中平滑相机移动的标准方法是什么?手动更改 x,y 不够平滑,但使用 CoreAnimation 会创建“脉冲”运动。SceneKit 上的文档似乎非常有限,因此任何示例都将不胜感激,我目前正在这样做:
- (void)keyDown:(NSEvent *)theEvent {
int key = [theEvent keyCode];
int x = cameraNode.position.x;
int y = cameraNode.position.y;
int z = cameraNode.position.z;
int speed = 4;
if (key==123) {//left
x-=speed;
} else if (key==124) {//right
x+=speed;
} else if (key==125) {//down
y-=speed;
} else if (key==126) {//up
y+=speed;
}
//move the camera
[SCNTransaction begin];
[SCNTransaction setAnimationDuration: 1.0];
// Change properties
cameraNode.position = SCNVector3Make(x, y, z);
[SCNTransaction commit];
}