123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- Component({
- behaviors: [require('../common/share-behavior').default],
- wxball: null,
- wxballTransform: null,
- wxballAnimator: null,
- animationRuning: false,
- properties: {
- },
- data: {
- loaded: false,
- arReady: false,
- },
- lifetimes: {
- async attached() {
- console.log('data', this.data);
- }
- },
- methods: {
- handleReady({
- detail
- }) {
- const xrScene = this.scene = detail.value;
- console.log('xr-scene', xrScene);
- const xrFrameSystem = wx.getXrFrameSystem();
- this.wxball = xrScene.getElementById('wxball');
- this.wxballTransform = this.wxball.getComponent(xrFrameSystem.Transform);
- this.wxballTransform.visible = false;
- },
- handleAssetsProgress: function ({
- detail
- }) {
- console.log('assets progress', detail.value);
- },
- handleAssetsLoaded: function ({
- detail
- }) {
- console.log('assets loaded', detail.value);
- this.setData({
- loaded: true
- });
- },
- handleGltfLoaded: function() {
- const xrScene = this.scene;
- const xrFrameSystem = wx.getXrFrameSystem();
-
- this.wxball = xrScene.getElementById('wxball');
- this.wxballAnimator = this.wxball.getComponent(xrFrameSystem.Animator);
- this.wxballAnimator.play('gltfAnimation', {
- loop: -1,
- });
- this.wxballAnimator.play('gltfAnimation#0', {
- loop: -1,
- });
- this.wxballTransform.visible = true;
- },
- handleTouchWXball: function() {
-
- if (!this.animationRuning) {
- console.log('WXBALL TOUCH');
- this.animationRuning = true;
- this.wxballAnimator.pauseToFrame('gltfAnimation', 1);
- this.wxballAnimator.pauseToFrame('gltfAnimation#0', 1);
-
- this.wxballAnimator.resume('gltfAnimation');
- this.wxballAnimator.resume('gltfAnimation#0');
- }
- },handleARTrackerState({detail}) {
- // 事件的值即为`ARTracker`实例
- const tracker = detail.value;
- // 获取当前状态和错误信息
- const {state, errorMessage} = tracker;
- },
- handleAnimationStop: function() {
- console.log('animation Stop');
- }
- }
- })
|