1

我正在尝试gltf2.0使用ar.js. 我已经尝试了几次,但我认为我在某些方面是错误的。这是代码:

    <script src="https://cdn.rawgit.com/jeromeetienne/AR.js/1.5.0/aframe/examples/vendor/aframe/build/aframe.min.js"></script>
<script src="https://cdn.rawgit.com/jeromeetienne/AR.js/1.5.0/aframe/build/aframe-ar.js"></script>
<script src="https://rawgit.com/donmccurdy/aframe-extras/master/dist/aframe-extras.loaders.min.js"></script>
<body style='margin : 0px; overflow: hidden;'>
    <a-scene embedded arjs='trackingMethod: best;'>
      <a-anchor hit-testing-enabled='true'>
      <a-gltf-model-next src="damagedHelmet/damagedHelmet.gltf" scale="0.5 0.5 0.5"></a-gltf-model>
      </a-anchor>
        <a-camera-static/>
    </a-scene>
</body>

gltf 模型的文件夹与 html 代码所在的文件夹相同。谁能帮我解决这个问题?

4

1 回答 1

1

这是旧aframe版本的已知问题,但是您的代码有额外的问题。提高你的aframe版本和aframe-ar版本。删除aframe-extras脚本,在新版本中不需要。摆脱a-anchor并最后添加一个标记a-marker-camera

<script src="https://aframe.io/releases/0.8.0/aframe.min.js"></script>
<script src="https://cdn.rawgit.com/jeromeetienne/AR.js/1.5.5/aframe/build/aframe-ar.js"></script>
<body style='margin : 0px; overflow: hidden;'>
    <a-scene embedded arjs='trackingMethod: best;'>
      <a-gltf-model src="https://rawgit.com/KhronosGroup/glTF-Sample-Models/master/2.0/DamagedHelmet/glTF/DamagedHelmet.gltf"></a-gltf-model>
      <a-marker-camera preset='hiro'></a-marker-camera>
      <a-camera-static/>
    </a-scene>
</body>

运行代码)(下载标记

或者,如果您想保留旧aframe库,可以使用a-assets如下方式加载模型:

<script src="https://cdn.rawgit.com/jeromeetienne/AR.js/1.5.0/aframe/examples/vendor/aframe/build/aframe.min.js"></script>
<script src="https://cdn.rawgit.com/jeromeetienne/AR.js/1.5.0/aframe/build/aframe-ar.js"></script>
<body style='margin : 0px; overflow: hidden;'>
    <a-scene embedded arjs='trackingMethod: best;'>
    <a-assets>
    <a-asset-item id="model" src="https://rawgit.com/KhronosGroup/glTF-Sample-Models/master/1.0/CesiumMan/glTF/CesiumMan.gltf" crossOrigin="anonymous"></a-asset-item> 
  </a-assets>
  <a-gltf-model src="#model"></a-gltf-model>
  <a-marker-camera preset='hiro'></a-marker-camera>
    <a-camera-static/>
    </a-scene>
</body>

运行代码)(下载标记

但请注意,您只能加载gltf 1.0模型(头盔是gltf 2.0

于 2018-04-19T09:30:12.393 回答