index.js 966 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. Component({
  2. behaviors: [require('../common/share-behavior').default],
  3. properties: {},
  4. data: {
  5. stars: []
  6. },
  7. lifetimes: {},
  8. methods: {
  9. handleReady: function({detail}) {
  10. this.scene = detail.value;
  11. const stars = new Array(44).fill(0).map(() => {
  12. return {
  13. pos: [
  14. (Math.random() * 2 - 1) * 4,
  15. (Math.random() * 2 - 1) * 4,
  16. (Math.random() * 2 - 1) * 4,
  17. ].join(' '),
  18. color: [
  19. Math.random(),
  20. Math.random(),
  21. Math.random(),
  22. 1
  23. ].join(' '),
  24. speed: (Math.random() + 0.2) * 3
  25. };
  26. });
  27. console.log(stars)
  28. this.setData({stars});
  29. },
  30. handleAssetsProgress: function({detail}) {
  31. console.log('assets progress', detail.value);
  32. },
  33. handleAssetsLoaded: function({detail}) {
  34. console.log('assets loaded', detail.value);
  35. this.setData({loaded: true});
  36. }
  37. }
  38. })