|
1 |
| -import { Color, ColorSource, Filter, FilterSystem, GlProgram, GpuProgram, RenderSurface, Texture } from 'pixi.js'; |
| 1 | +import { |
| 2 | + Color, |
| 3 | + ColorSource, |
| 4 | + deprecation, |
| 5 | + Filter, |
| 6 | + FilterSystem, |
| 7 | + GlProgram, |
| 8 | + GpuProgram, |
| 9 | + RenderSurface, |
| 10 | + Texture, |
| 11 | +} from 'pixi.js'; |
2 | 12 | import { vertex, wgslVertex } from '../defaults';
|
3 | 13 | import fragment from './simple-lightmap.frag';
|
4 | 14 | import source from './simple-lightmap.wgsl';
|
5 | 15 |
|
| 16 | +type DeprecatedColor = number | number[]; |
| 17 | + |
6 | 18 | export interface SimpleLightmapFilterOptions
|
7 | 19 | {
|
8 | 20 | /** A texture where your lightmap is rendered */
|
@@ -55,8 +67,30 @@ export class SimpleLightmapFilter extends Filter
|
55 | 67 | private _color!: Color;
|
56 | 68 | private _lightMap!: Texture;
|
57 | 69 |
|
58 |
| - constructor(options: SimpleLightmapFilterOptions) |
| 70 | + constructor(options: SimpleLightmapFilterOptions); |
| 71 | + /** |
| 72 | + * @deprecated since 6.0.0 |
| 73 | + * |
| 74 | + * @param {PIXI.Texture} texture - a texture where your lightmap is rendered |
| 75 | + * @param {Array<number>|number} [color=0x000000] - An RGBA array of the ambient color |
| 76 | + * @param {number} [alpha=1] - Default alpha set independent of color (if it's a number, not array). |
| 77 | + */ |
| 78 | + constructor(texture: Texture, color?: DeprecatedColor, alpha?: number); |
| 79 | + constructor(...args: [SimpleLightmapFilterOptions] | [Texture, DeprecatedColor?, number?]) |
59 | 80 | {
|
| 81 | + let options = args[0] ?? {}; |
| 82 | + |
| 83 | + if (options instanceof Texture) |
| 84 | + { |
| 85 | + // eslint-disable-next-line max-len |
| 86 | + deprecation('6.0.0', 'SimpleLightmapFilter constructor params are now options object. See params: { lightMap, color, alpha }'); |
| 87 | + |
| 88 | + options = { lightMap: options }; |
| 89 | + |
| 90 | + if (args[1] !== undefined) options.color = args[1]; |
| 91 | + if (args[2] !== undefined) options.alpha = args[2]; |
| 92 | + } |
| 93 | + |
60 | 94 | options = { ...SimpleLightmapFilter.DEFAULT_OPTIONS, ...options };
|
61 | 95 |
|
62 | 96 | if (!options.lightMap) throw Error('No light map texture source was provided to SimpleLightmapFilter');
|
|
0 commit comments