Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bbazukun123 committed Feb 14, 2024
1 parent a5cbe8a commit d3c6b91
Showing 1 changed file with 12 additions and 37 deletions.
49 changes: 12 additions & 37 deletions src/godray/GodrayFilter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// eslint-disable-next-line camelcase
import { DEG_TO_RAD, deprecation, Filter, GlProgram, GpuProgram, v8_0_0 } from 'pixi.js';
import { DEG_TO_RAD, Filter, GlProgram, GpuProgram } from 'pixi.js';
import { vertex, wgslVertex } from '../defaults';
import fragment from './god-ray.frag';
import source from './god-ray.wgsl';
Expand All @@ -8,17 +7,6 @@ import sourcePerlin from './perlin.wgsl';

import type { FilterSystem, PointData, RenderSurface, Texture } from 'pixi.js';

interface DeprecatedGodrayFilterOptions
{
angle: number;
gain: number;
lacunarity: number;
parallel: boolean;
time: number;
center: number[] | PointData;
alpha: number;
}

export interface GodrayFilterOptions
{
/**
Expand All @@ -38,7 +26,7 @@ export interface GodrayFilterOptions
* once defined in the constructor
* @default {x:0,y:0}
*/
center?: PointData;
center?: PointData | number[];
/**
* General intensity of the effect. A value closer to 1 will produce a more intense effect,
* where a value closer to 0 will produce a subtler effect.
Expand Down Expand Up @@ -107,29 +95,8 @@ export class GodrayFilter extends Filter
private _angle = 0;
private _center!: PointData;

constructor(options?: GodrayFilterOptions);
/**
* @deprecated since 8.0.0
*
* @param {object} [options] - Filter options
* @param {number} [options.angle=30] - Angle/Light-source of the rays.
* @param {number} [options.gain=0.5] - General intensity of the effect.
* @param {number} [options.lacunarity=2.5] - The density of the fractal noise.
* @param {boolean} [options.parallel=true] - `true` to use `angle`, `false` to use `center`
* @param {number} [options.time=0] - The current time position.
* @param {PIXI.PointData|number[]} [options.center=[0,0]] - Focal point for non-parallel rays,
* to use this `parallel` must be set to `false`.
* @param {number} [options.alpha=1.0] - the alpha, defaults to 1, affects transparency of rays
*/
constructor(options?: Partial<DeprecatedGodrayFilterOptions>);
constructor(options?: GodrayFilterOptions | Partial<DeprecatedGodrayFilterOptions>)
constructor(options?: GodrayFilterOptions)
{
if (Array.isArray(options?.center))
{
deprecation(v8_0_0, 'GodrayFilterOptions.center now only accepts {x, y} PointData type.');
options.center = { x: options.center[0], y: options.center[1] };
}

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

const gpuProgram = GpuProgram.from({
Expand Down Expand Up @@ -222,7 +189,15 @@ export class GodrayFilter extends Filter
* @default {x:0,y:0}
*/
get center(): PointData { return this._center; }
set center(value: PointData) { this._center = value; }
set center(value: PointData | number[])
{
if (Array.isArray(value))
{
value = { x: value[0], y: value[1] };
}

this._center = value;
}

/**
* Focal point for non-parallel rays on the `x` axis, to use this `parallel` must be set to `false`.
Expand Down

0 comments on commit d3c6b91

Please sign in to comment.