Skip to content

Commit

Permalink
Chore: Simple Lightmap Filter Deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
bbazukun123 committed Feb 8, 2024
1 parent 9d610bb commit 4f234c1
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions src/simple-lightmap/SimpleLightmapFilter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import { Color, ColorSource, Filter, FilterSystem, GlProgram, GpuProgram, RenderSurface, Texture } from 'pixi.js';
import {
Color,
ColorSource,
deprecation,
Filter,
FilterSystem,
GlProgram,
GpuProgram,
RenderSurface,
Texture,
// eslint-disable-next-line camelcase
v8_0_0,
} 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,13 +69,35 @@ export class SimpleLightmapFilter extends Filter
private _color!: Color;
private _lightMap!: Texture;

constructor(options: SimpleLightmapFilterOptions)
constructor(options: SimpleLightmapFilterOptions);
/**
* @deprecated since 8.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(v8_0_0, 'SimpleLightmapFilter constructor params are now options object. See params: { lightMap, color, alpha }');

options = { lightMap: options };

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

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

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

const gpuProgram = new GpuProgram({
const gpuProgram = GpuProgram.from({
vertex: {
source: wgslVertex,
entryPoint: 'mainVertex',
Expand All @@ -71,7 +107,7 @@ export class SimpleLightmapFilter extends Filter
entryPoint: 'mainFragment',
},
});
const glProgram = new GlProgram({
const glProgram = GlProgram.from({
vertex,
fragment,
name: 'simple-lightmap-filter',
Expand Down

0 comments on commit 4f234c1

Please sign in to comment.