index.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. const xrFrameSystem = wx.getXrFrameSystem()
  26. const fireworkField = xrScene.getElementById("firework");
  27. const tempSystem = fireworkField.getComponent('custom-particle')
  28. tempSystem.addSizeGradient(0,0.2);
  29. tempSystem.addSizeGradient(3,0.5);
  30. var myData ={}
  31. myData = {
  32. "capacity": 200,
  33. "emitRate": 0, //子发射器不进行每秒发射
  34. "burstCount": 200, // 一次爆发200粒子
  35. "burstTime": 0, // 爆发延时为0
  36. "burstCycle": 1, // 发射一次
  37. "size":[0.05],
  38. "startColor":[1,1,0,1],
  39. "endColor":[1,0,0,0],
  40. "emitterType":"SphereShape",
  41. "emitterProps": [["radius","0.8"]],
  42. "lifeTime":[3], // 粒子生命周期为3秒
  43. "stopDuration":[3], // 子发射器生命周期为3秒
  44. "speed":[1],
  45. "texture":"flarePicture"
  46. }
  47. var subEmitter = tempSystem.createSubEmitter(myData)
  48. subEmitter.state = 1 // 设置为1为当粒子消失后出现作用子发射器
  49. //可以规定多个子发射器的阵列
  50. tempSystem.subEmitters = [subEmitter]
  51. },
  52. handleAssetsProgress: function({detail}) {
  53. console.log('assets progress', detail.value);
  54. },
  55. handleAssetsLoaded: function({detail}) {
  56. }
  57. }
  58. })