gemercheung 1 год назад
Родитель
Сommit
81adf2c555

+ 9 - 31
miniprogram/components/ar-tracker/ar-tracker.js

@@ -12,9 +12,7 @@ Component({
    * 组件的初始数据
    */
   data: {
-    isT1: false,
-    isT2: false,
-    isT3: false
+
   },
 
   /**
@@ -41,12 +39,8 @@ Component({
         errorMessage
       } = tracker;
       if (state == 2) {
-        this.setData({
-          isT1: true
-        })
-        // wx.showToast({
-        //   title: "阿里公仔"
-        // })
+
+        this.triggerEvent('scan', 1)
       }
     },
     handleARTrackerState1({
@@ -60,12 +54,10 @@ Component({
         errorMessage
       } = tracker;
       if (state == 2) {
-        this.setData({
-          isT2: true
-        })
         wx.showToast({
-          title: "显示器"
+          title: "2"
         })
+        this.triggerEvent('scan', 2)
       }
     },
     handleARTrackerState2({
@@ -79,27 +71,13 @@ Component({
         errorMessage
       } = tracker;
       if (state == 2) {
-        this.setData({
-          isT3: true
-        })
         wx.showToast({
-          title: "药药药"
+          title: "3"
         })
+        this.triggerEvent('scan', 3)
       }
     },
-    handleAssetsProgress() {
-      // console.log(arguments)
-
-    },
-    handleAssetsLoaded() {
-      // console.log(arguments)
-    },
-    handleGLTFLoaded({
-      detail
-    }) {
-      const el = detail.value.target;
-      const animator = el.getComponent("animator");
-      console.log('animator', animator)
-    }
+    handleAssetsProgress() {},
+    handleAssetsLoaded() {},
   }
 })

+ 6 - 26
miniprogram/components/ar-tracker/ar-tracker.wxml

@@ -1,40 +1,20 @@
 <xr-scene ar-system="modes:Marker;planeMode: 1" id="xr-scene" bind:ready="handleReady" bind:ar-ready="handleARReady" bind:log="handleLog">
+  <!-- <xr-assets bind:progress="handleAssetsProgress" bind:loaded="handleAssetsLoaded">
+    <xr-asset-load type="gltf" asset-id="anchor" src="https://mmbizwxaminiprogram-1258344707.cos.ap-guangzhou.myqcloud.com/xr-frame/demo/ar-plane-marker.glb" />
+  </xr-assets> -->
 
-  <xr-assets bind:progress="handleAssetsProgress" bind:loaded="handleAssetsLoaded">
-
-    <!-- <xr-asset-load type="gltf" asset-id="soldier" src="https://houseoss.4dkankan.com/Soldier.glb" /> -->
-
-    <xr-asset-load type="gltf" asset-id="mtgj" src="https://houseoss.4dkankan.com/mini-ar-test/mtgj.glb" />
-    <xr-asset-load type="texture" asset-id="point" src="https://mmbizwxaminiprogram-1258344707.cos.ap-guangzhou.myqcloud.com/xr-frame/demo/particles/point.png" />
-
-    <xr-asset-load type="video-texture" asset-id="cat" src="https://houseoss.4dkankan.com/mini-ar-test/Homevideonew.mp4" options="autoPlay:true,loop:true,abortAudio:false,placeHolder:https://houseoss.4dkankan.com/mini-ar-test/Homevideonew.mp4?x-oss-process=video/snapshot,t_0,f_jpg,w_1000,m_fast,ar_auto" />
-
-    <!-- <xr-asset-material asset-id="catMat" effect="simple" uniforms="u_baseColorMap: video-cat" /> -->
-
-  </xr-assets>
   <xr-env env-data="xr-frame-team-workspace-day" />
   <xr-node>
-    <xr-ar-tracker id="ar-tracker-1" mode="Marker" src="https://houseoss.4dkankan.com/mini-ar-test/save-1.png" bind:ar-tracker-state="handleARTrackerState">
-      <!-- <xr-gltf id="soldier-1" position="0 0.2 0" scale="0.3 0.3 0.3" rotation="90 270 90" model="soldier" anim-autoplay bind:gltf-loaded="handleGLTFLoaded" wx:if="{{isT1}}"></xr-gltf> -->
-      <xr-gltf id="mtgj-1" position="0 0 0" scale="0.03 0.03 0.03" rotation="-45 0 0" model="mtgj" anim-autoplay="loop:0" bind:gltf-loaded="handleGLTFLoaded" wx:if="{{isT1}}"></xr-gltf>
-      <!-- <xr-mesh node-id="mesh-plane" geometry="plane" material="mat"  /> -->
-      <!-- <xr-particle capacity="500" emit-rate="20" size="0.03 0.06" life-time="2 3" speed="0.04 0.1" start-color="1 1 1 0.8" end-color="1 1 1 0.2" emitter-type="BoxShape" emitter-props="minEmitBox:-0.5 0 0.5,maxEmitBox:0.5 0.2 0,direction:0 0 -1,direction2:0 0 -1" texture="point" /> -->
+    <xr-ar-tracker id="ar-tracker-1" mode="Marker" src="https://houseoss.4dkankan.com/mini-ar-test/AR/1/marker.png" bind:ar-tracker-state="handleARTrackerState">
     </xr-ar-tracker>
-
-    <xr-ar-tracker id="ar-tracker-2" mode="Marker" src="https://houseoss.4dkankan.com/mini-ar-test/mon1.jpg" bind:ar-tracker-state="handleARTrackerState1">
-      <xr-mesh node-id="mesh-plane" geometry="plane" material="catMat" scale="0.4 0.4 0.4" />
+    <xr-ar-tracker id="ar-tracker-2" mode="Marker" src="https://houseoss.4dkankan.com/mini-ar-test/AR/2/marker.png" bind:ar-tracker-state="handleARTrackerState1">
     </xr-ar-tracker>
-
-    <xr-ar-tracker id="ar-tracker-3" mode="Marker" src="https://houseoss.4dkankan.com/mini-ar-test/save-2.png" bind:ar-tracker-state="handleARTrackerState2">
-      <xr-mesh node-id="mesh-plane" geometry="plane" material="catMat" scale="0.4 0.4 0.4" wx:if="{{isT3}}" />
+    <xr-ar-tracker id="ar-tracker-3" mode="Marker" src="https://houseoss.4dkankan.com/mini-ar-test/AR/3/marker.png" bind:ar-tracker-state="handleARTrackerState2">
     </xr-ar-tracker>
 
     <xr-camera id="camera" node-id="camera" position="1 1 1" clear-color="0.925 0.925 0.925 1" far="2000" background="ar" is-ar-camera></xr-camera>
 
-
   </xr-node>
-
-
   <xr-node node-id="lights">
     <xr-light type="ambient" color="1 1 1" intensity="2" />
     <xr-light type="directional" rotation="90 60 0" color="1 1 1" intensity="1" />

+ 11 - 3
miniprogram/components/xr-ar-vio-marker-1/index.js

@@ -1,7 +1,7 @@
 Component({
   // behaviors: [require('../common/share-behavior').default],
   properties: {
-    a: Number,
+    fromScan: Boolean
   },
   data: {
     loaded: false,
@@ -38,7 +38,6 @@ Component({
       // console.log('assets progress', detail.value.progress);
       const progress =
         Math.floor(detail.value.progress * 100)
-
       this.triggerEvent('progress', progress)
     },
     handleAssetsLoaded: function ({
@@ -50,6 +49,7 @@ Component({
       this.scene.event.addOnce('touchstart', this.placeNode.bind(this));
       this.triggerEvent('loaded')
 
+
     },
     handleARReady: function ({
       detail
@@ -85,6 +85,9 @@ Component({
       const video = this.scene.assets.getAsset("video-texture", "animaV");
       const newMat = this.scene.assets.getAsset("material", "matAnimaV");
       this.video = video
+      this.video.onEnd = () => {
+
+      }
       const animator = el.getComponent("animator");
       this.animator = animator
 
@@ -94,6 +97,11 @@ Component({
         mesh.material = newMat
         mesh.material.setText
       }
+
+      if (this.data.fromScan) {
+        console.log('fromScan', this.data.fromScan);
+        this.showAndPlay();
+      }
     },
 
     handleARTrackerState({
@@ -116,8 +124,8 @@ Component({
     },
     showAndPlay() {
       console.log('showAndPlay')
+      this.scene.ar.placeHere('setitem', true);
       if (!this.data.isPlay) {
-        this.scene.ar.placeHere('setitem', true);
         this.scene.getNodeById('setitem').visible = true;
         this.setData({
           isPlay: true

+ 8 - 3
miniprogram/components/xr-ar-vio-marker-2/index.js

@@ -1,7 +1,7 @@
 Component({
   // behaviors: [require('../common/share-behavior').default],
   properties: {
-    a: Number,
+    fromScan: Boolean
   },
   data: {
     loaded: false,
@@ -84,6 +84,11 @@ Component({
       for (const mesh of gltf.getPrimitivesByNodeName("video")) {
         mesh.material = newMat
       }
+      if (this.data.fromScan) {
+        console.log('fromScan', this.data.fromScan);
+        this.scene.ar.resetPlane();
+        this.showAndPlay();
+      }
     },
     handleARTrackerState({
       detail
@@ -105,9 +110,9 @@ Component({
     },
 
     showAndPlay() {
-      console.log('showAndPlay')
+  
+      this.scene.ar.placeHere('setitem', true);
       if (!this.data.isPlay) {
-        this.scene.ar.placeHere('setitem', true);
         this.scene.getNodeById('setitem').visible = true;
         this.setData({
           isPlay: true

+ 7 - 3
miniprogram/components/xr-ar-vio-marker-3/index.js

@@ -3,7 +3,7 @@ const xrFrameSystem = wx.getXrFrameSystem();
 Component({
   // behaviors: [require('../common/share-behavior').default],
   properties: {
-    a: Number,
+    fromScan: Boolean
   },
   data: {
     loaded: false,
@@ -80,6 +80,10 @@ Component({
       const animator = el.getComponent("animator");
       this.animator = animator
       console.warn('handleGLTFLoaded', animator)
+      if (this.data.fromScan) {
+        console.log('fromScan', this.data.fromScan);
+        this.showAndPlay();
+      }
     },
 
     handleARTrackerState({
@@ -101,9 +105,9 @@ Component({
       }
     },
     showAndPlay() {
-      console.log('showAndPlay')
+      console.log('showAndPlay');
+      this.scene.ar.placeHere('setitem', true);
       if (!this.data.isPlay) {
-        this.scene.ar.placeHere('setitem', true);
         this.scene.getNodeById('setitem').visible = true;
         this.setData({
           isPlay: true

+ 8 - 2
miniprogram/pages/children/children.ts

@@ -9,13 +9,14 @@ Page({
     renderWidth: 300,
     renderHeight: 300,
     loaded: false,
-    progress: 0
+    progress: 0,
+    fromScan: true
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad() {
+  onLoad(params) {
     const info = wx.getSystemInfoSync();
     const width = info.windowWidth;
     const height = info.windowHeight;
@@ -25,6 +26,11 @@ Page({
       renderWidth: width * dpi,
       renderHeight: height * dpi
     });
+    if ('fromScan' in params) {
+      this.setData({
+        fromScan: true
+      });
+    }
   },
 
   /**

+ 1 - 3
miniprogram/pages/children/children.wxml

@@ -3,9 +3,7 @@
   <view class="loading" wx:if="{{!loaded}}">
     <text>{{progress}}%</text>
   </view>
-  <xr-ar-vio-marker disable-scroll id="main-frame" width="{{renderWidth}}" height="{{renderHeight}}" style="width:{{width}}px;height:{{height}}px;top:{{top}}px;left:{{left}}px;display:block;" bind:loaded="handleLoaded" 
-  bind:progress="handleProgress"
-  />
+  <xr-ar-vio-marker disable-scroll id="main-frame" width="{{renderWidth}}" height="{{renderHeight}}" style="width:{{width}}px;height:{{height}}px;top:{{top}}px;left:{{left}}px;display:block;" bind:loaded="handleLoaded" bind:progress="handleProgress" fromScan="{{fromScan}}" />
 
 
 </view>

+ 10 - 2
miniprogram/pages/dunhuang/dunhuang.ts

@@ -9,22 +9,30 @@ Page({
     renderWidth: 300,
     renderHeight: 300,
     loaded: false,
-    progress: 0
+    progress: 0,
+    fromScan: false
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad() {
+  onLoad(params) {
     const info = wx.getSystemInfoSync();
     const width = info.windowWidth;
     const height = info.windowHeight;
     const dpi = info.pixelRatio;
+
     this.setData({
       width, height,
       renderWidth: width * dpi,
       renderHeight: height * dpi
     });
+
+    if ('fromScan' in params) {
+      this.setData({
+        fromScan: true
+      });
+    }
   },
 
   /**

+ 2 - 2
miniprogram/pages/dunhuang/dunhuang.wxml

@@ -1,9 +1,9 @@
 <view class="page">
-  <navigation-bar title="{{'四维AR'}}" back="{{true}}" />
+  <navigation-bar title="{{'“敦敦”带您游览敦煌千年'}}" back="{{true}}" />
   <view class="loading" wx:if="{{!loaded}}">
     <text>{{progress}}%</text>
   </view>
-  <xr-ar-vio-marker disable-scroll id="main-frame" width="{{renderWidth}}" height="{{renderHeight}}" style="width:{{width}}px;height:{{height}}px;top:{{top}}px;left:{{left}}px;display:block;" bind:loaded="handleLoaded" bind:progress="handleProgress" />
+  <xr-ar-vio-marker disable-scroll id="main-frame" width="{{renderWidth}}" height="{{renderHeight}}" style="width:{{width}}px;height:{{height}}px;top:{{top}}px;left:{{left}}px;display:block;" bind:loaded="handleLoaded" bind:progress="handleProgress" fromScan="{{fromScan}}" />
 
 
 </view>

+ 8 - 2
miniprogram/pages/myth/myth.ts

@@ -9,13 +9,14 @@ Page({
     renderWidth: 300,
     renderHeight: 300,
     loaded: false,
-    progress: 0
+    progress: 0,
+    fromScan: false
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad() {
+  onLoad(params) {
     const info = wx.getSystemInfoSync();
     const width = info.windowWidth;
     const height = info.windowHeight;
@@ -25,6 +26,11 @@ Page({
       renderWidth: width * dpi,
       renderHeight: height * dpi
     });
+    if ('fromScan' in params) {
+      this.setData({
+        fromScan: true
+      });
+    }
   },
 
   /**

+ 1 - 3
miniprogram/pages/myth/myth.wxml

@@ -3,9 +3,7 @@
   <view class="loading" wx:if="{{!loaded}}">
     <text>{{progress}}%</text>
   </view>
-  <xr-ar-vio-marker disable-scroll id="main-frame" width="{{renderWidth}}" height="{{renderHeight}}" style="width:{{width}}px;height:{{height}}px;top:{{top}}px;left:{{left}}px;display:block;" bind:loaded="handleLoaded" 
-  bind:progress="handleProgress"
-  />
+  <xr-ar-vio-marker disable-scroll id="main-frame" width="{{renderWidth}}" height="{{renderHeight}}" style="width:{{width}}px;height:{{height}}px;top:{{top}}px;left:{{left}}px;display:block;" bind:loaded="handleLoaded" bind:progress="handleProgress" fromScan="{{fromScan}}" />
 
 
 </view>

+ 5 - 0
miniprogram/pages/scaner/scaner.json

@@ -1,5 +1,10 @@
 {
+  "component": true,
+  "navigationBarTitleText": "四维AR",
+  "navigationBarTextStyle": "black",
+  "disableScroll": true,
   "usingComponents": {
+    "navigation-bar": "/components/navigation-bar/navigation-bar",
     "ar-tracker": "/components/ar-tracker/ar-tracker"
   }
 }

+ 25 - 0
miniprogram/pages/scaner/scaner.ts

@@ -9,6 +9,7 @@ Page({
     height: 300,
     renderWidth: 300,
     renderHeight: 300,
+
   },
 
   /**
@@ -74,5 +75,29 @@ Page({
    */
   onShareAppMessage() {
 
+  },
+  handleScan(event: WechatMiniprogram.TouchEvent) {
+    console.log('handleScan', event.detail)
+    const type = Number(event.detail)
+    wx.showToast({
+      title: `type-${type}`
+    })
+
+    if (type === 1) {
+      wx.redirectTo({
+        url: "/pages/dunhuang/dunhuang?fromScan=1",
+      })
+    }
+    if (type === 2) {
+      wx.redirectTo({
+        url: "/pages/myth/myth?fromScan=1",
+      })
+    }
+    if (type === 3) {
+      wx.redirectTo({
+        url: "/pages/children/children?fromScan=1",
+      })
+    }
+
   }
 })

+ 7 - 1
miniprogram/pages/scaner/scaner.wxml

@@ -1 +1,7 @@
-<ar-tracker disable-scroll id="main-frame" width="{{renderWidth}}" height="{{renderHeight}}" style="width:{{width}}px;height:{{height}}px;" />
+<view class="page">
+  <navigation-bar title="{{'四维AR'}}" back="{{true}}" />
+  <!-- <view class="loading" wx:if="{{!loaded}}">
+    <text>{{progress}}%</text>
+  </view> -->
+  <ar-tracker disable-scroll id="main-frame" width="{{renderWidth}}" height="{{renderHeight}}" style="width:{{width}}px;height:{{height}}px;" bind:scan="handleScan" />
+</view>

+ 14 - 1
project.private.config.json

@@ -5,5 +5,18 @@
     "compileHotReLoad": true,
     "skylineRenderEnable": true
   },
-  "libVersion": "3.4.1"
+  "libVersion": "3.4.1",
+  "condition": {
+    "miniprogram": {
+      "list": [
+        {
+          "name": "pages/dunhuang/dunhuang",
+          "pathName": "pages/dunhuang/dunhuang",
+          "query": "fromScan=1",
+          "launchMode": "default",
+          "scene": null
+        }
+      ]
+    }
+  }
 }