0
我有下面的代碼: 類的ViewController:UIViewController的{創建一個球體的iOS迅速
override func viewDidLoad() {
super.viewDidLoad()
let sceneView = SCNView(frame: self.view.frame)
self.view.addSubview(sceneView)
let scene = SCNScene()
sceneView.scene = scene
let camera = SCNCamera()
let cameraNode = SCNNode()
cameraNode.camera = camera
cameraNode.position = SCNVector3(x: -3.0, y: 3.0, z: 3.0)
let light = SCNLight()
light.type = SCNLightTypeOmni
let lightNode = SCNNode()
lightNode.light = light
lightNode.position = SCNVector3(x: 1.5, y: 1.5, z: 1.5)
let sphereGeometry = SCNSphere(radius: 5)
let sphereNode = SCNNode(geometry: sphereGeometry)
let constraint = SCNLookAtConstraint(target: sphereNode)
constraint.gimbalLockEnabled = true
cameraNode.constraints = [constraint]
scene.rootNode.addChildNode(lightNode)
scene.rootNode.addChildNode(cameraNode)
scene.rootNode.addChildNode(sphereNode)
}
}
然而,上述不顯示任何它成功生成。
當我改變行;
let sphereGeometry = SCNSphere(radius: 5)
來(創建多維數據集):
let cubeGeometry = SCNBox(width: 1.0, height: 1.0, length: 1.0, chamferRadius: 0.0)
我很困惑如何使球體出現。任何幫助將不勝感激:)