index.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. Component({
  2. behaviors: [require('../common/share-behavior').default],
  3. properties: {
  4. capacity: {
  5. type: Number,
  6. value: 20
  7. },
  8. emitRate: {
  9. type: Number,
  10. value: 5
  11. },
  12. lifeTime:{
  13. type: Number,
  14. value: 3
  15. }
  16. },
  17. data: {
  18. loaded: false
  19. },
  20. lifetimes: {},
  21. methods: {
  22. handleReady({detail}) {
  23. const xrScene = this.scene = detail.value;
  24. console.log('xr-scene', xrScene);
  25. },
  26. handleAssetsProgress: function({detail}) {
  27. console.log('assets progress', detail.value);
  28. },
  29. handleAssetsLoaded: function({detail}) {
  30. console.log('assets loaded', detail.value);
  31. this.setData({loaded: true});
  32. this.setMeshRender();
  33. },
  34. async setMeshRender(){
  35. const xrFrameSystem = wx.getXrFrameSystem()
  36. const magicField = this.scene.getElementById("magicField");
  37. const tempSystem = magicField.getComponent("custom-particle")
  38. tempSystem.addSizeGradient(0,0.7);
  39. tempSystem.addSizeGradient(0.5,1.0);
  40. tempSystem.addColorGradient(0, xrFrameSystem.Vector4.createFromNumber(1,0.89,0.27,1));
  41. tempSystem.addColorGradient(1, xrFrameSystem.Vector4.createFromNumber(1,0.64,0,1));
  42. tempSystem.addAlphaGradient(0,0,0);
  43. tempSystem.addAlphaGradient(0.5,1,1);
  44. tempSystem.addAlphaGradient(1,0,0);
  45. }
  46. }
  47. })