BasicShapeEmitter.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import XrFrame from 'XrFrame';
  2. const xrFrameSystem = wx.getXrFrameSystem();
  3. // 控制发射器形态的基础类
  4. export abstract class BasicShapeEmitter {
  5. /**
  6. * keep normalized length
  7. */
  8. direction?: XrFrame.Vector3;
  9. /**
  10. * keep normalized length
  11. */
  12. direction2?: XrFrame.Vector3;
  13. // 继承实现后,获取粒子初始的发射方向
  14. abstract startDirection(worldMatrix: XrFrame.Matrix4, direction: XrFrame.Vector3, ...args: any[]): void;
  15. // 继承实现后,获取粒子初始的发射位置
  16. abstract startPosition(worldMatrix: XrFrame.Matrix4, position: XrFrame.Vector3, ...args: any[]): void;
  17. // 继承后,用于自行定制粒子轨迹的变化规律
  18. processInstance?(instance: ParticleInstance, deltaTime: number): void;
  19. // 设置该形态发射器的各项属性
  20. setProperty(properties) {
  21. properties?.forEach(([key, v]) => {
  22. switch (typeof (this[key])) {
  23. case "number":
  24. this[key] = parseFloat(v);
  25. break;
  26. //一般为vector3
  27. case "object":
  28. var stringArray = v.split(' ')
  29. this[key] = xrFrameSystem.Vector3.createFromNumber(parseFloat(stringArray[0]), parseFloat(stringArray[1]), parseFloat(stringArray[2]))
  30. break;
  31. }
  32. })
  33. }
  34. }