aFrame a-assets not finding local files

Viewed 729

I am using nuxt with aframe... if I try and get assets from local files in a-assets-item it says it can find them. when I load it over https it works fine. Normal assets like img inside the a-assets tags works 100% in getting the file locally.

<template>
  <a-scene>
    <a-assets>
      <img id="sky" src="~/assets/images/textures/sky.jpg" />

      <a-asset-item
        id="cityModel"
        src="https://cdn.aframe.io/test-models/models/glTF-2.0/virtualcity/VC.gltf"
      ></a-asset-item>
      <!-- <a-asset-item id="cityModel" src="../assets/d/castle_village_scene/out.glb"></a-asset-item> -->
      <!-- <a-asset-item id="catapult-o" src="../assets/d/catapult-obj/catapult.obj"></a-asset-item> -->
      <!-- <a-asset-item id="catapult-m" src="../assets/d/catapult-obj/catapult.mtl"></a-asset-item> -->
    </a-assets>

    <a-sky src="#sky" rotation="0 64 0"> </a-sky>

    <a-entity position="-3 0 50">
      <a-camera></a-camera>
    </a-entity>
    <a-gltf-model src="#cityModel"></a-gltf-model>
    <!-- <a-entity gltf-model="#cityModel" modify-materials></a-entity> -->
  </a-scene>
</template>
2 Answers

See A-Frame FAQ:

if you are doing local development, make sure you are using a local server so that asset requests work properly.

Web pages don't have access to the local file system

@DiegoMarcos I run into the same issue.

<a-entity gltf-model="assets/models/boy0.gltf">

works just fine, while

<a-assets>
<a-asset-item id="boy0" src="assets/models/boy0.gltf"></a-asset-item>
</a-assets> 
<a-entity gltf-model="#boy0">

produces a browser.js:111 core:propertyTypes:warn "#boy0" asset not found. while the Network tab shows the file response alright and also accessing it within the browser makes the file download correct.

Related