Browse Source

修复部分bug

“hujiajun” 6 months ago
parent
commit
e14254849e

File diff suppressed because it is too large
+ 2 - 44
Assets/Scenes/Game.unity


File diff suppressed because it is too large
+ 0 - 0
Assets/WebGLTemplates/iTracker/arcamera.js


+ 575 - 0
Assets/WebGLTemplates/iTracker/demo.js

@@ -0,0 +1,575 @@
+/*
+ * 注意:
+ * 1. 所有的JS接口只能在公众号绑定的域名下调用,公众号开发者需要先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”。
+ * 2. 如果发现在 Android 不能分享自定义内容,请到官网下载最新的包覆盖安装,Android 自定义分享接口需升级至 6.0.2.58 版本及以上。
+ * 3. 完整 JS-SDK 文档地址:http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html
+ *
+ * 如有问题请通过以下渠道反馈:
+ * 邮箱地址:weixin-open@qq.com
+ * 邮件主题:【微信JS-SDK反馈】具体问题
+ * 邮件内容说明:用简明的语言描述问题所在,并交代清楚遇到该问题的场景,可附上截屏图片,微信团队会尽快处理你的反馈。
+ */
+wx.ready(function () {
+  // 1 判断当前版本是否支持指定 JS 接口,支持批量判断
+  document.querySelector('#checkJsApi').onclick = function () {
+    wx.checkJsApi({
+      jsApiList: [
+        'getNetworkType',
+        'previewImage'
+      ],
+      success: function (res) {
+        alert(JSON.stringify(res));
+      }
+    });
+  };
+
+  // 2. 分享接口
+  // 2.1 监听“分享给朋友”,按钮点击、自定义分享内容及分享结果接口
+  document.querySelector('#onMenuShareAppMessage').onclick = function () {
+    wx.onMenuShareAppMessage({
+      title: '互联网之子',
+      desc: '在长大的过程中,我才慢慢发现,我身边的所有事,别人跟我说的所有事,那些所谓本来如此,注定如此的事,它们其实没有非得如此,事情是可以改变的。更重要的是,有些事既然错了,那就该做出改变。',
+      link: 'http://movie.douban.com/subject/25785114/',
+      imgUrl: 'http://demo.open.weixin.qq.com/jssdk/images/p2166127561.jpg',
+      trigger: function (res) {
+        // 不要尝试在trigger中使用ajax异步请求修改本次分享的内容,因为客户端分享操作是一个同步操作,这时候使用ajax的回包会还没有返回
+        alert('用户点击发送给朋友');
+      },
+      success: function (res) {
+        alert('已分享');
+      },
+      cancel: function (res) {
+        alert('已取消');
+      },
+      fail: function (res) {
+        alert(JSON.stringify(res));
+      }
+    });
+    alert('已注册获取“发送给朋友”状态事件');
+  };
+
+  // 2.2 监听“分享到朋友圈”按钮点击、自定义分享内容及分享结果接口
+  document.querySelector('#onMenuShareTimeline').onclick = function () {
+    wx.onMenuShareTimeline({
+      title: '互联网之子',
+      link: 'http://movie.douban.com/subject/25785114/',
+      imgUrl: 'http://demo.open.weixin.qq.com/jssdk/images/p2166127561.jpg',
+      trigger: function (res) {
+        // 不要尝试在trigger中使用ajax异步请求修改本次分享的内容,因为客户端分享操作是一个同步操作,这时候使用ajax的回包会还没有返回
+        alert('用户点击分享到朋友圈');
+      },
+      success: function (res) {
+        alert('已分享');
+      },
+      cancel: function (res) {
+        alert('已取消');
+      },
+      fail: function (res) {
+        alert(JSON.stringify(res));
+      }
+    });
+    alert('已注册获取“分享到朋友圈”状态事件');
+  };
+
+  // 2.3 监听“分享到QQ”按钮点击、自定义分享内容及分享结果接口
+  document.querySelector('#onMenuShareQQ').onclick = function () {
+    wx.onMenuShareQQ({
+      title: '互联网之子',
+      desc: '在长大的过程中,我才慢慢发现,我身边的所有事,别人跟我说的所有事,那些所谓本来如此,注定如此的事,它们其实没有非得如此,事情是可以改变的。更重要的是,有些事既然错了,那就该做出改变。',
+      link: 'http://movie.douban.com/subject/25785114/',
+      imgUrl: 'http://img3.douban.com/view/movie_poster_cover/spst/public/p2166127561.jpg',
+      trigger: function (res) {
+        alert('用户点击分享到QQ');
+      },
+      complete: function (res) {
+        alert(JSON.stringify(res));
+      },
+      success: function (res) {
+        alert('已分享');
+      },
+      cancel: function (res) {
+        alert('已取消');
+      },
+      fail: function (res) {
+        alert(JSON.stringify(res));
+      }
+    });
+    alert('已注册获取“分享到 QQ”状态事件');
+  };
+  
+  // 2.4 监听“分享到微博”按钮点击、自定义分享内容及分享结果接口
+  document.querySelector('#onMenuShareWeibo').onclick = function () {
+    wx.onMenuShareWeibo({
+      title: '互联网之子',
+      desc: '在长大的过程中,我才慢慢发现,我身边的所有事,别人跟我说的所有事,那些所谓本来如此,注定如此的事,它们其实没有非得如此,事情是可以改变的。更重要的是,有些事既然错了,那就该做出改变。',
+      link: 'http://movie.douban.com/subject/25785114/',
+      imgUrl: 'http://img3.douban.com/view/movie_poster_cover/spst/public/p2166127561.jpg',
+      trigger: function (res) {
+        alert('用户点击分享到微博');
+      },
+      complete: function (res) {
+        alert(JSON.stringify(res));
+      },
+      success: function (res) {
+        alert('已分享');
+      },
+      cancel: function (res) {
+        alert('已取消');
+      },
+      fail: function (res) {
+        alert(JSON.stringify(res));
+      }
+    });
+    alert('已注册获取“分享到微博”状态事件');
+  };
+
+  // 2.5 监听“分享到QZone”按钮点击、自定义分享内容及分享接口
+  document.querySelector('#onMenuShareQZone').onclick = function () {
+    wx.onMenuShareQZone({
+      title: '互联网之子',
+      desc: '在长大的过程中,我才慢慢发现,我身边的所有事,别人跟我说的所有事,那些所谓本来如此,注定如此的事,它们其实没有非得如此,事情是可以改变的。更重要的是,有些事既然错了,那就该做出改变。',
+      link: 'http://movie.douban.com/subject/25785114/',
+      imgUrl: 'http://img3.douban.com/view/movie_poster_cover/spst/public/p2166127561.jpg',
+      trigger: function (res) {
+        alert('用户点击分享到QZone');
+      },
+      complete: function (res) {
+        alert(JSON.stringify(res));
+      },
+      success: function (res) {
+        alert('已分享');
+      },
+      cancel: function (res) {
+        alert('已取消');
+      },
+      fail: function (res) {
+        alert(JSON.stringify(res));
+      }
+    });
+    alert('已注册获取“分享到QZone”状态事件');
+  };
+
+
+  // 3 智能接口
+  var voice = {
+    localId: '',
+    serverId: ''
+  };
+  // 3.1 识别音频并返回识别结果
+  document.querySelector('#translateVoice').onclick = function () {
+    if (voice.localId == '') {
+      alert('请先使用 startRecord 接口录制一段声音');
+      return;
+    }
+    wx.translateVoice({
+      localId: voice.localId,
+      complete: function (res) {
+        if (res.hasOwnProperty('translateResult')) {
+          alert('识别结果:' + res.translateResult);
+        } else {
+          alert('无法识别');
+        }
+      }
+    });
+  };
+
+  // 4 音频接口
+  // 4.2 开始录音
+  document.querySelector('#startRecord').onclick = function () {
+    wx.startRecord({
+      cancel: function () {
+        alert('用户拒绝授权录音');
+      }
+    });
+  };
+
+  // 4.3 停止录音
+  document.querySelector('#stopRecord').onclick = function () {
+    wx.stopRecord({
+      success: function (res) {
+        voice.localId = res.localId;
+      },
+      fail: function (res) {
+        alert(JSON.stringify(res));
+      }
+    });
+  };
+
+  // 4.4 监听录音自动停止
+  wx.onVoiceRecordEnd({
+    complete: function (res) {
+      voice.localId = res.localId;
+      alert('录音时间已超过一分钟');
+    }
+  });
+
+  // 4.5 播放音频
+  document.querySelector('#playVoice').onclick = function () {
+    if (voice.localId == '') {
+      alert('请先使用 startRecord 接口录制一段声音');
+      return;
+    }
+    wx.playVoice({
+      localId: voice.localId
+    });
+  };
+
+  // 4.6 暂停播放音频
+  document.querySelector('#pauseVoice').onclick = function () {
+    wx.pauseVoice({
+      localId: voice.localId
+    });
+  };
+
+  // 4.7 停止播放音频
+  document.querySelector('#stopVoice').onclick = function () {
+    wx.stopVoice({
+      localId: voice.localId
+    });
+  };
+
+  // 4.8 监听录音播放停止
+  wx.onVoicePlayEnd({
+    complete: function (res) {
+      alert('录音(' + res.localId + ')播放结束');
+    }
+  });
+
+  // 4.8 上传语音
+  document.querySelector('#uploadVoice').onclick = function () {
+    if (voice.localId == '') {
+      alert('请先使用 startRecord 接口录制一段声音');
+      return;
+    }
+    wx.uploadVoice({
+      localId: voice.localId,
+      success: function (res) {
+        alert('上传语音成功,serverId 为' + res.serverId);
+        voice.serverId = res.serverId;
+      }
+    });
+  };
+
+  // 4.9 下载语音
+  document.querySelector('#downloadVoice').onclick = function () {
+    if (voice.serverId == '') {
+      alert('请先使用 uploadVoice 上传声音');
+      return;
+    }
+    wx.downloadVoice({
+      serverId: voice.serverId,
+      success: function (res) {
+        alert('下载语音成功,localId 为' + res.localId);
+        voice.localId = res.localId;
+      }
+    });
+  };
+
+  // 5 图片接口
+  // 5.1 拍照、本地选图
+  var images = {
+    localId: [],
+    serverId: []
+  };
+  document.querySelector('#chooseImage').onclick = function () {
+    wx.chooseImage({
+      success: function (res) {
+        images.localId = res.localIds;
+        alert('已选择 ' + res.localIds.length + ' 张图片');
+      }
+    });
+  };
+
+  // 5.2 图片预览
+  document.querySelector('#previewImage').onclick = function () {
+    wx.previewImage({
+      current: 'http://img5.douban.com/view/photo/photo/public/p1353993776.jpg',
+      urls: [
+        'http://img3.douban.com/view/photo/photo/public/p2152117150.jpg',
+        'http://img5.douban.com/view/photo/photo/public/p1353993776.jpg',
+        'http://img3.douban.com/view/photo/photo/public/p2152134700.jpg'
+      ]
+    });
+  };
+
+  // 5.3 上传图片
+  document.querySelector('#uploadImage').onclick = function () {
+    if (images.localId.length == 0) {
+      alert('请先使用 chooseImage 接口选择图片');
+      return;
+    }
+    var i = 0, length = images.localId.length;
+    images.serverId = [];
+    function upload() {
+      wx.uploadImage({
+        localId: images.localId[i],
+        isShowProgressTips: 1,
+        success: function (res) {
+          i++;
+          //alert('已上传:' + i + '/' + length);
+          images.serverId.push(res.serverId);
+          if (i < length) {
+            upload();
+          }
+        },
+        fail: function (res) {
+          alert(JSON.stringify(res));
+        }
+      });
+    }
+    upload();
+  };
+
+  // 5.4 下载图片
+  document.querySelector('#downloadImage').onclick = function () {
+    if (images.serverId.length === 0) {
+      alert('请先使用 uploadImage 上传图片');
+      return;
+    }
+    var i = 0, length = images.serverId.length;
+    images.localId = [];
+    function download() {
+      wx.downloadImage({
+        serverId: images.serverId[i],
+        success: function (res) {
+          i++;
+          alert('已下载:' + i + '/' + length);
+          images.localId.push(res.localId);
+          if (i < length) {
+            download();
+          }
+        }
+      });
+    }
+    download();
+  };
+
+  // 6 设备信息接口
+  // 6.1 获取当前网络状态
+  document.querySelector('#getNetworkType').onclick = function () {
+    wx.getNetworkType({
+      success: function (res) {
+        alert(res.networkType);
+      },
+      fail: function (res) {
+        alert(JSON.stringify(res));
+      }
+    });
+  };
+
+  // 7 地理位置接口
+  // 7.1 查看地理位置
+  document.querySelector('#openLocation').onclick = function () {
+    wx.openLocation({
+      latitude: 23.099994,
+      longitude: 113.324520,
+      name: 'TIT 创意园',
+      address: '广州市海珠区新港中路 397 号',
+      scale: 14,
+      infoUrl: 'http://weixin.qq.com'
+    });
+  };
+
+  // 7.2 获取当前地理位置
+  document.querySelector('#getLocation').onclick = function () {
+    wx.getLocation({
+      success: function (res) {
+        alert(JSON.stringify(res));
+      },
+      cancel: function (res) {
+        alert('用户拒绝授权获取地理位置');
+      }
+    });
+  };
+
+  // 8 界面操作接口
+  // 8.1 隐藏右上角菜单
+  document.querySelector('#hideOptionMenu').onclick = function () {
+    wx.hideOptionMenu();
+  };
+
+  // 8.2 显示右上角菜单
+  document.querySelector('#showOptionMenu').onclick = function () {
+    wx.showOptionMenu();
+  };
+
+  // 8.3 批量隐藏菜单项
+  document.querySelector('#hideMenuItems').onclick = function () {
+    wx.hideMenuItems({
+      menuList: [
+        'menuItem:readMode', // 阅读模式
+        'menuItem:share:timeline', // 分享到朋友圈
+        'menuItem:copyUrl' // 复制链接
+      ],
+      success: function (res) {
+        alert('已隐藏“阅读模式”,“分享到朋友圈”,“复制链接”等按钮');
+      },
+      fail: function (res) {
+        alert(JSON.stringify(res));
+      }
+    });
+  };
+
+  // 8.4 批量显示菜单项
+  document.querySelector('#showMenuItems').onclick = function () {
+    wx.showMenuItems({
+      menuList: [
+        'menuItem:readMode', // 阅读模式
+        'menuItem:share:timeline', // 分享到朋友圈
+        'menuItem:copyUrl' // 复制链接
+      ],
+      success: function (res) {
+        alert('已显示“阅读模式”,“分享到朋友圈”,“复制链接”等按钮');
+      },
+      fail: function (res) {
+        alert(JSON.stringify(res));
+      }
+    });
+  };
+
+  // 8.5 隐藏所有非基本菜单项
+  document.querySelector('#hideAllNonBaseMenuItem').onclick = function () {
+    wx.hideAllNonBaseMenuItem({
+      success: function () {
+        alert('已隐藏所有非基本菜单项');
+      }
+    });
+  };
+
+  // 8.6 显示所有被隐藏的非基本菜单项
+  document.querySelector('#showAllNonBaseMenuItem').onclick = function () {
+    wx.showAllNonBaseMenuItem({
+      success: function () {
+        alert('已显示所有非基本菜单项');
+      }
+    });
+  };
+
+  // 8.7 关闭当前窗口
+  document.querySelector('#closeWindow').onclick = function () {
+    wx.closeWindow();
+  };
+
+  // 9 微信原生接口
+  // 9.1.1 扫描二维码并返回结果
+  document.querySelector('#scanQRCode0').onclick = function () {
+    wx.scanQRCode();
+  };
+  // 9.1.2 扫描二维码并返回结果
+  document.querySelector('#scanQRCode1').onclick = function () {
+    wx.scanQRCode({
+      needResult: 1,
+      desc: 'scanQRCode desc',
+      success: function (res) {
+        alert(JSON.stringify(res));
+      }
+    });
+  };
+
+  // 10 微信支付接口
+  // 10.1 发起一个支付请求
+  document.querySelector('#chooseWXPay').onclick = function () {
+    // 注意:此 Demo 使用 2.7 版本支付接口实现,建议使用此接口时参考微信支付相关最新文档。
+    wx.chooseWXPay({
+      timestamp: 1414723227,
+      nonceStr: 'noncestr',
+      package: 'addition=action_id%3dgaby1234%26limit_pay%3d&bank_type=WX&body=innertest&fee_type=1&input_charset=GBK&notify_url=http%3A%2F%2F120.204.206.246%2Fcgi-bin%2Fmmsupport-bin%2Fnotifypay&out_trade_no=1414723227818375338&partner=1900000109&spbill_create_ip=127.0.0.1&total_fee=1&sign=432B647FE95C7BF73BCD177CEECBEF8D',
+      signType: 'SHA1', // 注意:新版支付接口使用 MD5 加密
+      paySign: 'bd5b1933cda6e9548862944836a9b52e8c9a2b69'
+    });
+  };
+
+  // 11.3  跳转微信商品页
+  document.querySelector('#openProductSpecificView').onclick = function () {
+    wx.openProductSpecificView({
+      productId: 'pDF3iY_m2M7EQ5EKKKWd95kAxfNw',
+      extInfo: '123'
+    });
+  };
+
+  // 12 微信卡券接口
+  // 12.1 添加卡券
+  document.querySelector('#addCard').onclick = function () {
+    wx.addCard({
+      cardList: [
+        {
+          cardId: 'pDF3iY9tv9zCGCj4jTXFOo1DxHdo',
+          cardExt: '{"code": "", "openid": "", "timestamp": "1418301401", "signature":"f6628bf94d8e56d56bfa6598e798d5bad54892e5"}'
+        },
+        {
+          cardId: 'pDF3iY9tv9zCGCj4jTXFOo1DxHdo',
+          cardExt: '{"code": "", "openid": "", "timestamp": "1418301401", "signature":"f6628bf94d8e56d56bfa6598e798d5bad54892e5"}'
+        }
+      ],
+      success: function (res) {
+        alert('已添加卡券:' + JSON.stringify(res.cardList));
+      },
+      cancel: function (res) {
+        alert(JSON.stringify(res))
+      }
+    });
+  };
+
+  var codes = [];
+  // 12.2 选择卡券
+  document.querySelector('#chooseCard').onclick = function () {
+    wx.chooseCard({
+      cardSign: '1fdb2640c60e41f8823e9f762e70c531d161ae76',
+      timestamp: 1437997723,
+      nonceStr: 'k0hGdSXKZEj3Min5',
+      success: function (res) {
+        res.cardList = JSON.parse(res.cardList);
+        encrypt_code = res.cardList[0]['encrypt_code'];
+        alert('已选择卡券:' + JSON.stringify(res.cardList));
+        decryptCode(encrypt_code, function (code) {
+          codes.push(code);
+        });
+      },
+      cancel: function (res) {
+        alert(JSON.stringify(res))
+      }
+    });
+  };
+
+  // 12.3 查看卡券
+  document.querySelector('#openCard').onclick = function () {
+    if (codes.length < 1) {
+      alert('请先使用 chooseCard 接口选择卡券。');
+      return false;
+    }
+    var cardList = [];
+    for (var i = 0; i < codes.length; i++) {
+      cardList.push({
+        cardId: 'pDF3iY9tv9zCGCj4jTXFOo1DxHdo',
+        code: codes[i]
+      });
+    }
+    wx.openCard({
+      cardList: cardList,
+      cancel: function (res) {
+        alert(JSON.stringify(res))
+      }
+    });
+  };
+
+  var shareData = {
+    title: '微信JS-SDK Demo',
+    desc: '微信JS-SDK,帮助第三方为用户提供更优质的移动web服务',
+    link: 'http://demo.open.weixin.qq.com/jssdk/',
+    imgUrl: 'http://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRt8Qia4lv7k3M9J1SKqKCImxJCt7j9rHYicKDI45jRPBxdzdyREWnk0ia0N5TMnMfth7SdxtzMvVgXg/0'
+  };
+  wx.onMenuShareAppMessage(shareData);
+  wx.onMenuShareTimeline(shareData);
+
+  function decryptCode(code, callback) {
+    $.getJSON('/jssdk/decrypt_code.php?code=' + encodeURI(code), function (res) {
+      if (res.errcode == 0) {
+        codes.push(res.code);
+      }
+    });
+  }
+});
+
+wx.error(function (res) {
+  alert(res.errMsg);
+});

+ 7 - 0
Assets/WebGLTemplates/iTracker/demo.js.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 22961b822b87344ff834c4c98dec794b
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 149 - 49
Assets/WebGLTemplates/iTracker/index.html

@@ -3,12 +3,21 @@
 <head>
     <meta charset="utf-8">
     <meta name="viewport" content='width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0, user-scalable=no, shrink-to-fit=yes'>
-    <title>Unity WebGL Player | {{{ PRODUCT_NAME }}}</title>
+    <title>{{{ PRODUCT_NAME }}}</title>
     <link rel="stylesheet" href="TemplateData/style.css">
 
     <style>
-        html{
+       html{
             height: -webkit-fill-available;
+            position: fixed; /* 或者 absolute,取决于你的布局需求 */
+            top: 0;
+            left: 0;
+            width: 100%;
+            height: 100%;
+            background-image: url('StreamingAssets/ui/bg.png');
+            background-size: cover;
+            background-position: center;
+            background-repeat: no-repeat;
         }
         body {
             margin: 0;
@@ -28,21 +37,62 @@
             right: 0;
             top: 0;
             bottom: 0;
-            background: #fffa;
             z-index: 99;
+        } .image-button {
+            background-image: url('StreamingAssets/ui/initbt.png'); /* 替换为您的图片路径 */
+            background-size: cover; /* 背景图片覆盖整个按钮 */
+            background-color: transparent;
+            border: none;
+            padding: 30px 130px; /* 内边距 */
+            position: relative; top: 210px; left: -30px;
+        }
+ .loading {
+   position: relative; 
+   top: 540px;
+    width: 30px;
+    height: 30px;
+    border: 8px solid #f3f3f3;
+    border-top: 8px solid #B0BBB6; 
+    border-radius: 50%;
+    animation: spin 2s linear infinite;
+    margin: 100px auto;
+  }.progressBar {
+            position: fixed;
+            bottom: 0;
+            width: 100%;
         }
+.progress {
+  width: 100%;
+  height:40px;
+}
+       
+  @keyframes spin {
+    0% { transform: rotate(0deg); }
+    100% { transform: rotate(360deg); }
+  }
     </style>
 </head>
 <body>
     <!--IMAGETARGETS-->
 
     <video id="webcam-video" muted autoplay playsinline style="width:1px;position:absolute"></video>
+
     <!-- <video id="webcam-video" muted autoplay playsinline style="width:100%; height:100%; object-fit:cover; position:absolute"></video> -->
-    <canvas id="video-canvas" style="width:100%; height:100%; object-fit:cover; position:absolute"></canvas>
+    <canvas id="video-canvas" style="width:100%; height:100%; object-fit:cover; position:absolute">
+
+
+        
+    </canvas>
     <div id="startARDiv" class="ctaDiv">
-        <select id="chooseCamSel" style="display: none;" onchange="SelectCam()"></select>
-        <p style="text-align: center; width:60vw;">This augmented reality experience requires access to your device's camera</p>
-        <button id="startARButton" onclick="StartAR()" style="display:none">ALLOW ACCESS</button>
+        <!--   <select id="chooseCamSel" style="display: block;" onchange="SelectCam()"></select>
+     <p style="text-align: center; width:60vw;">This augmented reality experience requires access to your device's camera</p>
+
+        <div id="unity-loading-bar2" style="display:block">
+            <div id="unity-progress-bar-empty2"  style="display:block; height: 18px; margin-top: 10px; margin-left: 6.5px; background: url('TemplateData/progress-bar-empty-light.png') no-repeat center ">
+                <div id="unity-progress-bar-full2" style="display:block;position: relative; top: 210px;width: 0%; height: 18px; margin-top: 10px; background: url('TemplateData/progress-bar-full-light.png') no-repeat center "></div>
+            </div>
+        </div>-->
+        <button  class="image-button" id="startARButton" onclick="StartAR()" style="display:none">      </button>
     </div>
     <div id="screenshotDiv" style="display: none;" class="ctaDiv">
         <div style="position:relative; background-color:white; padding:10px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.3), 0 6px 20px 0 rgba(0, 0, 0, 0.25);">
@@ -61,25 +111,65 @@
     </div>
     <div id="errorDiv" class="ctaDiv" style="display: none; background:#aaa">
         <p id="errorText" style="text-align: center; width:60vw; color:white"></p>
+            <button onclick="refreshPage()">刷新页面</button>
     </div>
     <div id="unity-container" class="unity-mobile">
-        <canvas id="unity-canvas" style="width: 100%; height: 100%; background: #0000; z-index: -99"></canvas>
-        <div id="unity-loading-bar">
-            <div id="unity-logo"></div>
-            <div id="unity-progress-bar-empty">
-                <div id="unity-progress-bar-full"></div>
-            </div>
-        </div>
-        <canvas id="video-canvas"></canvas>
+        <canvas id="unity-canvas" style="width: 100%; height: 100%; background: #0000; z-index: -99">
+
+
+        </canvas>
+        <canvas id="video-canvas">
+
+
+        </canvas>
+ 
     </div>
+
+<div class="progressBar" id="progressBar" style="display:none;">
+    <id id="myProgress2" style="text-align: center; color: #2F4F4F;">0</id>
+    <progress class="progress" id="myProgress" value="0" max="100"></progress>
+</div>
+ <!--
+    <div id="startmusic" class="music1">
+        <button onclick="playMusic()">播放背景音乐</button>
+        <button onclick="stopMusic()">停止背景音乐</button>
+    </div>-->
+    <div class="loading" id="loadingbar" style="display:none;"></div>
+
     <script src="arcamera.js" type="text/javascript"></script>
     <script src="itracker.js" type="text/javascript"></script>
+    <script src="wtracker.js" type="text/javascript"></script>
     <script src="Build/{{{ LOADER_FILENAME }}}"></script>
-    <script>
+    <script>    // JavaScript用于更新进度条的值
+        function updateProgress(value) {
+            var progressBar = document.getElementById("myProgress");
+            
+            progressBar.value = value;
+            var progressBar2 = document.getElementById("myProgress2");
+        progressBar2.textContent = value + '%';
+        }
+        function changeBackground() {
+        var body = document.querySelector("html");
+        body.style.backgroundImage = "url('StreamingAssets/ui/black.jpg')";
+    }
+            function refreshPage() {
+                location.reload();
+            }
             var initialize = async() =>{
                 var unityCanvas = document.querySelector("#unity-canvas");
                 var videoCanvas = document.querySelector("#video-canvas");
                 window.arCamera = new ARCamera(unityCanvas, videoCanvas);
+ window.wTracker = new WorldTracker(arCamera);
+            try{
+                await wTracker.initialize("./opencv.js");
+                console.log("World tracker initialized!");   
+            }
+            catch (error) {
+                console.error("Failed to initialize world tracker. Are you missing opencv.js?", error);
+                ShowError("Failed to initialize the World Tracker.\n" + error);
+                return;
+            }
+
                 window.iTracker = new ImageTracker(arCamera);
                 try{
                     await window.iTracker.initialize();
@@ -92,14 +182,14 @@
                 }
                 
                 await LoadWebcams();
+           //     StartAR();
                 document.getElementById("startARButton").style.display = "block";
             }
-
             initialize();
 
             var container = document.querySelector("#unity-container");
             var canvas = document.querySelector("#unity-canvas");
-            var loadingBar = document.querySelector("#unity-loading-bar");
+            var loadingBar = document.getElementById("progressBar");
             var progressBarFull = document.querySelector("#unity-progress-bar-full");
             function StartAR() {
                 canvas.style.width = window.innerWidth + "px";
@@ -127,26 +217,30 @@
                     // devicePixelRatio: 1, // Uncomment this to override low DPI rendering on high DPI displays.
                     },
                     (progress) => {
-                        progressBarFull.style.width = 100 * progress + "%";
+                      //  progressBarFull.style.width = 100 * progress + "%";
+       updateProgress(100 * progress);
                     }
                 ).then((unityInstance) => {
                     window.unityInstance = unityInstance;
-                    RequestWebcam();
-
-                    loadingBar.style.display = "none";
-                });
+                   loadingBar.style.display = "none";
+                   changeBackground();
+                }).catch((message) => {
+       // alert("加载出错重新加载"+message); 
+                    ShowError("网络异常请重新加载");
+      });
+            StartMotionSensors();
+            
+            StartGPS();
                 loadingBar.style.display = "block";
             }
-            //Set Facing Mode here ('environment', 'user', '')
-            window.unityFacingMode = "environment";
-
+             //Set Facing Mode here ('environment', 'user', '')
+		window.unityFacingMode = "environment"
             window.WEBCAM_SETTINGS = {
                 video: {
                     facingMode: unityFacingMode,
                 },
                 audio: false
             };
-
             window.requestingForPermissions = false;
             async function RequestWebcam(){
                 window.requestingForPermissions = true;
@@ -158,22 +252,19 @@
                 catch (err) {
                     //user denied camera permission - show error panel
                     console.error("getUserMedia error - " , err);
-                    ShowError("Failed to start the experience. Camera permission was denied");
+                    ShowError("允许权限并刷新页面后继续导览");
                     window.requestingForPermissions = false;
                 }           
             }
-
             async function StartWebcam(){
+                await RequestWebcam();
                 console.log("StartWebcam")
-
                 while (window.requestingForPermissions) {
                     // Wait until requestingForPermissions becomes true.
                     console.log("Waiting for permissions...");
                     await new Promise(resolve => setTimeout(resolve, 100)); // Adjust the delay time as needed.
                 }
-
                 console.log("Got Permissions");
-
                 if(window.webcamStream)
                 {
                     const video = document.querySelector("#webcam-video");
@@ -181,7 +272,6 @@
                     try {
                         await arCamera.startWebcam(video);
                         console.log("Webcam started successfully");
-
                         window.unityInstance.SendMessage('ARCamera', 'OnStartWebcamSuccess');
                     }
                     catch(err){
@@ -201,7 +291,6 @@
                 var ctr = 0;
                 devices.forEach(mediaDevice => {
                     if (mediaDevice.kind === 'videoinput') {
-
                         if(window.unityFacingMode == 'environment' && !mediaDevice.label.includes('facing front')){
                             //back cam only
                             camDevices.push(mediaDevice);
@@ -218,8 +307,8 @@
                         ctr++;
                     }
                 });
-                var select = document.getElementById("chooseCamSel");
-                select.style.display = "block";
+             //   var select = document.getElementById("chooseCamSel");
+          //      select.style.display = "block";
                 var count = 0;
                 //reverse array because some Android phones can't distinguish front and back cams at first load
                 //and when this happens, most of the time, front cam goes first and back cam goes last
@@ -233,23 +322,21 @@
                     }
                     const textNode = document.createTextNode(label);
                     option.appendChild(textNode);
-                    select.appendChild(option);
+                   // select.appendChild(option);
                     count++;
                 });
-                iTracker.WEBCAM_NAME = select.options[select.selectedIndex].innerHTML;
+              //  iTracker.WEBCAM_NAME = select.options[select.selectedIndex].innerHTML;
             }
             function SelectCam(){
                 var select = document.getElementById("chooseCamSel");
                 window.deviceId = select.value;
                 window.WEBCAM_SETTINGS.video['deviceId'] = deviceId;
                 //console.log(window.WEBCAM_SETTINGS);
-                iTracker.WEBCAM_NAME = select.options[select.selectedIndex].innerHTML;
+             //   iTracker.WEBCAM_NAME = select.options[select.selectedIndex].innerHTML;
             }
-
             async function FlipCam(){
                 arCamera.stopWebcam();
                 window.WEBCAM_SETTINGS.video.deviceId = '';
-
                 if(window.WEBCAM_SETTINGS.video.facingMode == 'user'){
                     window.WEBCAM_SETTINGS.video.facingMode = 'environment';
                     arCamera.setFlipped(false);
@@ -259,37 +346,50 @@
                     arCamera.setFlipped(true);
                 }
                 window.webcamStream = await navigator.mediaDevices.getUserMedia(window.WEBCAM_SETTINGS);
-
                 const video = document.querySelector("#webcam-video");
                 video.srcObject = webcamStream;
-
                 await arCamera.startWebcam(video);
             }
-
             function ShowError(error){
                 document.getElementById("errorDiv").style.display = "flex";
                 document.getElementById("errorText").innerHTML = error;
             }
-
             function ShowScreenshot(dataUrl){
                 document.getElementById("screenshotDiv").style.display = "flex";
                 document.getElementById("screenshotImg").src = dataUrl;
                 document.getElementById("screenshotImg").style.width = "80vw";
                 document.getElementById("screenshotImg").style.height = 80 / window.innerWidth * window.innerHeight + "vw";
             }
-
             function ShowConfirmUrl(url){
                 document.getElementById("confirmUrlDiv").style.display = "flex";
                 window.newUrlString = url;
                 document.getElementById("confirmUrlText").innerText = "Are you sure you want to visit " + url;                
             }
-
             window.ITRACKER_GLOBALS = {
                 //place global settings here
                 INTERNAL_SMOOTHFACTOR_POS: .075,
             }
+             function StartMotionSensors(){
+            window.wTracker.startAngles()
+            .then(()=>{
+                console.log("Motion sensors started");
+            })
+            .catch(error=>{
+                console.error("Failed to start motion sensors - " + error);
+                ShowError("允许权限并刷新页面后继续导览");
+            });
+        }
+        function StartGPS(){            
+            window.wTracker.startGPS()
+            .then((pos)=>{
+                console.log("GPS started", pos);
+            })
+            .catch(error=>{
+                console.error("Failed to start GPS - " + error);
+                //ShowError("Failed to start GPS " + error);
+            });
+        }
             
-
     </script>
 </body>
-</html>
+</html>

File diff suppressed because it is too large
+ 0 - 0
Assets/WebGLTemplates/iTracker/itracker.js


+ 1 - 1
Assets/WebGLTemplates/iTracker/opencv.js

@@ -46,4 +46,4 @@ else if (typeof exports === 'object')
     Module = {};
   return cv(Module);
 }));
-        
+        

File diff suppressed because it is too large
+ 0 - 0
Assets/WebGLTemplates/iTracker/wtracker.js


+ 7 - 0
Assets/WebGLTemplates/iTracker/wtracker.js.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 88bd8ea883926407ba1bc1ebd84fe131
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 1 - 1
ProjectSettings/ProjectSettings.asset

@@ -13,7 +13,7 @@ PlayerSettings:
   useOnDemandResources: 0
   accelerometerFrequency: 60
   companyName: DefaultCompany
-  productName: WXGame
+  productName: "\u4E94\u4ED9\u89C2\u5947\u8C08"
   defaultCursor: {fileID: 0}
   cursorHotspot: {x: 0, y: 0}
   m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}

Some files were not shown because too many files changed in this diff