【问题标题】:Memory management for panorama tour全景游览的内存管理
【发布时间】:2019-09-06 03:45:24
【问题描述】:

构建 iPhone 局部全景图之旅。 其中大约有 40 多个,而且移动设备上的内存似乎快用完了。

此外,使用版本 A-frame 0.5.0,下面的代码可以在桌面上运行,但不能在最新版本 0.9.2 中运行。

<a-entity id="pano_01" visible="true">
<a-curvedimage asset-on-demand="src: ../Html_Templates/pix/Upgrade.jpg" height="145" radius="100" theta-length="300" rotation="0 33 0"></a-curvedimage>
<a-sky asset-on-demand="src: ../Html_Templates/pix/Upgrade_sky.jpg" rotation="0 -90 0"></a-sky>
<a-image asset-on-demand="src: ../Html_Templates/pix/UI_Next.png" position="0 -0.5 -3" scale="0.35 0.35 0.35" onclick="setpano_02()"></a-image>
</a-entity>

<a-entity id="pano_02" visible="false">
<a-sky asset-on-demand="src: ../Html_Templates/pix/JRO_Arrive_sky.jpg"></a-sky>
<a-curvedimage asset-on-demand="src: ../Html_Templates/pix/JRO_Arrive.jpg" height="140" radius="100.0" theta-length="300" rotation="0 60 0"></a-curvedimage>
<a-image asset-on-demand="src: ../Html_Templates/pix/UI_Next.png" position="1 -0.5 -3" scale="0.35 0.35 0.35" onclick="setpano_03()"></a-image>
<a-image asset-on-demand="src: ../Html_Templates/pix/UI_Back.png" position="-1 -0.5 -3" scale="0.35 0.35 0.35" onclick="setpano_01()"></a-image>
</a-entity>

支持上述的Java:

function setpano_01() {
 document.getElementById('pano_01').setAttribute('visible', 'true')
 document.getElementById('pano_02').setAttribute('visible', 'false')
}
function setpano_02() {
 document.getElementById('pano_01').setAttribute('visible', 'false')
 document.getElementById('pano_02').setAttribute('visible', 'true')
 document.getElementById('pano_03').setAttribute('visible', 'false')

我的期望是按需资产脚本将有助于释放内存资源,但它似乎不适用于此策略。 另外,我希望最新版本的 A-Frame 能够改进内存管理。

(我希望这个问题现在措辞更好)。

【问题讨论】:

  • 请阅读How to Ask,然后阅读edit您的问题。照原样,您的问题可能过于广泛。此外,“不起作用”不是有用的问题描述。请将您的代码添加为minimal reproducible example。当你运行它时会发生什么?你期望会发生什么?有什么错误吗?

标签: memory aframe panoramas


【解决方案1】:

有一个名为 aframe-asset on demand 的自定义组件。 https://www.npmjs.com/package/aframe-asset-on-demand-component

它将图像作为资产动态加载,并将它们从内存中删除。 这可能会解决您的图形内存问题。

“不再需要时从内存中删除资源。如果您只是从实体中删除纹理,它不会完全从 THREE.JS 中删除,并且仍然使用宝贵的内存(特别是在移动设备上很宝贵)。A-Frame Asset OnDemand 确保以释放内存的方式删除资产。”

我通过谷歌搜索“aframe 动态加载资产”发现了这一点

【讨论】:

  • 感谢您的回复。我实际上正在使用按需资产组件。就它获取资产而言,它确实有效,但它似乎确实如此有效地完成了清算部分。由于我使用切换实体部分可见性的策略,我怀疑它可能不适合组件的方案。
  • 另外,有趣的是,代码在 0.5.0 版本下运行良好。但不是在较新的版本下。我非常希望获得帮助以使其与当前版本 0.9.2 保持同步。
  • 我建议将项目简化为单个加载图像并删除,并监视 vram 以查看您是否实际上在删除时清除内存。我看不出实体的可见性变化会如何影响资产的删除,但也许有什么东西阻止了显卡释放内存。当你让简单的图像添加和删除工作正常时,慢慢添加其他功能,并注意何时开始出现故障。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-05-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-05
  • 2015-11-24
相关资源
最近更新 更多