首页 > 解决方案 > AR.js aframe 对象显示也没有指向标记

问题描述

在我的 AR 项目中,当我用手机摄像头指向我的 hiro 图案时,我使用带有 aframe 的 arjs 来使我的 gltf 对象可见:

<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
<!-- include ar.js for A-Frame -->
<script src="https://jeromeetienne.github.io/AR.js/aframe/build/aframe-ar.js"></script>
<script src="https://unpkg.com/aframe-orbit-controls@1.2.0/dist/aframe-orbit-controls.min.js"></script> 

<body style='margin : 0px; overflow: hidden;'>
  <a-scene embedded arjs>
    <!-- define your gltf asset -->
    <!--This is for add a text-->
    <!--<a-text value="Hello, World!"></a-text>-->
    <!--This is for add an image-->
    <!--<a-image src="another-image.png"></a-image>-->
    <a-assets>
      <a-asset-item id="tree" src="models/gltf/manovella.gltf"></a-asset-item>
    </a-assets>
    <a-entity gltf-model="#tree" position="0 0 0" rotation="0 90 0" scale="10 10 10"></a-entity>

    <a-entity camera look-controls orbit-controls="target: 0 1.6 -0.5; minDistance: 0.5; maxDistance: 180; initialPosition: 0 5 15">
      <!-- define a camera which will move according to the marker position -->
      <a-marker-camera preset='hiro'></a-marker-camera>
    </a-entity>
  </a-scene>
</body>

当我指向我的标记全部完成时,问题也是当我启动我的应用程序而不指向任何市场时,对象会出现,当我不再在框架中看到标记时,对象仍保留在屏幕上。如何管理仅与我的标记相关的 gltf 显示/隐藏?

非常感谢提前

标签: three.jsaframear.js

解决方案


您的对象应该在您的标记内。尝试在您的场景中使用它:

<a-assets>
  <a-asset-item id="tree" src="models/gltf/manovella.gltf"></a-asset-item>
</a-assets>
  <!-- define a camera which will move according to the marker position -->
  <a-marker-camera preset='hiro'><a-entity gltf-model="#tree" position="0 0 0" rotation="0 90 0" scale="10 10 10"></a-entity></a-marker-camera>
<a-entity camera look-controls orbit-controls="target: 0 1.6 -0.5; minDistance: 0.5; maxDistance: 180; initialPosition: 0 5 15"></a-entity>

推荐阅读