pixi.js
    Preparing search index...

    Class extensions

    Global registration system for all PixiJS extensions. Provides a centralized way to add, remove, and manage functionality across the engine.

    Features:

    • Register custom extensions and plugins
    • Handle multiple extension types
    • Priority-based ordering
    import { extensions, ExtensionType } from 'pixi.js';

    // Register a simple object extension
    extensions.add({
    extension: {
    type: ExtensionType.LoadParser,
    name: 'my-loader',
    priority: 100, // Optional priority for ordering
    },
    // add load parser functions
    });

    // Register a class-based extension
    class MyRendererPlugin {
    static extension = {
    type: [ExtensionType.WebGLSystem, ExtensionType.WebGPUSystem],
    name: 'myRendererPlugin'
    };

    // add renderer plugin methods
    }
    extensions.add(MyRendererPlugin);

    // Remove extensions
    extensions.remove(MyRendererPlugin);
    • Extensions must have a type from ExtensionType
    • Can be registered before or after their handlers
    • Supports priority-based ordering
    • Automatically normalizes extension formats
    Index

    Methods

    Methods

    • Register new extensions with PixiJS. Extensions can be registered in multiple formats:

      • As a class with a static extension property
      • As an extension format object
      • As multiple extensions passed as separate arguments

      Parameters

      • ...extensions: any[]

        Extensions to add to PixiJS. Each can be:

        • A class with static extension property
        • An extension format object with type and ref
        • Multiple extensions as separate arguments

      Returns {
          add(
              ...extensions: any[],
          ): { _addHandlers: Partial<Record<ExtensionType, ExtensionHandler>>; _removeHandlers: Partial<Record<ExtensionType, ExtensionHandler>>; ... 7 more ...; mixin(Target: any, ...sources: unknown[]): void; };
          mixin(Target: any, ...sources: unknown[]): void;
          remove(
              ...extensions: any[],
          ): { _addHandlers: Partial<Record<ExtensionType, ExtensionHandler>>; _removeHandlers: Partial<Record<ExtensionType, ExtensionHandler>>; ... 7 more ...; mixin(Target: any, ...sources: unknown[]): void; };
      }

      This extensions instance for chaining

      • add: function
        • Register new extensions with PixiJS. Extensions can be registered in multiple formats:

          • As a class with a static extension property
          • As an extension format object
          • As multiple extensions passed as separate arguments

          Parameters

          • ...extensions: any[]

            Extensions to add to PixiJS. Each can be:

            • A class with static extension property
            • An extension format object with type and ref
            • Multiple extensions as separate arguments

          Returns { _addHandlers: Partial<Record<ExtensionType, ExtensionHandler>>; _removeHandlers: Partial<Record<ExtensionType, ExtensionHandler>>; ... 7 more ...; mixin(Target: any, ...sources: unknown[]): void; }

          This extensions instance for chaining

          // Register a simple extension
          extensions.add(MyRendererPlugin);

          // Register multiple extensions
          extensions.add(
          MyRendererPlugin,
          MySystemPlugin,
          });
      • mixin: function
        • Mixin the source object(s) properties into the target class's prototype. Copies all property descriptors from source objects to the target's prototype.

          Parameters

          • Target: any

            The target class to mix properties into

          • ...sources: unknown[]

            One or more source objects containing properties to mix in

          Returns void

          // Create a mixin with shared properties
          const moveable = {
          x: 0,
          y: 0,
          move(x: number, y: number) {
          this.x += x;
          this.y += y;
          }
          };

          // Create a mixin with computed properties
          const scalable = {
          scale: 1,
          get scaled() {
          return this.scale > 1;
          }
          };

          // Apply mixins to a class
          extensions.mixin(Sprite, moveable, scalable);

          // Use mixed-in properties
          const sprite = new Sprite();
          sprite.move(10, 20);
          console.log(sprite.x, sprite.y); // 10, 20
          • Copies all properties including getters/setters
          • Does not modify source objects
          • Preserves property descriptors
      • remove: function
        • Remove extensions from PixiJS.

          Parameters

          • ...extensions: any[]

            Extensions to be removed. Can be:

            • Extension class with static extension property
            • Extension format object with type and ref
            • Multiple extensions as separate arguments

          Returns { _addHandlers: Partial<Record<ExtensionType, ExtensionHandler>>; _removeHandlers: Partial<Record<ExtensionType, ExtensionHandler>>; ... 7 more ...; mixin(Target: any, ...sources: unknown[]): void; }

          this for chaining

          // Remove a single extension
          extensions.remove(MyRendererPlugin);

          // Remove multiple extensions
          extensions.remove(
          MyRendererPlugin,
          MySystemPlugin
          );
      // Register a simple extension
      extensions.add(MyRendererPlugin);

      // Register multiple extensions
      extensions.add(
      MyRendererPlugin,
      MySystemPlugin,
      });
    • Mixin the source object(s) properties into the target class's prototype. Copies all property descriptors from source objects to the target's prototype.

      Parameters

      • Target: any

        The target class to mix properties into

      • ...sources: unknown[]

        One or more source objects containing properties to mix in

      Returns void

      // Create a mixin with shared properties
      const moveable = {
      x: 0,
      y: 0,
      move(x: number, y: number) {
      this.x += x;
      this.y += y;
      }
      };

      // Create a mixin with computed properties
      const scalable = {
      scale: 1,
      get scaled() {
      return this.scale > 1;
      }
      };

      // Apply mixins to a class
      extensions.mixin(Sprite, moveable, scalable);

      // Use mixed-in properties
      const sprite = new Sprite();
      sprite.move(10, 20);
      console.log(sprite.x, sprite.y); // 10, 20
      • Copies all properties including getters/setters
      • Does not modify source objects
      • Preserves property descriptors
    • Remove extensions from PixiJS.

      Parameters

      • ...extensions: any[]

        Extensions to be removed. Can be:

        • Extension class with static extension property
        • Extension format object with type and ref
        • Multiple extensions as separate arguments

      Returns {
          add(
              ...extensions: any[],
          ): { _addHandlers: Partial<Record<ExtensionType, ExtensionHandler>>; _removeHandlers: Partial<Record<ExtensionType, ExtensionHandler>>; ... 7 more ...; mixin(Target: any, ...sources: unknown[]): void; };
          mixin(Target: any, ...sources: unknown[]): void;
          remove(
              ...extensions: any[],
          ): { _addHandlers: Partial<Record<ExtensionType, ExtensionHandler>>; _removeHandlers: Partial<Record<ExtensionType, ExtensionHandler>>; ... 7 more ...; mixin(Target: any, ...sources: unknown[]): void; };
      }

      this for chaining

      • add: function
        • Register new extensions with PixiJS. Extensions can be registered in multiple formats:

          • As a class with a static extension property
          • As an extension format object
          • As multiple extensions passed as separate arguments

          Parameters

          • ...extensions: any[]

            Extensions to add to PixiJS. Each can be:

            • A class with static extension property
            • An extension format object with type and ref
            • Multiple extensions as separate arguments

          Returns { _addHandlers: Partial<Record<ExtensionType, ExtensionHandler>>; _removeHandlers: Partial<Record<ExtensionType, ExtensionHandler>>; ... 7 more ...; mixin(Target: any, ...sources: unknown[]): void; }

          This extensions instance for chaining

          // Register a simple extension
          extensions.add(MyRendererPlugin);

          // Register multiple extensions
          extensions.add(
          MyRendererPlugin,
          MySystemPlugin,
          });
      • mixin: function
        • Mixin the source object(s) properties into the target class's prototype. Copies all property descriptors from source objects to the target's prototype.

          Parameters

          • Target: any

            The target class to mix properties into

          • ...sources: unknown[]

            One or more source objects containing properties to mix in

          Returns void

          // Create a mixin with shared properties
          const moveable = {
          x: 0,
          y: 0,
          move(x: number, y: number) {
          this.x += x;
          this.y += y;
          }
          };

          // Create a mixin with computed properties
          const scalable = {
          scale: 1,
          get scaled() {
          return this.scale > 1;
          }
          };

          // Apply mixins to a class
          extensions.mixin(Sprite, moveable, scalable);

          // Use mixed-in properties
          const sprite = new Sprite();
          sprite.move(10, 20);
          console.log(sprite.x, sprite.y); // 10, 20
          • Copies all properties including getters/setters
          • Does not modify source objects
          • Preserves property descriptors
      • remove: function
        • Remove extensions from PixiJS.

          Parameters

          • ...extensions: any[]

            Extensions to be removed. Can be:

            • Extension class with static extension property
            • Extension format object with type and ref
            • Multiple extensions as separate arguments

          Returns { _addHandlers: Partial<Record<ExtensionType, ExtensionHandler>>; _removeHandlers: Partial<Record<ExtensionType, ExtensionHandler>>; ... 7 more ...; mixin(Target: any, ...sources: unknown[]): void; }

          this for chaining

          // Remove a single extension
          extensions.remove(MyRendererPlugin);

          // Remove multiple extensions
          extensions.remove(
          MyRendererPlugin,
          MySystemPlugin
          );
      // Remove a single extension
      extensions.remove(MyRendererPlugin);

      // Remove multiple extensions
      extensions.remove(
      MyRendererPlugin,
      MySystemPlugin
      );