index.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. Component({
  2. behaviors: [require('../common/share-behavior').default],
  3. wxball: null,
  4. wxballTransform: null,
  5. wxballAnimator: null,
  6. animationRuning: false,
  7. properties: {
  8. },
  9. data: {
  10. loaded: false,
  11. arReady: false,
  12. },
  13. lifetimes: {
  14. async attached() {
  15. console.log('data', this.data);
  16. }
  17. },
  18. methods: {
  19. handleReady({
  20. detail
  21. }) {
  22. const xrScene = this.scene = detail.value;
  23. console.log('xr-scene', xrScene);
  24. const xrFrameSystem = wx.getXrFrameSystem();
  25. this.wxball = xrScene.getElementById('wxball');
  26. this.wxballTransform = this.wxball.getComponent(xrFrameSystem.Transform);
  27. this.wxballTransform.visible = false;
  28. },
  29. handleAssetsProgress: function ({
  30. detail
  31. }) {
  32. console.log('assets progress', detail.value);
  33. },
  34. handleAssetsLoaded: function ({
  35. detail
  36. }) {
  37. console.log('assets loaded', detail.value);
  38. this.setData({
  39. loaded: true
  40. });
  41. },
  42. handleGltfLoaded: function() {
  43. const xrScene = this.scene;
  44. const xrFrameSystem = wx.getXrFrameSystem();
  45. this.wxball = xrScene.getElementById('wxball');
  46. this.wxballAnimator = this.wxball.getComponent(xrFrameSystem.Animator);
  47. this.wxballAnimator.play('gltfAnimation', {
  48. loop: 0,
  49. });
  50. this.wxballAnimator.play('gltfAnimation#0', {
  51. loop: 0,
  52. });
  53. this.wxballAnimator.pauseToFrame('gltfAnimation', 1);
  54. this.wxballAnimator.pauseToFrame('gltfAnimation#0', 1);
  55. this.wxballTransform.visible = true;
  56. },
  57. handleTouchWXball: function() {
  58. if (!this.animationRuning) {
  59. console.log('WXBALL TOUCH');
  60. this.animationRuning = true;
  61. this.wxballAnimator.pauseToFrame('gltfAnimation', 1);
  62. this.wxballAnimator.pauseToFrame('gltfAnimation#0', 1);
  63. this.wxballAnimator.resume('gltfAnimation');
  64. this.wxballAnimator.resume('gltfAnimation#0');
  65. }
  66. },
  67. handleAnimationStop: function() {
  68. console.log('animation Stop');
  69. }
  70. }
  71. })