어제 ARKit을 맛보면서 든 생각
- configureation이 무엇일까?
- AR 컨텐츠를 사용하기 위해서는 convert과정 또는 apple이 제공하는것을 써야겠구나
- usdz도구?
ARConfiguration
An object that defines the features enabled in your AR session
: AR 세션에서 활성화된 기능을 정의하는 오브젝트
USDZ도구로 ar컨텐츠를 변환한다
잘 모르겠다,,,,,,,
음,,,,,,,뭐를 어떻게 공부해야하지요
class ViewController: UIViewController {
@IBOutlet var arView: ARView!
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
arView.session.delegate = self
setupARView()
arView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleTap(recognizer:))))
}
//Setup Methods
func setupARView(){
arView.automaticallyConfigureSession = false
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = [.horizontal, .vertical]
configuration.environmentTexturing = .automatic
arView.session.run(configuration)
}
//레이저포인터와 같이 가상의 레이저를 우리가 반응하는 서비스에,,,Object Placement
@objc
func handleTap(recognizer:UITapGestureRecognizer){
let location = recognizer.location(in: arView)
let result = arView.raycast(from: location,allowing: .estimatedPlane, alignment: .horizontal)
if let firstResult = result.first{
let anchor = ARAnchor(name : "toy_biplane", transform: firstResult.worldTransform)
arView.session.add(anchor: anchor)
}else{
print("Object placement failed - couldn't find surface.")
}
}
//model entity
func placeObject(named entityName:String, for anchor: ARAnchor){
let entity = try!ModelEntity.loadModel(named: entityName)
entity.generateCollisionShapes(recursive: true)
arView.installGestures([.rotation,.translation],for: entity)
let anchorEntity = AnchorEntity(anchor: anchor)
anchorEntity.addChild(entity)
arView.scene.addAnchor(anchorEntity)
}
}
extension ViewController : ARSessionDelegate{
func session(_ session: ARSession, didAdd anchors: [ARAnchor]) {
for anchor in anchors{
if let anchorName = anchor.name, anchorName == "toy_biplane"{
placeObject(named: anchorName, for: anchor)
}
}
}
}
반응형
'기록 > 공부기록👩🏻💻' 카테고리의 다른 글
[공부기록]100일_61일차 (0) | 2020.11.06 |
---|---|
[공부기록]100일_60일차 (0) | 2020.11.05 |
[공부기록]100일_58일차 (0) | 2020.11.03 |
[공부기록]100일_56일차 (0) | 2020.11.01 |
[공부기록]100일_55일차 (0) | 2020.10.31 |