Aframe状态组件——渲染资源
Aframe state component - rendering assets
我想知道如何在框架状态组件中管理资产
以列表为例
<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 无法到达实体并出现错误:
Cannot read property 'match' of null
at FileLoader.load (aframe-master.js:28912)
at HTMLElement.value (aframe-master.js:57743)
at HTMLElement.wrappedMethod (aframe-master.js:59621)
我试过了<a-asset-item response-type="arraybuffer" src="{{asset.id}}" bind__src="value: asset.src" bind__id="value: asset.id" />
这也不管用。
绑定仅适用于实体。将 运行 时间状态绑定器与资产 预加载 系统一起使用是没有意义的。
<a-entity bind__material="src: assetUrl">
我想知道如何在框架状态组件中管理资产
以列表为例
<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 无法到达实体并出现错误:
Cannot read property 'match' of null at FileLoader.load (aframe-master.js:28912) at HTMLElement.value (aframe-master.js:57743) at HTMLElement.wrappedMethod (aframe-master.js:59621)
我试过了<a-asset-item response-type="arraybuffer" src="{{asset.id}}" bind__src="value: asset.src" bind__id="value: asset.id" />
这也不管用。
绑定仅适用于实体。将 运行 时间状态绑定器与资产 预加载 系统一起使用是没有意义的。
<a-entity bind__material="src: assetUrl">