首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ARKit -环境遮挡

ARKit -环境遮挡
EN

Stack Overflow用户
提问于 2021-12-23 07:29:43
回答 1查看 947关注 0票数 2

在统一中,我们可以用环境深度实现遮挡。它在场景后面使用ARKit。如何在iOS ARkit中实现相同的行为。

我知道我们可以配置框架语义的深度,但我怀疑它是否真的等同于统一环境的深度遮挡?

代码语言:javascript
复制
// Build the set of required frame semantics.
let semantics: ARConfiguration.FrameSemantics = [.sceneDepth]
configuration.frameSemantics = semantics

session.run(configuration)
EN

回答 1

Stack Overflow用户

发布于 2021-12-24 13:15:39

在ARKit中实现sceneReconstruction选项,在RealityKit中打开.occlusion

唯一的缺点是丑陋的面具周围有柔软膨胀的边缘.

代码语言:javascript
复制
import RealityKit
import SwiftUI
import ARKit

struct ContentView: View {
    var body: some View {
        return ARContainer().ignoresSafeArea()
    }
}

struct ARContainer: UIViewRepresentable {

    func makeUIView(context: Context) -> ARView {  
        let arView = ARView(frame: .zero)
        arView.cameraMode = .ar
                
        arView.automaticallyConfigureSession = false
        let config = ARWorldTrackingConfiguration()
        config.sceneReconstruction = .mesh
        arView.session.run(config)

        arView.environment.sceneUnderstanding.options = .occlusion

        let box: MeshResource = .generateBox(size: 0.5)
        let material = SimpleMaterial(color: .green, isMetallic: true)
        let entity = ModelEntity(mesh: box, materials: [material])
        let anchor = AnchorEntity(world: [0,0,-1.5])
        anchor.addChild(entity)
        arView.scene.anchors.append(anchor)            
        return arView
    }       
    func updateUIView(_ uiView: ARView, context: Context) { }
}
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70458954

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档