babylon.lensFlare.ts 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. module BABYLON {
  2. export class LensFlare {
  3. public color: Color3;
  4. public texture: Nullable<Texture>;
  5. public alphaMode: number = Engine.ALPHA_ONEONE;
  6. private _system: LensFlareSystem;
  7. public static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare {
  8. return new LensFlare(size, position, color, imgUrl, system);
  9. }
  10. constructor(public size: number, public position: number, color: Color3, imgUrl: string, system: LensFlareSystem) {
  11. this.color = color || new Color3(1, 1, 1);
  12. this.texture = imgUrl ? new Texture(imgUrl, system.getScene(), true) : null;
  13. this._system = system;
  14. system.lensFlares.push(this);
  15. }
  16. public dispose(): void {
  17. if (this.texture) {
  18. this.texture.dispose();
  19. }
  20. // Remove from scene
  21. var index = this._system.lensFlares.indexOf(this);
  22. this._system.lensFlares.splice(index, 1);
  23. };
  24. }
  25. }