import UIKit
import SceneKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let scnView = self.view as SCNView
scnView.backgroundColor = UIColor.blackColor()
let sizeScnView = CGSize(width: 100.0, height: 100.0)
let centerView = CGPoint(x: CGRectGetMidX(self.view.frame) - sizeScnView.width/2, y: CGRectGetMidY(self.view.frame) - sizeScnView.height/2)
let scene = Tile(frame: CGRect(origin: centerView, size: sizeScnView))
scnView.scene = scene
}
}
import UIKit
import SceneKit
class Tile: SCNScene {
override init() {
super.init()
let ball = SCNSphere(radius: 0.5)
let ballNode = SCNNode(geometry: ball)
ball.firstMaterial?.diffuse.contents = UIColor.orangeColor()
self.rootNode.addChildNode(ballNode)
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
0
A
답변
1
그냥 질문 아직도 내가 작은 시험에서 이것을 실행하고 열려있는 경우 모르는이 기사를
class ViewController: UIViewController {
var sceneView: SCNView!
var camera: SCNNode!
var light: SCNNode!
var sphere1: SCNNode!
override func viewDidLoad() {
super.viewDidLoad()
let sizeScnView = CGSize(width: 420.0, height: 580.0)
let centerView = CGPoint(x: CGRectGetMidX(self.view.frame) - sizeScnView.width/2, y: CGRectGetMidY(self.view.frame) - sizeScnView.height/2)
sceneView = SCNView(frame: CGRect(origin: centerView, size: sizeScnView))
sceneView.scene = SCNScene()
self.view.addSubview(sceneView)
sceneView.backgroundColor = UIColor.blackColor()
let camera = SCNCamera()
camera.zFar = 10000
self.camera = SCNNode()
self.camera.camera = camera
self.camera.position = SCNVector3(x: -20, y: 55, z: 20)
let constraint = SCNLookAtConstraint(target: ground)
constraint.gimbalLockEnabled = true
self.camera.constraints = [constraint]
let ambientLight = SCNLight()
ambientLight.color = UIColor.darkGrayColor()
ambientLight.type = SCNLightTypeAmbient
self.camera.light = ambientLight
let spotLight = SCNLight()
spotLight.type = SCNLightTypeSpot
spotLight.castsShadow = true
spotLight.spotInnerAngle = 70.0
spotLight.spotOuterAngle = 90.0
spotLight.zFar = 500
light = SCNNode()
light.light = spotLight
light.position = SCNVector3(x: 0, y: 25, z: 25)
light.constraints = [constraint]
let sphereGeometry = SCNSphere(radius: 1.5)
let sphereMaterial = SCNMaterial()
sphereMaterial.diffuse.contents = UIColor.greenColor()
sphereGeometry.materials = [sphereMaterial]
sphere1 = SCNNode(geometry: sphereGeometry)
sphere1.position = SCNVector3(x: -15, y: 1.5, z: 0)
sceneView.scene?.rootNode.addChildNode(self.camera)
sceneView.scene?.rootNode.addChildNode(light)
sceneView.scene?.rootNode.addChildNode(sphere1)
}
}
+0
그라운드 란 무엇입니까? – swl
+0
그라운드를 루트 장면에 추가 할 수 있습니다. 줄을 지우지 않아서 죄송합니다. ///// let let constraint = SCNLookAtConstraint (target : ground) ////////// constraint.gimbalLockEnabled = true –
1
다른 UIView
당신이 (View Programming Guide for iOS 참조) SCNView
의 frame
설정할 수 있습니다.
SCNScene
인스턴스에는 2D 크기가 없습니다 (루트 노드의 경계 상자를 계산할 수 있지만 그 다른 것).
관련 문제
- 1. 인덱스를 크기보다 작게 만드는 방법
- 2. ICU를 작게 만드는 방법은 무엇입니까?
- 3. 버튼을 작게 만드는 방법은 무엇입니까?
- 4. WP7 앱에서 눈금을 화면 크기보다 크게 만드는 방법은 무엇입니까?
- 5. 게임 크기를 창 크기보다 작게 설정하십시오.
- 6. OpenFileDialog를 더 작게 만드는 간단한 방법은 무엇입니까?
- 7. , 이처럼 안드로이드와 같은 탭뷰를 구현하는 방법은 무엇입니까?
- 8. CSS로 이미지를 더 작게 만드는 방법은 무엇입니까?
- 9. ggplot의 범례 크기를 기본 크기보다 작게
- 10. 콘텐츠 크기가 화면 크기보다 크면 UITableView를 스크롤하는 방법은 무엇입니까?
- 11. 원본 크기가 아닌 이미지를 작게 만드는 방법은 무엇입니까?
- 12. 전화 화면 크기보다 큰 이미지를 표시하는 방법은 무엇입니까?
- 13. JSON 응답을 더 작게 만들기 ... 그냥 아이디어
- 14. 화면 크기보다 큰 창 설정
- 15. 정지 스크립트 화면 크기보다 작은
- 16. 화면 크기보다 큰 안드로이드보기/양식
- 17. jscrollpane으로 화면 크기보다 큰 내용
- 18. 크기가 화면 크기보다 큰 형식의 스크린 샷
- 19. UITextView를 더 작게 만드는 제약
- 20. 단추를 작게 만드는 방법
- 21. Html, CSS - 이처럼 도넛 형 차트를 만드는 방법은 무엇입니까?
- 22. exapmle에서 이처럼 간단한 이미지 회전 효과를 만드는 방법은 무엇입니까?
- 23. 이처럼 크롬 확장을 개발하는 방법은 무엇입니까
- 24. 화면 어디에서나 툴팁을 만드는 방법은 무엇입니까?
- 25. 안드로이드 EditText를 기본 높이보다 작게 만드는 방법은 무엇입니까?
- 26. 부 트랩에서 열을 더 크게 또는 작게 만드는 방법은 무엇입니까?
- 27. 큰 튜플 목록에서 튜플 목록을 작게 만드는 방법은 무엇입니까?
- 28. Java 응용 프로그램을 가능한 작게 만드는 방법은 무엇입니까?
- 29. 오른쪽 테두리 표 tcpdf를 작게 만드는 방법은 무엇입니까?
- 30. Jquery draggable : 드래그하는 동안 구성 요소를 작게 만드는 방법은 무엇입니까?
다른 어떤 결과 현재 코드에 대해 작동하지 않는 것을 설명하고, 잘 작동하는 것 같다 읽기 네가 원해. (코드처럼 보이지 않는 일부 줄에는 서식 문제가 있습니까?) – RobP
"let scene ="줄에 오류 메시지가 나타납니다. 오류 메시지 : 호출에서 추가 인수 'frame' – swl
let scene = Tile (프레임 : CGRect (x : 0, y : 0, width : 100, height : 100)) // 작동하지 않음 – swl