Machineboy空
Reality Composer Pro Animations, 애니메이션 있는 usdz파일 넣기 본문
오늘의 목표
Reality Composer Pro에 Animation이 실행되는 usdz파일을 넣고, 이를 ARView에 띄워보겠다.
찾아본 것들..
https://www.youtube.com/watch?v=pJ3D20zNd18
예전 튜토리얼들을 살펴보면 Reality Composer Pro UI가 달라서
Action Sequence 창을 도무지 어떻게 띄우는지를 모르겠다..
**저건 Reality Composer였다..
https://developer.apple.com/documentation/visionos/diorama
가장 유명한 Diorama 예제인데 visionOS 빌드 전용의 RealityView이다..
iOS에 띄울 ARView에서는 realitykitcontent 라이브러리를 import하여 사용할 수가 없고,
RealityView를 컨테이너에 담아 ARView에 띄우기란 스택오버플로우 답변상 아마 불가능한 것 같다.
Diorama 예제 속 독수리는 이미 animation이 들어있는 채로 import되어 사용되고 있다..
animation이 포함된 usdz파일은 어떻게 만드는 거고,
Reality Composer Pro에서 animation을 넣는 거라면 어떻게 하는 건지 방법을 찾아보겠음.
Solution: 애초에 animation 들어있는 모델 구해서 스크립트 제어
Diorama 관련 WWDC 봐도, 이미 animation이 있는 모델을 import했다고 나온다.
import SwiftUI
import RealityKit
import ARKit
struct ContentView : View {
var body: some View {
ARViewContainer().edgesIgnoringSafeArea(.all)
}
}
struct ARViewContainer: UIViewRepresentable {
func makeUIView(context: Context) -> ARView {
let arView = ARView(frame: .zero)
arView.addCoaching()
// Load the model with embedded animation
let model = try! ModelEntity.loadModel(named: "Camelon")
model.scale = SIMD3(x: 2.5, y: 2.5, z: 2.5)
model.generateCollisionShapes(recursive: true)
// Play the embedded animation in a loop
if let animation = model.availableAnimations.first {
model.playAnimation(animation.repeat(), transitionDuration: 0.5, startsPaused: false)
}
// Create horizontal plane anchor for the content
let anchor = AnchorEntity(.plane(.horizontal, classification: .any, minimumBounds: SIMD2<Float>(0.2, 0.2)))
anchor.children.append(model)
// Add the horizontal plane anchor to the scene
arView.scene.anchors.append(anchor)
return arView
}
func updateUIView(_ uiView: ARView, context: Context) {}
}
extension ARView: ARCoachingOverlayViewDelegate {
func addCoaching(){
let coachingOverlay = ARCoachingOverlayView()
coachingOverlay.goal = .horizontalPlane
coachingOverlay.session = self.session
coachingOverlay.autoresizingMask = [.flexibleWidth, .flexibleHeight]
self.addSubview(coachingOverlay)
}
}
#Preview {
ContentView()
}
// Animation 재생 함수 숙지
let model = try! ModelEntity.loadModel(named: "Camelon")
model.scale = SIMD3(x: 2.5, y: 2.5, z: 2.5)
model.generateCollisionShapes(recursive: true)
if let animation = model.availableAnimations.first {
model.playAnimation(animation.repeat(), transitionDuration: 0.5, startsPaused: false)
}
어찌저찌 성공!
이제 Reality Composer Pro 상에서 animation에 접근하는 방법을 찾아보자..
우선 이것저것 다 눌러보니 Statistics안에 Animation이 있긴 한데 이건 정말 수치를 보여주는 창인듯 하다.
WWDC의 Animation관련 내용은.. 2024부터 적용된 건지 창이 나랑 다르다..
https://medium.com/daily-monster/wwdc23-meet-reality-composer-pro-082bb13635b8
또 다른 튜토리얼들을 보면 iOS나 iPad에서만 지원된다는 Reality Composer 을 사용해서 Animation을 제어하고 있다..
대체 mac 지원은 왜 안되는 것이고.. 사람들은 왜 손 터치로 3D를 만지고 있는거지.. 이해가 안가는 애플 AR 생태계
https://apps.apple.com/kr/app/reality-composer/id1462358802
여튼 2024 리뉴얼된 Reality Composer Pro에서 기존 내장된 Animation API도 사용이 가능하고, Animation을 배열로 저장하고서 State 관리도 가능하다는 것을 확인했으나.. 그 리뉴얼된 리얼리티 컴포저 프로 대체 어디서 다운받는지 모르겠음..
일단 고급기능은 차차 알아가보는 걸로!
'언어 > swift' 카테고리의 다른 글
특정 건물을 인식해보자! - Vision Framework, CreateML 흘겨 보기 (5) | 2024.10.03 |
---|---|
RealityKit SceneReconstruction, 환경 인식 관련 (0) | 2024.10.02 |
Augmented Reality: ARKit의 대략적 원리(VIO, 평면 감지, 오브젝트 분류) (0) | 2024.07.07 |
Augmented Reality: RealityKit VS SceneKit 비교 (3) 기본 구성 (Entity, Node) (0) | 2024.06.24 |
Augmented Reality: RealityKit VS SceneKit 비교 (2) 좌표축, 크기 단위 (1) | 2024.06.23 |