标签: realitykit

RealityKit 仅显示暗图像

我正在使用 ARKit 3 和 RealityKit 开发 iOS 应用程序。我想在包含图像的房间内创建虚拟 2d 平面。因此我用了

以编程方式将材质添加到 ModelEntity

但不是接近白色的图像会显示得很暗,接近黑色。我也尝试了一下UnlitMaterial。它确实创造了更好的结果,但图像仍然很暗。JPEG 和 PNG 文件仍然存在此问题。

在我使用 SceneKit 的早期版本中,我通过解决了类似的问题

sceneView.automaticallyUpdatesLighting = true
sceneView.autoenablesDefaultLighting = true
Run Code Online (Sandbox Code Playgroud)

我想这个图像确实通过这段代码启发了自己。

如何解决 RealityKit 中的问题?

可能相关: https: //forums.developer.apple.com/thread/119265

augmented-reality ios swift arkit realitykit

6
推荐指数
1
解决办法
1521
查看次数

如何编辑已包含在 AR 项目中的 USDZ 网格?

如何编辑usdz文件并维护其中设置的装备?例如,我正在尝试编辑此示例项目中包含的 robots.usdz 网格 -

https://developer.apple.com/documentation/arkit/capturing_body_motion_in_3d

robots.usdz 文件包含在字符文件夹中。

我尝试了以下方法:

  1. 使用 scntool 转换 usdz > scn > dae。但是 scntool 无法成功转换文件
  2. 使用 ModelIO 转换 usdz > stl 文件。STL 文件丢失所有关节并且不包括几何体
  3. 尝试将节点添加到 SCN 文件 > 转换回 usdz。机器人角色无法通过 RealityKit 加载
  4. 尝试使用 Unity usdz 包管理器。在这里没有取得多大成功,无法编辑实际几何图形

您是否有推荐的管道来编辑 usdz 文件的实际网格?我没有原始的 dae 或 fbx 或 gtlf 文件。

maya scenekit arkit usdz realitykit

6
推荐指数
1
解决办法
722
查看次数

如何释放RealityKit ARView()?

我无法从内存中释放我的 RealityKit ARView()

\n\n

我知道 ARKit + SceneKit \xe2\x80\x93 存在类似问题,并具有如下解决方法:/sf/answers/3774381131/ \n这确实解决了我的问题不幸的是问题。

\n\n

上述解决方案通过手动删除所有“可疑”内容来发挥作用。这正是我在更广泛的范围内所做的:

\n\n
class ViewController_ARViewMemoryTest: UIViewController {\n\n    var arView: ARView?\n\n    init() {\n        super.init(nibName: nil, bundle: nil)\n        arView = ARView(frame: .zero)\n    }\n\n    required init?(coder: NSCoder) {\n        fatalError("init(coder:) has not been implemented")\n    }\n\n    deinit {\n        doEverythingThatsNeeded()\n    }\n\n    public func doEverythingThatsNeeded() {\n        self.arView?.session.pause()\n        self.arView?.session.delegate = nil\n        self.arView?.removeFromSuperview()\n        // Quite a few more removals and resets here, ie. for Combines AnyCancellables\n        self.arView = nil\n    }\n\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

我也从外部调用 doEverythingThatsNeeded() :

\n\n
aRViewMemoryTest?.doEverythingThatsNeeded()\naRViewMemoryTest?.arView …
Run Code Online (Sandbox Code Playgroud)

swift arkit swiftui realitykit

6
推荐指数
1
解决办法
1802
查看次数

RealityKit – 平面检测

在 RealityKit 中,与 ARKit 类似,只有在相机检测到某种平面时,对象才会显示。一旦相机检测到该表面,物体就会显示并固定在其上。

我如何知道(通过代码)相机是否检测到平坦表面?实际上,我想突出显示可选择区域,但我不确定 RealityKit 是否真的允许你这样做,我知道 SceneKit 也可以。

augmented-reality swift arkit realitykit

6
推荐指数
1
解决办法
3342
查看次数

如何防止实体重叠?

我正在尝试使用 RealityKit 创建 AR 体验,但我发现默认情况下,实体在通过用户交互移动时会相互移动并重叠。

我想防止对象重叠并相互进入,这样当用户移动它们时,它们只是撞击/反弹而不会重叠。

我从 RealityComposer 文件中加载实体并将它们添加到场景中(在 catch 块中以及此简化版本中未显示的其他块中):

let entity = try Experience.loadBallSort()
anchorEntity.addChild(entity) 
// anchorEntity is an AnchorEntity that is already attached to the scene
Run Code Online (Sandbox Code Playgroud)

我使用像这样的默认手势来启用用户交互,这就是导致对象重叠的方式,因为它们一旦触摸就不会停止:

arView.installGestures([.rotation, .translation], for: entity)
Run Code Online (Sandbox Code Playgroud)

在 Reality Composer 中,我启用了具有静态运动类型的物理功能,以及每个对象的默认物理材质/碰撞形状。我也尝试过generateCollisionShapes这样使用,但它不会改变碰撞的行为:

entity.generateCollisionShapes(recursive: true)
Run Code Online (Sandbox Code Playgroud)

如何防止 RealityKit 中的实体重叠?

augmented-reality swift arkit realitykit reality-composer

6
推荐指数
1
解决办法
1002
查看次数

RealityKit 中使用的相机的真实焦距是多少?

我正在从 Xcode 的默认 AR 项目开始做这个增强现实项目。

我需要知道 ARKit 使用的相机的焦距。

该页面很好地定义了焦距:

焦距,通常以毫米(mm)表示,是对摄影镜头的基本描述。它不是对镜头实际长度的测量,而是计算从光线会聚形成物体清晰图像的点到相机焦平面处的数字传感器或 35mm 胶片的光学距离。镜头的焦距是在镜头聚焦于无限远时确定的。

据说,苹果提供了这种称为内在函数的相机矩阵,定义为

在此输入图像描述

据苹果公司称,

值 fx 和 fy 是像素焦距,对于方形像素来说是相同的。值 ox 和 oy 是主点距图像帧左上角的偏移量。所有值均以像素表示。

fx我得到和的相同数字fy,即1515.481

要获得以毫米为单位的实际焦距,

  1. 此页面说我需要使用这个公式:F(mm) = F(pixels) * SensorWidth(mm) / ImageWidth (pixel)但我没有传感器尺寸。
  2. 另一页FC = fx/sx = fy/sy,其中sxsy是图像尺寸的宽度和高度,我想会给我两个数字,因为fx= fy... 这又回到了零平方。

在 iPhone 11 上,ARCamera 捕获以下尺寸的帧:1920x1440,至少酒店报告了这个数字camera.imageResolution

ARCamera以精神理智的名义,有没有办法获得所使用的焦距RealityKit

augmented-reality scenekit swift arkit realitykit

6
推荐指数
1
解决办法
3719
查看次数

ARKit 应用程序无法重播 Reality Composer 中录制的 ARSession

我按照此处的说明使用 Reality Composer 应用程序记录 ARKit mov 会话,但是当我加载 Xcode 并使用 ARKit 应用程序运行时,该应用程序显示黑屏并显示错误:\n该应用程序在没有 .mov 文件的情况下运行正常

\n
2021-07-17 20:57:40.773522-0700 ARKitInteraction[10346:6322385] \xe2\x9a\xa0\xef\xb8\x8f\xe2\x9a\xa0\xef\xb8\x8f\xe2\x9a\xa0\xef\xb8\x8f WARNING [MOVStreamReader]: Cannot grab metadata. Unknwon metadata stream \'CVAUserEvent\'. \xe2\x9a\xa0\xef\xb8\x8f\xe2\x9a\xa0\xef\xb8\x8f\xe2\x9a\xa0\xef\xb8\x8f\n2021-07-17 20:57:40.773645-0700 ARKitInteraction[10346:6322385] MOVReaderInterface - ERROR - Error Domain=com.apple.videoeng.streamreaderwarning Code=0 "Cannot grab metadata. Unknwon metadata stream \'CVAUserEvent\'." UserInfo={NSLocalizedDescription=Cannot grab metadata. Unknwon metadata stream \'CVAUserEvent\'.}\n2021-07-17 20:57:41.614815-0700 ARKitInteraction[10346:6322385] \xe2\x9a\xa0\xef\xb8\x8f\xe2\x9a\xa0\xef\xb8\x8f\xe2\x9a\xa0\xef\xb8\x8f WARNING [MOVStreamReader]: Cannot grab metadata. Unknwon metadata stream \'mdta/com.apple.arkit.arimagedata\'. \xe2\x9a\xa0\xef\xb8\x8f\xe2\x9a\xa0\xef\xb8\x8f\xe2\x9a\xa0\xef\xb8\x8f\n2021-07-17 20:57:41.615833-0700 ARKitInteraction[10346:6322420] \xe2\x9a\xa0\xef\xb8\x8f\xe2\x9a\xa0\xef\xb8\x8f\xe2\x9a\xa0\xef\xb8\x8f WARNING [MOVStreamReader]: Cannot grab metadata. Unknwon metadata stream \'mdta/com.apple.arkit.arimagedata\'. \xe2\x9a\xa0\xef\xb8\x8f\xe2\x9a\xa0\xef\xb8\x8f\xe2\x9a\xa0\xef\xb8\x8f\n2021-07-17 20:57:41.615940-0700 ARKitInteraction[10346:6322420] …
Run Code Online (Sandbox Code Playgroud)

replay arkit realitykit reality-composer

6
推荐指数
1
解决办法
521
查看次数

如何将视频素材添加到 ModelEntity?

我使用代码在 RealityKit 中添加图片纹理,效果很好。

var material = SimpleMaterial()

material.baseColor = try! .texture(.load(named: "image.jpg"))
Run Code Online (Sandbox Code Playgroud)

我尝试使用此代码添加视频文件作为纹理,但它崩溃了!

guard let url = Bundle.main.url(forResource: "data", withExtension: "mp4") else {
    return
}
material.baseColor = try! .texture(.load(contentsOf: url))
Run Code Online (Sandbox Code Playgroud)

如何添加视频文件?

scenekit swift arkit swiftui realitykit

5
推荐指数
2
解决办法
2132
查看次数

用于物体遮挡的 SceneKit LiDAR 功能

LiDAR 的对象遮挡可在 RealityKit 中通过场景理解选项发挥作用。基本上,扫描的几何形状用于遮挡。

arView.environment.sceneUnderstanding.options.insert(.occlusion)
Run Code Online (Sandbox Code Playgroud)

遗憾的是,这没有包含在 SceneKit 中。虽然仍然可以通过 ARMeshAnchor 从 LiDAR 获取扫描的几何图形,但必须从该几何图形手动完成对象遮挡。这是对此的讨论:苹果论坛

这种方法已经有解决方案了吗?

lidar scenekit swift arkit realitykit

5
推荐指数
1
解决办法
1130
查看次数

如何使用 RealityKit 渲染规范面网格?

I\xe2\x80\x99m 尝试使用 RealityKit 渲染面部网格,但尚未成功。因此,当 ARKit 检测到人脸时,ARSession 会生成一个 ARFaceAnchor,其中包含人脸几何网格。

\n

但它不能生成为模型实体。

\n

有人可以帮忙吗?

\n

swift arkit swiftui realitykit

5
推荐指数
1
解决办法
814
查看次数