|
@@ -1,3 +1,5 @@
|
|
|
+const xrFrameSystem = wx.getXrFrameSystem();
|
|
|
+
|
|
|
Component({
|
|
|
// behaviors: [require('../common/share-behavior').default],
|
|
|
properties: {
|
|
@@ -11,6 +13,13 @@ Component({
|
|
|
lifetimes: {
|
|
|
async attached() {
|
|
|
console.log('data', this.data)
|
|
|
+ },
|
|
|
+ async detached() {
|
|
|
+ console.error('detached', this.video)
|
|
|
+ this.animator && (this.animator = null);
|
|
|
+ this.setData({
|
|
|
+ isPlay: false
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
@@ -25,7 +34,6 @@ Component({
|
|
|
handleAssetsProgress: function ({
|
|
|
detail
|
|
|
}) {
|
|
|
- // console.log('assets progress', detail.value.progress);
|
|
|
const progress =
|
|
|
Math.floor(detail.value.progress * 100)
|
|
|
this.triggerEvent('progress', progress)
|
|
@@ -59,13 +67,8 @@ Component({
|
|
|
this.scene.getNodeById('setitem').visible = false;
|
|
|
this.scene.ar.resetPlane();
|
|
|
} else {
|
|
|
- this.scene.ar.placeHere('setitem', true);
|
|
|
- console.error('show-gltf')
|
|
|
- if (!this.isPlay) {
|
|
|
- this.setData({
|
|
|
- isPlay: true
|
|
|
- })
|
|
|
- }
|
|
|
+ console.error('show-gltf', this.data.isPlay)
|
|
|
+ this.showAndPlay();
|
|
|
}
|
|
|
|
|
|
this.scene.event.addOnce('touchstart', this.placeNode.bind(this));
|
|
@@ -74,15 +77,52 @@ Component({
|
|
|
detail
|
|
|
}) {
|
|
|
const el = detail.value.target;
|
|
|
- // console.error('handleGLTFLoaded')
|
|
|
- // const gltf = el.getComponent("gltf");
|
|
|
- // const video = this.scene.assets.getAsset("video-texture", "cat");
|
|
|
- // const newMat = this.scene.assets.getAsset("material", "catMat");
|
|
|
- // this.video = video
|
|
|
+ const animator = el.getComponent("animator");
|
|
|
+ this.animator = animator
|
|
|
+ console.warn('handleGLTFLoaded', animator)
|
|
|
+ },
|
|
|
+
|
|
|
+ handleARTrackerState({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ const tracker = detail.value;
|
|
|
+ // 获取当前状态和错误信息
|
|
|
+ const {
|
|
|
+ state,
|
|
|
+ errorMessage
|
|
|
+ } = tracker;
|
|
|
|
|
|
- // for (const mesh of gltf.getPrimitivesByNodeName("video")) {
|
|
|
- // mesh.material = newMat
|
|
|
- // }
|
|
|
+ console.log('tracker-state', tracker)
|
|
|
+ if (state == 2) {
|
|
|
+ wx.showToast({
|
|
|
+ title: "tracker"
|
|
|
+ })
|
|
|
+ this.showAndPlay();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ showAndPlay() {
|
|
|
+ console.log('showAndPlay')
|
|
|
+ if (!this.data.isPlay) {
|
|
|
+ this.scene.ar.placeHere('setitem', true);
|
|
|
+ this.scene.getNodeById('setitem').visible = true;
|
|
|
+ this.setData({
|
|
|
+ isPlay: true
|
|
|
+ }, () => {
|
|
|
+ if (this.animator) {
|
|
|
+ if (this.animator) {
|
|
|
+ this.animator.play('Group21137Action', {
|
|
|
+ loop: 0
|
|
|
+ });
|
|
|
+ this.animator.play('polySurface1Action', {
|
|
|
+ loop: 0
|
|
|
+ });
|
|
|
+ this.animator.play('vlAction', {
|
|
|
+ loop: 0
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
})
|