AR/VR相关资料

ar.js主要基于两个开源项目:three.js和jsartoolkit5,3D场景加载、演示部分是使用three.js实现,Marker追踪识别则是由jsartoolkit5实现。
ar.js文档: https://ar-js-org.github.io/AR.js-Docs
AR.js中提供了图像跟踪(Image Tracking)、基于定位(Location Based)、基于标记(Marker Based) 三种模式。
图像跟踪模式是通过设备摄像头,扫描图片、绘画、照片等内容,从而定位场景的模式,是用 自然特征点跟踪(Nature Feature Tracking、NFT) 技术,将图片中的特征点进行提取。然后通过识别影像中是否存在这些特征点,来确定图像的位置和方向,构建场景,进一步加载或者渲染期望的模型。厉害的是,生成特征时用的是图片,但检测的时候可以是实物

#官方的demo js由于访问受限可能加载不到,所以这里我把js放在服务器了
<script src="aframe-master.min.js"></script>
<script src="aframe-ar-nft.js"></script>
  <script>
       // 注册markerhandler组件
       // 该组件中注册了,当场景中检测到图像时触发的事件
       AFRAME.registerComponent('markerhandler', {
           init: function () {
               this.el.sceneEl.addEventListener('markerFound', () => {
                   alert('hello ar!')
               });
           }
       });
   </script>

<style>
 .arjs-loader {
   height: 100%;
   width: 100%;
   position: absolute;
   top: 0;
   left: 0;
   background-color: rgba(0, 0, 0, 0.8);
   z-index: 9999;
   display: flex;
   justify-content: center;
   align-items: center;
 }

 .arjs-loader div {
   text-align: center;
   font-size: 1.25em;
   color: white;
 }
</style>

<body style="margin : 0px; overflow: hidden;">
 <!-- minimal loader shown until image descriptors are loaded -->
 <div class="arjs-loader">
   <div>Loading, please wait...</div>
 </div>
 <a-scene
   vr-mode-ui="enabled: false;"
   renderer="logarithmicDepthBuffer: true;"
   embedded
   arjs="trackingMethod: best; sourceType: webcam;debugUIEnabled: false;"
 >
   <!-- we use cors proxy to avoid cross-origin problems -->
     
       <!--url=" https://arjs-cors-proxy.herokuapp.com/https://raw.githack.com/AR-js-org/AR.js/master/aframe/examples/image-tracking/nft/trex/trex-image/trex"-->

   <a-nft markerhandler 
     type="nft"
   
    url="nft/nft"
     smooth="true"
     smoothCount="10"
     smoothTolerance=".01"
     smoothThreshold="5"
   >
     <a-entity
       gltf-model="https://arjs-cors-proxy.herokuapp.com/https://raw.githack.com/AR-js-org/AR.js/master/aframe/examples/image-tracking/nft/trex/scene.gltf"
       scale="1 1 1"
       position="50 150 0"
     >
     </a-entity>
   </a-nft>
   <a-entity camera></a-entity>
 </a-scene>
</body>

图像追踪 特征生成工具: https://carnaux.github.io/NFT-Marker-Creator/#/

mind-ar: https://hiukim.github.io/mind-ar-js-doc/tools/compile
AR 手势交互: https://github.com/fcor/arjs-gestures
资源下载:
aframe-ar-nft.js: https://download.csdn.net/download/weixin_37391237/85765460
aframe-master.min.js: lhttps://download.csdn.net/download/weixin_37391237/85765451

注意:
手机浏览器打开摄像头需要https协议(必须)

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值