我的光不跟着我的相机。
在将摄像机添加到场景之前,我已经将灯光添加为摄像机的childNode,但这仍然不能解决问题。
override func viewDidLoad()
{
super.viewDidLoad()
let scene = SCNScene()
let shipScene = SCNScene(named: "merchant.scn")
guard let shipNode = shipScene?.rootNode.childNode(withName: "merchant", recursively: true)
else
{
fatalError("ShipModel is not found!")
}
shipNode.position = SCNVector3(x:0, y:0, z:0)
scene.rootNode.addChildNode(shipNode)
let lightNode = SCNNode()
lightNode.light = SCNLight()
lightNode.light?.type = .omni
lightNode.position = SCNVector3(x:0, y:2, z:10)
let cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
cameraNode.position = SCNVector3(x:0, y:1, z:8)
cameraNode.addChildNode(lightNode)
scene.rootNode.addChildNode(cameraNode)
let sceneView = self.view as! SCNView
sceneView.scene = scene
sceneView.showsStatistics = true
sceneView.backgroundColor = UIColor.gray
sceneView.allowsCameraControl = true
}
无论照相机的位置如何,灯光仍然仅照亮模型的最前面。
答案 0 :(得分:0)
完美。唯一缺少的行如下。
double millisstart = datestart.getTime();
double millisend = dateend.getTime();
double millistoday = datetoday.getTime();
double percent = (((millistoday - millisstart) / (millisend - millisstart)) * 100);
percentAsString = Double.toString(percent);
txt5.setText(percentAsString);