index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. const STATE = {
  2. NONE: -1,
  3. MOVE: 0,
  4. ZOOM_OR_PAN: 1
  5. }
  6. Component({
  7. behaviors: [require('../../common/share-behavior').default],
  8. properties: {
  9. a: Number,
  10. },
  11. data: {
  12. loaded: false,
  13. arReady: false,
  14. },
  15. lifetimes: {
  16. async attached() {
  17. console.log('data', this.data)
  18. }
  19. },
  20. methods: {
  21. handleReady({detail}) {
  22. const xrScene = this.scene = detail.value;
  23. console.log('xr-scene', xrScene);
  24. },
  25. handleAssetsProgress: function({detail}) {
  26. console.log('assets progress', detail.value);
  27. },
  28. handleAssetsLoaded: function({detail}) {
  29. console.log('assets loaded', detail.value);
  30. // this.setData({loaded: true});
  31. this.placedFlag = false;
  32. this.scene.event.addOnce('touchstart', this.placeNode.bind(this));
  33. },
  34. handleARReady: function({detail}) {
  35. console.log('arReady', this.scene.ar.arVersion);
  36. },
  37. placeNode(event) {
  38. if (this.placedFlag) {
  39. return;
  40. }
  41. const xrFrameSystem = wx.getXrFrameSystem()
  42. this.placedFlag = true;
  43. this.scene.ar.placeHere('setitem', true)
  44. const anchorTRS = this.scene.getElementById('anchor').getComponent(xrFrameSystem.Transform)
  45. anchorTRS.setData({ visible: false })
  46. anchorTRS.scale.x = 0
  47. anchorTRS.scale.y = 0
  48. anchorTRS.scale.z = 0
  49. wx.setKeepScreenOn({ keepScreenOn: true })
  50. }
  51. }
  52. })