LogoPixi’VN
pixi-jsClasses

Class: extensions

Defined in: node_modules/pixi.js/lib/extensions/Extensions.d.ts:159

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

Example

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);

Remarks

  • Extensions must have a type from ExtensionType
  • Can be registered before or after their handlers
  • Supports priority-based ordering
  • Automatically normalizes extension formats

See

Standard

Methods

add()

> static add(...extensions): any

Defined in: node_modules/pixi.js/lib/extensions/Extensions.d.ts:213

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

any

This extensions instance for chaining

Example

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

// Register multiple extensions
extensions.add(
    MyRendererPlugin,
    MySystemPlugin,
});

See


mixin()

> static mixin(Target, ...sources): void

Defined in: node_modules/pixi.js/lib/extensions/Extensions.d.ts:293

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

Example

// 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

Remarks

  • Copies all properties including getters/setters
  • Does not modify source objects
  • Preserves property descriptors

See

  • Object.defineProperties For details on property descriptors
  • Object.getOwnPropertyDescriptors For details on property copying

remove()

> static remove(...extensions): any

Defined in: node_modules/pixi.js/lib/extensions/Extensions.d.ts:187

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

any

this for chaining

Example

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

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

See