index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. Component({
  2. behaviors: [require('../../common/share-behavior').default],
  3. properties: {
  4. a: Number,
  5. },
  6. data: {
  7. loaded: false,
  8. arReady: false,
  9. },
  10. lifetimes: {
  11. async attached() {
  12. console.log('data', this.data)
  13. }
  14. },
  15. methods: {
  16. handleReady({detail}) {
  17. console.log('xr-scene12312312');
  18. const xrScene = this.scene = detail.value;
  19. this.mat = new (wx.getXrFrameSystem().Matrix4)();
  20. console.log('xr-scene', xrScene);
  21. },
  22. handleAssetsProgress: function({detail}) {
  23. console.log('assets progress', detail.value);
  24. },
  25. handleAssetsLoaded: function({detail}) {
  26. console.log('assets loaded', detail.value);
  27. // this.setData({loaded: true});
  28. this.scene.event.addOnce('touchstart', this.placeNode.bind(this));
  29. },
  30. handleARReady: function({detail}) {
  31. console.log('arReady', this.scene.ar.arVersion);
  32. },
  33. placeNode(event) {
  34. const {clientX, clientY} = event.touches[0];
  35. const {frameWidth: width, frameHeight: height} = this.scene;
  36. if (clientY / height > 0.8 && clientX / width < 0.2) {
  37. this.scene.getNodeById('setitem').visible = false;
  38. this.scene.ar.resetPlane();
  39. } else {
  40. this.scene.ar.placeHere('setitem', true);
  41. }
  42. this.scene.event.addOnce('touchstart', this.placeNode.bind(this));
  43. }
  44. }
  45. })