RealityKit–面部锚不在AR中放置模型
我正在使用RealityKit面部锚。我从Sketchfab下载了一个模型,但我试图将模型放在脸上不起作用,并且没有显示任何内容。
struct ARViewContainer: UIViewRepresentable {
func makeUIView(context: Context) -> ARView {
let arView = ARView(frame: .zero)
let configuration = ARFaceTrackingConfiguration()
arView.session.run(configuration)
let anchor = AnchorEntity(.face)
let model = try! Entity.loadModel(named: "squid-game")
anchor.addChild(model)
arView.scene.addAnchor(anchor)
return arView
}
func updateUIView(_ uiView: ARView, context: Context) { }
}
I am using RealityKit face anchors. I downloaded a model from SketchFab but I am trying to put the model on the face it does not work and does not display anything.
struct ARViewContainer: UIViewRepresentable {
func makeUIView(context: Context) -> ARView {
let arView = ARView(frame: .zero)
let configuration = ARFaceTrackingConfiguration()
arView.session.run(configuration)
let anchor = AnchorEntity(.face)
let model = try! Entity.loadModel(named: "squid-game")
anchor.addChild(model)
arView.scene.addAnchor(anchor)
return arView
}
func updateUIView(_ uiView: ARView, context: Context) { }
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
AR开发人员可以处理的最常见问题之一是模型大小。在RealityKit,Arkit,Roomplan& Scenekit,工作单元是米。经常以3DSMAX或搅拌机创建的模型以厘米级将XCode导入到Xcode中。因此,它们比应有的大100倍。您看不到模型,因为您可能在其中,并且其内部着色器的内表面没有在RealityKit中呈现。因此,您只需要扩展模型的大小。
第二个常见问题是枢轴点的位置。在99%的情况下,枢轴应在模型内部。 Model的枢轴就像“飞镖”,
.face
锚点就像“ 10分”。不幸的是,RealityKit 2.0无法控制枢轴。 Scenekit做。也有硬件约束。运行以下简单检查:
我还建议您在COMPOSER应用中打开
.usdz
模型,以确保它可以成功加载并且不是100%透明的。One of the most common problems that AR developers can deal with is model size. In RealityKit, ARKit, RoomPlan & SceneKit, the working units are meters. Quite often models created in 3dsMax or Blender are imported into Xcode in centimeter scale. Therefore, they are 100 times bigger than they should be. You cannot see your model because you may be inside it and its inner surface of shader is not rendered in RealityKit. So, all you need is to scale the size of the model.
The second common problem is a pivot point's location. In 99% of cases, the pivot should be inside the model. Model's pivot is like a "dart", and
.face
anchor is like "10 points". Unfortunately, RealityKit 2.0 does not have the ability to control the pivot. SceneKit does.There are also hardware constraints. Run the following simple check:
I also recommend you open your
.usdz
model in Reality Composer app to make sure it can be successfully loaded and is not 100% transparent.错误
?.reality
文件进行测试,还可以从Apple开发人员
网站下载示例。error
when you run the demo?.reality
file to test, and you can also download a sample from theApple Developer
site.