Hello! I had a similar issue. Adding OrthographicCameraComponent does not crash anymore, but it crashed for me when computing a projection from the world coordinates to screen coordinates or another way around.
import SwiftUI
import RealityKit
struct ContentView: View {
var body: some View {
RealityView { content in
var camera = Entity()
var component = OrthographicCameraComponent()
component.scale = 5
camera.position = [0, 0, 5]
camera.components.set(component)
content.add(camera)
content.add(ModelEntity(mesh: .generateSphere(radius: 1)))
} update: { content in
if let p = content.project(point: [0, 0, 0], to: .local) {
print(p)
}
}
}
}
#Preview {
ContentView()
}
Topic:
Graphics & Games
SubTopic:
RealityKit
Tags: