gemer zhang 1 год назад
Родитель
Сommit
3b520f4d53

+ 27 - 13
miniprogram/components/ar-tracker/ar-tracker.js

@@ -145,20 +145,31 @@ Component({
       // }
 
 
-      // for (const mesh of othergltf.model.meshes) {
-      //   // mesh.material = newMat
-      //   console.warn('othergltf-m', mesh.name)
-      // }
+      for (const mesh of othergltf.model.meshes) {
+        // mesh.material = newMat
 
-      for (const mesh of gltf.getPrimitivesByNodeName('node_video1_-7064')) {
-        mesh.material = newMat
-        // console.warn('mesh1', mesh)
-      }
-      for (const mesh of gltf.getPrimitivesByNodeName('node_video2_-7072')) {
-        mesh.material = newMat2
-        // console.warn('mesh2', mesh)
+        if (String(mesh.name).includes('video1')) {
+          const videoMesh1 = gltf.getPrimitivesByMeshName(mesh.name)
+          console.warn('videoMesh1', mesh.name, videoMesh1[0].nodeName)
+          for (const mesh of gltf.getPrimitivesByNodeName(videoMesh1[0].nodeName)) {
+            mesh.material = newMat
+          }
+        }
+        if (String(mesh.name).includes('video2')) {
+          const videoMesh2 = gltf.getPrimitivesByMeshName(mesh.name)
+          console.warn('videoMesh2', mesh.name, videoMesh2[0].nodeName)
+          for (const mesh of gltf.getPrimitivesByNodeName(videoMesh2[0].nodeName)) {
+            mesh.material = newMat2
+          }
+        }
       }
 
+
+      // for (const mesh of gltf.getPrimitivesByNodeName('node_video2_-7072')) {
+      //   mesh.material = newMat2
+      //   // console.warn('mesh2', mesh)
+      // }
+
     },
     handleItem2Loaded({
       detail
@@ -198,7 +209,7 @@ Component({
             }
           }
           if (this.animator1) {
-            this.data.isStartPlay1 ? this.animator1.resume('dd2') : this.animator1.play('dd2')
+            this.data.isStartPlay1 ? this.animator1.resume('dd3') : this.animator1.play('dd3')
           }
           this.setData({
             isStartPlay1: true
@@ -248,7 +259,7 @@ Component({
           this.innerAudioContext1.pause()
         }
         if (this.animator1) {
-          this.animator1.pause('dd2')
+          this.animator1.pause('dd3')
         }
       }
       if (type === 2) {
@@ -265,6 +276,9 @@ Component({
       // 事件的值即为`ARTracker`实例
       const tracker = detail.value;
       // 获取当前状态和错误信息
+
+      console.log('tracker', tracker)
+   
       const {
         state,
         errorMessage

+ 3 - 4
miniprogram/components/ar-tracker/ar-tracker.wxml

@@ -2,7 +2,7 @@
 
   <xr-assets bind:progress="handleAssetsProgress" bind:loaded="handleAssetsLoaded">
 
-    <xr-asset-load type="gltf" asset-id="item1" src="https://houseoss.4dkankan.com/mini-ar-test/AR/01/ddn02/ddn02.gltf" options="preserveRaw: true" />
+    <xr-asset-load type="gltf" asset-id="item1" src="https://houseoss.4dkankan.com/mini-ar-test/AR/01/ddn03/ddn03.gltf" options="preserveRaw: true" />
     <xr-asset-load type="gltf" asset-id="item2" src="https://houseoss.4dkankan.com/mini-ar-test/AR/2/gc99.glb" />
     <xr-asset-load type="gltf" asset-id="item3" src="https://houseoss.4dkankan.com/mini-ar-test/mtgj.glb" />
 
@@ -22,9 +22,8 @@
 
   <xr-node>
     <xr-ar-tracker id="ar-tracker-1" mode="Marker" src="https://houseoss.4dkankan.com/mini-ar-test/AR/01/01.png" bind:ar-tracker-state="handleARTrackerState1">
-      <!-- <xr-gltf model="item1" scale="5 5 5" rotation="270 0 0" bind:gltf-loaded="handleItem1Loaded"></xr-gltf> -->
-      <xr-gltf model="item1" position="-0.06 0 0.85"  scale="11 11 11" rotation="-270 0 180" bind:gltf-loaded="handleItem1Loaded"></xr-gltf>
-      <!-- <xr-mesh geometry="plane" rotation="0 0 0" scale="1 1 1" uniforms="u_baseColorFactor:0 1 0 0.5" states="alphaMode:BLEND" /> -->
+      <xr-gltf model="item1" position="0 0 0.5" height="100%" scale="10 10 10" rotation="-270 0 180" bind:gltf-loaded="handleItem1Loaded"></xr-gltf>
+      <xr-mesh geometry="plane" rotation="0 0 0" scale="1 1 1" uniforms="u_baseColorFactor:0 1 0 0.2" states="alphaMode:BLEND" />
     </xr-ar-tracker>
     <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="handleARTrackerState2">
       <xr-gltf model="item2" position="0 0.2 0"  scale="0.08 0.08 0.08" rotation="0 -90 80" bind:gltf-loaded="handleItem2Loaded"></xr-gltf>