使用 SceneKit 在 AR 中预加载资源

发布于 2025-01-09 00:50:42 字数 1031 浏览 0 评论 0原文

在我们使用 SceneKit 制作的 AR 应用程序和 appclip 中,当我们使 3D 内容出现在体验的不同步骤时,我们会遇到帧速率显着下降的情况。我们在 iPhone X (iOS 15.2.1)、iPhone 12 Pro (iOS 14) 和 iPad Pro 2020 (iPad OS 14.8.1) 上进行了测试。

目前,我们所有的 3D 对象都在主场景中。那些应该出现在体验中某个时刻的对象在开始时将其不透明度设置为 0.01,然后通过 SCNAction 淡入(我们尝试在开始时将其不透明度设置为 0.01 的原因是为了确保这些对象是从体验开始时呈现)。

但是,如果从体验开始就将所有对象的不透明度设置为 1,我们不会遇到任何 fps 下降。

值得注意的是,帧率下降仅发生在第一次打开应用程序时。如果我关闭它并重新打开它,它就会展开而不会出现任何冻结。

加载(或预加载)这些 3D 元素以避免这些冻结的最佳方法是什么?

有人告诉我prepareObject:shouldAbortBlock:和prepareObjects:withCompletionHandler方法可以解决我们的问题。

在我们的例子中,SceneView 是 ARCNView,因此我们似乎无法访问 SCNSceneRenderer 方法。我们只成功实现了“Prepare”方法来预加载我们的资源: https://developer.apple.com/documentation/scenekit/scnscenerenderer/1523375-准备

它似乎正在做一些事情,因为我们在体验开始时的冻结时间明显更长,但是,我们仍然体验到相同的 fps当我们的物体第一次出现时,我们的体验就会下降。

是否有关于如何在 ARCNView 中使用prepareObject:shouldAbortBlock: 和prepareObjects:withCompletionHandler 方法的文档?

In our AR app and appclip made with SceneKit, we experience very significant drops in framerate when we make our 3D content appear at different steps of the experience. We have conducted our tests on an iPhone X (iOS 15.2.1), on an iPhone 12 Pro (iOS 14), and on an iPad Pro 2020 (iPad OS 14.8.1).

For now, all of our 3D objects are in our Main Scene. Those which are supposed to appear at some point in the experience have their opacity set to 0.01 at the beginning and then fade in with a SCNAction (the reason why we tried setting their opacity to 0.01 at the start was to make sure that these objects are rendered from the start of the experience).

However, if the objects all have their opacity set to 1 from the start of the experience, we do not experience any fps drop.

It is worth noting that the fps drops only happen the first time the app is opened. If I close it and re-open it, then it unfolds without any freeze.

What would be the best way to load (or pre-load) these 3D elements to avoid these freezes?

I have been told the prepareObject:shouldAbortBlock: and the prepareObjects:withCompletionHandler methods could solve our problem.

In our case the SceneView is an ARCNView, so we can't seem to access the SCNSceneRenderer methods. We have only managed to implement the "Prepare" method to preload our assets:
https://developer.apple.com/documentation/scenekit/scnscenerenderer/1523375-prepare

It seems to be doing something because we get a significantly longer freeze at the start of the experience, however, we still experience the same fps drops during the experience when our objects appear for the first time.

Is there any documentation on how to use the prepareObject:shouldAbortBlock: and the prepareObjects:withCompletionHandler methods in an ARCNView?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文