Я пытаюсь выучить якоря мира и не могу поставить объект на место. Я получаю следующую ошибку при запуске:
2020-02-12 11:06:20.027274+0000 Project[8336:1778069] Metal GPU Frame Capture Enabled
2020-02-12 11:06:20.027756+0000 Project[8336:1778069] Metal API Validation Enabled
2020-02-12 11:06:20.428611+0000 Project[8336:1778069] Compiler failed to build request
2020-02-12 11:06:20.428933+0000 Project[8336:1778069] [Graphics] makeRenderPipelineState failed [output of type ushort is not compatible with a MTLPixelFormatR16Float color attachement.].
2020-02-12 11:06:20.428995+0000 Project[8336:1778069] [Graphics] makeRenderPipelineState failed.
Приложение загружается нормально, но я считаю, что сбой makeRenderPipelineState может быть тем, что сдерживает меня. Я попытался найти ошибку в Интернете, но ни одна из них, похоже, не связана с тем, что есть в моем коде. Любые идеи о том, как это исправить или в чем может быть проблема? Приветствия.
Код:
//
// ViewController.swift
// Project
//
// Created by Callum King on 11/02/2020.
// Copyright © 2020 Callum King. All rights reserved.
//
import UIKit
import RealityKit
import ARKit
class ViewController: UIViewController {
@IBOutlet var arView: ARView!
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
setupARView()
arView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleTap(recognizer:))))
}
//MARK: Setup Methods
func setupARView(){
arView.automaticallyConfigureSession = false
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = [.horizontal, .vertical]
configuration.environmentTexturing = .automatic
arView.session.run(configuration)
}
//MARK: Object Placement
@objc
func handleTap(recognizer: UITapGestureRecognizer) {
let location = recognizer.location(in: arView)
let results = arView.raycast(from: location, allowing: .estimatedPlane, alignment: .any)
if let firstResult = results.first {
let anchor = ARAnchor(name: "toy_robot_vintage", transform: firstResult.worldTransform)
arView.session.add(anchor: anchor)
} else {
print("ERROR: SURFACE NOT FOUND")
}
}
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_robot_vintage" {
placeObject(named: anchorName, for: anchor)
}
}
}
}