rexrainbow / phaser3-rex-notes

Notes of phaser3 engine
MIT License
1.21k stars 260 forks source link

Couple of definitions not present .d.ts GlowFilter2PipelinePlugin #275

Closed ccmoralesj closed 2 years ago

ccmoralesj commented 2 years ago

Hello there 👋🏼

distance, quality, and knockout are not present in the type declaration file for GlowFilter2PipelinePlugin. Also setDistance and setQuality are present in the declaration file, but not present at all to be called in the code.

Thanks!

rexrainbow commented 2 years ago

GlowFilter2PipelinePlugin is a plugin instance, not a GlowFilter2Pipeline instance. glowPlugin.add(gameObject) will return a GlowFilter2Pipeline instance (typescript define file).

quality(setQuality(), getQuality() ) and distance(setDistance(), getDistance()) are static methods of GlowFilter2Pipeline class. quality and distance can't change after creating GlowFilter2Pipeline instance.

ccmoralesj commented 2 years ago

Maybe I'm doing something wrong.

I have this

const glowDistance = 100;
    const glowOuterStrength = 5.5;
    const pipeline = this.rexGlow.add(redComboBar, {
      distance: glowDistance,
      glowColor: ScoreScene.RED_COMBO_BAR_COLOR,
      outerStrength: 0, 
      innerStrength: 0, 
      quality: 0.03,
    });

    // 2. Add glow effect as a tween
    this.tweens.add({
      targets: pipeline,
      outerStrength: glowOuterStrength,
      ease: 'Sine.easeInOut',
      repeat: -1,
      yoyo: true,
    });

But I get an error because Typescript says I can't add distance or quality because they don't exist in the definition type. When I try to access it. I see this (see code below) and double-checking in the code apparently my statement is correct (see here).

.../games/type-fighters/node_modules/phaser3-rex-plugins/plugins/glowfilter2pipeline-plugin.d.ts

// import * as Phaser from 'phaser';
import GlowFilterPostFxPipeline from './glowfilter2pipeline';

export default GlowFilterPipelinePlugin;

declare namespace GlowFilterPipelinePlugin {

    interface IConfig {
        outerStrength?: number,
        innerStrength?: number,
        glowColor?: number,
        name?: string,
        knockout?: boolean,
    }

}

declare class GlowFilterPipelinePlugin extends Phaser.Plugins.BasePlugin {
    add(
        gameObject: Phaser.GameObjects.GameObject,
        config?: GlowFilterPipelinePlugin.IConfig
    ): GlowFilterPostFxPipeline;

    remove(
        gameObject: Phaser.GameObjects.GameObject,
        name?: string
    ): this;

    get(
        gameObject: Phaser.GameObjects.GameObject,
        name?: string
    ): GlowFilterPostFxPipeline | GlowFilterPostFxPipeline[];

    setQuality(value: number): this;
    quality: number;

    setDistance(value: number): this;
    distance: number;    
}

So... Am I doing something wrong? I manually added those 2 (distance and quality) attributes to the IConfig interface and the plugin is working great now. That's why I opened this issue in the first place because apparently, they need to be added to the definitions.

Let me know your thoughts 🤔

rexrainbow commented 2 years ago

I see, distance and quality are missed in config indeed. Will add to d.ts file later. Thanks for this reporting.

ccmoralesj commented 2 years ago

Thanks to you 💓