#ios #swift #uikit #realitykit
Вопрос:
Я пытаюсь загрузить армодель с помощью RealityKit, добавив привязку к arView.scene, однако я получаю сообщение об ошибке: «Поток 1: EXC_BAD_ACCESS (код=2, адрес=0x1eb6f4938)». Как мне устранить эту ошибку?
import UIKit import AVFoundation import Vision import RealityKit class ViewController: UIViewController, AVCaptureVideoDataOutputSampleBufferDelegate { var bufferSize: CGSize = .zero var rootLayer: CALayer! = nil private let session = AVCaptureSession() private var previewLayer: AVCaptureVideoPreviewLayer! = nil private let videoDataOutput = AVCaptureVideoDataOutput() private let videoDataOutputQueue = DispatchQueue(label: "VideoDataOutput", qos: .userInitiated, attributes: [], autoreleaseFrequency: .workItem) @IBOutlet var previewView: ARView! func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) { // to be implemented in the subclass } override func viewDidLoad() { super.viewDidLoad() setupAVCapture() let sphere = MeshResource.generateSphere(radius: 0.05) let material = SimpleMaterial(color: .red, roughness: 0, isMetallic: true) let sphereEntitity = ModelEntity(mesh:sphere, materials: [material]) let sphereAnchor = AnchorEntity(world: SIMD3(x:0, y:0, z:0)) sphereAnchor.addChild(sphereEntitity) self.previewView.scene.addAnchor(sphereAnchor) }