Skip to content

Commit a2d5355

Browse files
Chore: SimpleLightmapFilter deprecate non-options constructor (#436)
* Chore: Simple Lightmap Filter Deprecations * Address Feedback --------- Co-authored-by: Baz Utsahajit <[email protected]> Co-authored-by: Matt Karl <[email protected]>
1 parent fcfaa83 commit a2d5355

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

src/simple-lightmap/SimpleLightmapFilter.ts

+36-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
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';
212
import { vertex, wgslVertex } from '../defaults';
313
import fragment from './simple-lightmap.frag';
414
import source from './simple-lightmap.wgsl';
515

16+
type DeprecatedColor = number | number[];
17+
618
export interface SimpleLightmapFilterOptions
719
{
820
/** A texture where your lightmap is rendered */
@@ -55,8 +67,30 @@ export class SimpleLightmapFilter extends Filter
5567
private _color!: Color;
5668
private _lightMap!: Texture;
5769

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?])
5980
{
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+
6094
options = { ...SimpleLightmapFilter.DEFAULT_OPTIONS, ...options };
6195

6296
if (!options.lightMap) throw Error('No light map texture source was provided to SimpleLightmapFilter');

0 commit comments

Comments
 (0)