index.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. Component({
  2. behaviors: [require('../common/share-behavior').default],
  3. properties: {},
  4. data: {
  5. loaded: false
  6. },
  7. lifetimes: {},
  8. methods: {
  9. handleReady: function({detail}) {
  10. this.scene = detail.value;
  11. this.rotSpeed = 1;
  12. this.rotAxis = 0;
  13. },
  14. handleTouchStart: function({detail}) {
  15. console.log('touch start', detail.value);
  16. },
  17. handleTouchEnd: function({detail}) {
  18. console.log('touch end', detail.value);
  19. this.rotAxis += 1;
  20. if (this.rotAxis >= 3) {
  21. this.rotAxis = 0;
  22. }
  23. this.changeSpeed();
  24. },
  25. handleDrag: function({detail}) {
  26. const info = detail.value;
  27. console.log('drag', info);
  28. this.rotSpeed += info.deltaX / this.scene.width;
  29. this.changeSpeed();
  30. },
  31. changeSpeed() {
  32. const xrSystem = wx.getXrFrameSystem();
  33. const el = this.scene.getElementById('artg');
  34. const comp = el.getComponent('auto-rotate');
  35. if (comp) {
  36. comp.setData({speed: [0, 0, 0].map((_, i) => i === this.rotAxis ? this.rotSpeed : 0)});
  37. }
  38. },
  39. handleAssetsProgress: function({detail}) {
  40. console.log('assets progress', detail.value);
  41. },
  42. handleAssetsLoaded: function({detail}) {
  43. console.log('assets loaded', detail.value);
  44. this.setData({loaded: true});
  45. },
  46. handleLog: function({detail}) {
  47. console.log('log', detail.value);
  48. }
  49. }
  50. })