Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Simple Lightmap Filter Deprecations #436

Merged
merged 3 commits into from
Feb 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions src/simple-lightmap/SimpleLightmapFilter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import { Color, ColorSource, Filter, FilterSystem, GlProgram, GpuProgram, RenderSurface, Texture } from 'pixi.js';
import {
Color,
ColorSource,
deprecation,
Filter,
FilterSystem,
GlProgram,
GpuProgram,
RenderSurface,
Texture,
} from 'pixi.js';
import { vertex, wgslVertex } from '../defaults';
import fragment from './simple-lightmap.frag';
import source from './simple-lightmap.wgsl';

type DeprecatedColor = number | number[];

export interface SimpleLightmapFilterOptions
{
/** A texture where your lightmap is rendered */
Expand Down Expand Up @@ -55,8 +67,30 @@ export class SimpleLightmapFilter extends Filter
private _color!: Color;
private _lightMap!: Texture;

constructor(options: SimpleLightmapFilterOptions)
constructor(options: SimpleLightmapFilterOptions);
/**
* @deprecated since 6.0.0
*
* @param {PIXI.Texture} texture - a texture where your lightmap is rendered
* @param {Array<number>|number} [color=0x000000] - An RGBA array of the ambient color
* @param {number} [alpha=1] - Default alpha set independent of color (if it's a number, not array).
*/
constructor(texture: Texture, color?: DeprecatedColor, alpha?: number);
constructor(...args: [SimpleLightmapFilterOptions] | [Texture, DeprecatedColor?, number?])
{
let options = args[0] ?? {};

if (options instanceof Texture)
{
// eslint-disable-next-line max-len
deprecation('6.0.0', 'SimpleLightmapFilter constructor params are now options object. See params: { lightMap, color, alpha }');

options = { lightMap: options };

if (args[1] !== undefined) options.color = args[1];
if (args[2] !== undefined) options.alpha = args[2];
}

options = { ...SimpleLightmapFilter.DEFAULT_OPTIONS, ...options };

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