【问题标题】:Aframe state component - rendering assetsAframe 状态组件 - 渲染资产
【发布时间】:2019-03-14 07:10:36
【问题描述】:

我想知道如何管理框架状态组件中的资产

以列表为例

<a-entity bind-for="for: shoppingItem; in: shoppingList; key: name">
  <template>
    <a-entity bind__text="value: shoppingItem.name"
              data-amount="{{ shoppingItem.amount }}"></a-entity>
  </template>
</a-entity>

我假设你会使用这样的东西

      <a-assets bind-for="for: asset; in: assets; key: id">
        <template>
            <a-asset-item response-type="arraybuffer" bind__src="asset.src" bind__id="value: asset.id" />
        </template>
      </a-assets>

但这仅适用于视频。

如果我这样设置我的初始状态

initialState: {
  hotspots: [],
  assets: [{src: 'https://example.com/assets/logo.png' , id: 'logo'}]
},

并计划使用每个资产的 src 和 id 填充这些资产数组,然后 SRC 不会将其发送到出现错误的实体:

无法读取 null 的属性“匹配” 在 FileLoader.load (aframe-master.js:28912) 在 HTMLElement.value (aframe-master.js:57743) 在 HTMLElement.wrappedMethod (aframe-master.js:59621)

我试过&lt;a-asset-item response-type="arraybuffer" src="{{asset.id}}" bind__src="value: asset.src" bind__id="value: asset.id" /&gt;

这也不起作用。

【问题讨论】:

    标签: aframe


    【解决方案1】:

    Bind 仅适用于实体。将运行时状态绑定器与资产预加载系统一起使用是没有意义的。

    &lt;a-entity bind__material="src: assetUrl"&gt;

    【讨论】:

    • 啊好吧,所以你不能使用这个系统动态预加载资产? IE。我有一个预加载图像的菜单,然后选择一个预加载资产的“游戏”。
    • 没有动态预加载资产这样的事情。预加载意味着它在场景运行之前下载并阻止场景渲染。动态意味着在场景运行时。您可以设置 src 网址。如果需要,您可以设置自己的加载屏幕,并在需要时手动收听资产加载。
    猜你喜欢
    • 2019-11-09
    • 2018-11-15
    • 2022-06-30
    • 2018-12-21
    • 2021-08-15
    • 2021-03-07
    • 2018-12-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多