chenlei пре 5 часа
родитељ
комит
b19cfc025e

Разлика између датотеке није приказан због своје велике величине
+ 2558 - 261
小程序入口_嵌套展示端/components/xr-ar-2dmarker/index.js


+ 18 - 0
小程序入口_嵌套展示端/components/xr-ar-2dmarker/index.wxml

@@ -13,6 +13,24 @@
       <xr-gltf vis model="adl" position="{{adlPos}}" scale="{{adlScale}}" rotation="-90 0 0" bind:gltf-loaded="handleItem2Loaded" />
     </xr-ar-tracker>
 
+    <xr-ar-tracker mode="Marker" src="{{markerImg2}}" bind:ar-tracker-state="handleARTrackerState2">
+      <xr-gltf vis model="bg" position="0 0 0" scale="0.5 0.5 0.5" rotation="-90 0 0" bind:gltf-loaded="handleItem3Loaded" />
+
+      <xr-gltf vis model="adl" position="{{adlPos}}" scale="{{adlScale}}" rotation="-90 0 0" bind:gltf-loaded="handleItem4Loaded" />
+    </xr-ar-tracker>
+
+    <xr-ar-tracker mode="Marker" src="{{markerImg3}}" bind:ar-tracker-state="handleARTrackerState3">
+      <xr-gltf vis model="bg" position="0 0 0" scale="0.5 0.5 0.5" rotation="-90 0 0" bind:gltf-loaded="handleItem5Loaded" />
+
+      <xr-gltf vis model="adl" position="{{adlPos}}" scale="{{adlScale}}" rotation="-90 0 0" bind:gltf-loaded="handleItem6Loaded" />
+    </xr-ar-tracker>
+
+    <xr-ar-tracker mode="Marker" src="{{markerImg4}}" bind:ar-tracker-state="handleARTrackerState4">
+      <xr-gltf vis model="bg" position="0 0 0" scale="0.5 0.5 0.5" rotation="-90 0 0" bind:gltf-loaded="handleItem7Loaded" />
+
+      <xr-gltf vis model="adl" position="{{adlPos}}" scale="{{adlScale}}" rotation="-90 0 0" bind:gltf-loaded="handleItem8Loaded" />
+    </xr-ar-tracker>
+
     <xr-camera id="camera" position="1 1 1" node-id="camera" clear-color="0.925 0.925 0.925 1" background="ar" is-ar-camera></xr-camera>
   </xr-node>
   <xr-node node-id="lights">

BIN
小程序入口_嵌套展示端/pages/ar/img@2x.png


+ 43 - 23
小程序入口_嵌套展示端/pages/ar/index.js

@@ -1,5 +1,5 @@
-var sceneReadyBehavior = require('../behavior-scene/scene-ready');
-var handleDecodedXML = require('../behavior-scene/util').handleDecodedXML;
+var sceneReadyBehavior = require("../behavior-scene/scene-ready");
+var handleDecodedXML = require("../behavior-scene/util").handleDecodedXML;
 var xmlCode = `&lt;xr-scene ar-system=&quot;modes:Marker&quot; id=&quot;xr-scene&quot; bind:ready=&quot;handleReady&quot; bind:arReady=&quot;handleARReady&quot; bind:log=&quot;handleLog&quot;&gt;
 &lt;xr-assets bind:progress=&quot;handleAssetsProgress&quot; bind:loaded=&quot;handleAssetsLoaded&quot;&gt;
   &lt;xr-asset-material asset-id=&quot;ar-anchor&quot; effect=&quot;standrand&quot; uniforms=&quot;u_baseColorFactor:0 1 0 1&quot;&gt;&lt;/xr-asset-material&gt;
@@ -24,12 +24,19 @@ var xmlCode = `&lt;xr-scene ar-system=&quot;modes:Marker&quot; id=&quot;xr-scene
 Page({
   behaviors: [sceneReadyBehavior],
   data: {
-    xmlCode: '<div class="codeWrap">' + handleDecodedXML(xmlCode) + '</div>',
-    markerImg: 'https://ossxiaoan.4dage.com/hq-eduction-vr/hq-bag.jpg',
+    xmlCode: '<div class="codeWrap">' + handleDecodedXML(xmlCode) + "</div>",
+    markerImg: "https://ossxiaoan.4dage.com/hq-eduction-vr/hq-bag.jpg",
+    markerImg2:
+      "https://houseoss.4dkankan.com/project/hq-eduction-vr/public/1.png",
+    markerImg3:
+      "https://houseoss.4dkankan.com/project/hq-eduction-vr/public/2.png",
+    markerImg4:
+      "https://houseoss.4dkankan.com/project/hq-eduction-vr/public/4.png",
     showLoading: true,
-    loadingText: '正在初始化相机…',
+    loadingText: "正在初始化相机…",
     loadingProgress: 0,
-    _wxLoadingText: ''
+    _wxLoadingText: "",
+    showGuide: true,
   },
   onUnload() {
     if (wx.hideLoading) wx.hideLoading();
@@ -40,16 +47,22 @@ Page({
     const assetsLoaded = !!detail.assetsLoaded;
     const item1Loaded = !!detail.item1Loaded;
     const item2Loaded = !!detail.item2Loaded;
-    const p = typeof detail.assetsProgress === 'number' ? detail.assetsProgress : 0;
+    const p =
+      typeof detail.assetsProgress === "number" ? detail.assetsProgress : 0;
 
     let loadingText = this.data.loadingText;
-    if (!arReady) loadingText = '';
-    else if (!assetsLoaded) loadingText = '';
-    else if (!item1Loaded || !item2Loaded) loadingText = '';
-    else loadingText = '';
+    if (!arReady) loadingText = "";
+    else if (!assetsLoaded) loadingText = "";
+    else if (!item1Loaded || !item2Loaded) loadingText = "";
+    else loadingText = "";
 
     const loadingProgress = Math.max(0, Math.min(100, Math.round(p)));
-    const showLoading = !(arReady && assetsLoaded && item1Loaded && item2Loaded);
+    const showLoading = !(
+      arReady &&
+      assetsLoaded &&
+      item1Loaded &&
+      item2Loaded
+    );
 
     this.setData({ showLoading, loadingText, loadingProgress });
 
@@ -60,22 +73,29 @@ Page({
       }
     } else {
       if (wx.hideLoading) wx.hideLoading();
-      if (this.data._wxLoadingText) this.setData({ _wxLoadingText: '' });
+      if (this.data._wxLoadingText) this.setData({ _wxLoadingText: "" });
     }
   },
-  handleChangeMarkerImg: function() {
+  handleARTrackerState(e) {
+    const { isTracking } = e.detail || {};
+    if (isTracking) {
+      // 识别到marker后隐藏guide
+      this.setData({ showGuide: false });
+    }
+  },
+  handleChangeMarkerImg: function () {
     wx.chooseMedia({
       count: 1,
-      sizeType: ['compressed'],
-      mediaType: ['image'],
-      sourceType: ['album'],
-      success: res => {
+      sizeType: ["compressed"],
+      mediaType: ["image"],
+      sourceType: ["album"],
+      success: (res) => {
         const fp = res.tempFiles[0].tempFilePath;
-        this.setData({markerImg: fp});
+        this.setData({ markerImg: fp });
+      },
+      fail: (err) => {
+        console.error("[xr-demo]chooseImage failed", err);
       },
-      fail: err => {
-        console.error('[xr-demo]chooseImage failed', err);
-      }
     });
-  }
+  },
 });

+ 5 - 0
小程序入口_嵌套展示端/pages/ar/index.wxml

@@ -6,6 +6,9 @@
     height="{{renderHeight}}"
     style="width:{{width}}px;height:{{height}}px;top:{{top}}px;left:{{left}}px;display:block;"
     markerImg="{{markerImg}}"
+    markerImg2="{{markerImg2}}"
+    markerImg3="{{markerImg3}}"
+    markerImg4="{{markerImg4}}"
     bind:arTrackerState="handleARTrackerState"
     bind:loadState="handleLoadState"
   />
@@ -16,4 +19,6 @@
       <view wx:if="{{loadingProgress >= 0}}" class="loading-progress">{{loadingProgress}}%</view>
     </view>
   </view>
+
+  <image wx:if="{{showGuide}}" class="ar-guide" src="./img@2x.png" />
 </view>

+ 10 - 0
小程序入口_嵌套展示端/pages/ar/index.wxss

@@ -14,6 +14,16 @@
   background: rgba(0, 0, 0, 0.55);
 }
 
+.ar-guide {
+  position: fixed;
+  bottom: 0;
+  left: 0;
+  width: 100%;
+  height: 100%;
+  object-fit: cover;
+  z-index: 9999;
+}
+
 .loading-card {
   width: 360rpx;
   padding: 32rpx 28rpx;

+ 40 - 40
小程序入口_嵌套展示端/project.config.json

@@ -1,41 +1,41 @@
-{
-  "compileType": "miniprogram",
-  "libVersion": "trial",
-  "packOptions": {
-    "ignore": [],
-    "include": []
-  },
-  "setting": {
-    "coverView": true,
-    "es6": true,
-    "postcss": true,
-    "minified": true,
-    "enhance": true,
-    "showShadowRootInWxmlPanel": true,
-    "packNpmRelationList": [],
-    "babelSetting": {
-      "ignore": [],
-      "disablePlugins": [],
-      "outputPath": ""
-    },
-    "compileWorklet": false,
-    "uglifyFileName": false,
-    "uploadWithSourceMap": true,
-    "packNpmManually": false,
-    "minifyWXSS": true,
-    "minifyWXML": true,
-    "localPlugins": false,
-    "disableUseStrict": false,
-    "useCompilerPlugins": false,
-    "condition": false,
-    "swc": false,
-    "disableSWC": true
-  },
-  "condition": {},
-  "editorSetting": {
-    "tabIndent": "auto",
-    "tabSize": 2
-  },
-  "appid": "wxa8f5e5ba0792de6a",
-  "simulatorPluginLibVersion": {}
+{
+  "compileType": "miniprogram",
+  "libVersion": "trial",
+  "packOptions": {
+    "ignore": [],
+    "include": []
+  },
+  "setting": {
+    "coverView": true,
+    "es6": true,
+    "postcss": true,
+    "minified": true,
+    "enhance": true,
+    "showShadowRootInWxmlPanel": true,
+    "packNpmRelationList": [],
+    "babelSetting": {
+      "ignore": [],
+      "disablePlugins": [],
+      "outputPath": ""
+    },
+    "compileWorklet": false,
+    "uglifyFileName": false,
+    "uploadWithSourceMap": true,
+    "packNpmManually": false,
+    "minifyWXSS": true,
+    "minifyWXML": true,
+    "localPlugins": false,
+    "disableUseStrict": false,
+    "useCompilerPlugins": false,
+    "condition": false,
+    "swc": false,
+    "disableSWC": true
+  },
+  "condition": {},
+  "editorSetting": {
+    "tabIndent": "auto",
+    "tabSize": 2
+  },
+  "appid": "wxa8f5e5ba0792de6a",
+  "simulatorPluginLibVersion": {}
 }

+ 34 - 34
小程序入口_嵌套展示端/project.private.config.json

@@ -1,35 +1,35 @@
-{
-  "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
-  "projectname": "%E5%B0%8F%E7%A8%8B%E5%BA%8F%E5%85%A5%E5%8F%A3_%E5%B5%8C%E5%A5%97%E5%B1%95%E7%A4%BA%E7%AB%AF",
-  "setting": {
-    "compileHotReLoad": true,
-    "urlCheck": true,
-    "coverView": true,
-    "lazyloadPlaceholderEnable": false,
-    "skylineRenderEnable": false,
-    "preloadBackgroundData": false,
-    "autoAudits": false,
-    "useApiHook": true,
-    "showShadowRootInWxmlPanel": true,
-    "useStaticServer": false,
-    "useLanDebug": false,
-    "showES6CompileOption": false,
-    "checkInvalidKey": true,
-    "ignoreDevUnusedFiles": true,
-    "bigPackageSizeSupport": false
-  },
-  "condition": {
-    "miniprogram": {
-      "list": [
-        {
-          "name": "pages/ar/index",
-          "pathName": "pages/ar/index",
-          "query": "",
-          "scene": null,
-          "launchMode": "default"
-        }
-      ]
-    }
-  },
-  "libVersion": "3.12.1"
+{
+  "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
+  "projectname": "%E5%B0%8F%E7%A8%8B%E5%BA%8F%E5%85%A5%E5%8F%A3_%E5%B5%8C%E5%A5%97%E5%B1%95%E7%A4%BA%E7%AB%AF",
+  "setting": {
+    "compileHotReLoad": true,
+    "urlCheck": false,
+    "coverView": true,
+    "lazyloadPlaceholderEnable": false,
+    "skylineRenderEnable": false,
+    "preloadBackgroundData": false,
+    "autoAudits": false,
+    "useApiHook": true,
+    "showShadowRootInWxmlPanel": true,
+    "useStaticServer": false,
+    "useLanDebug": false,
+    "showES6CompileOption": false,
+    "checkInvalidKey": true,
+    "ignoreDevUnusedFiles": true,
+    "bigPackageSizeSupport": false
+  },
+  "condition": {
+    "miniprogram": {
+      "list": [
+        {
+          "name": "pages/ar/index",
+          "pathName": "pages/ar/index",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        }
+      ]
+    }
+  },
+  "libVersion": "trial"
 }