gameforge - v0.1.12
    Preparing search index...

    Class RenderTexture

    A RenderTexture is a special texture that allows any PixiJS display object to be rendered to it.

    Hint: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded otherwise black rectangles will be drawn instead.

    Hint-2: The actual memory allocation will happen on first render. You shouldn't create renderTextures each frame just to delete them after, try to reuse them.

    A RenderTexture takes a snapshot of any Display Object given to its render method. For example:

    import { autoDetectRenderer, RenderTexture, Sprite } from 'pixi.js';

    const renderer = autoDetectRenderer();
    const renderTexture = RenderTexture.create({ width: 800, height: 600 });
    const sprite = Sprite.from('spinObj_01.png');

    sprite.position.x = 800 / 2;
    sprite.position.y = 600 / 2;
    sprite.anchor.x = 0.5;
    sprite.anchor.y = 0.5;

    renderer.render(sprite, { renderTexture });

    // Note that you should not create a new renderer, but reuse the same one as the rest of the application.
    // The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0
    // you can clear the transform

    sprite.setTransform();

    const renderTexture = new RenderTexture.create({ width: 100, height: 100 });

    renderer.render(sprite, { renderTexture }); // Renders to center of RenderTexture

    PIXI

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _frame: Rectangle

    This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering, irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases)

    _rotate: number
    _updateID: number

    Update ID is observed by sprites and TextureMatrix instances. Call updateUvs() to increment it.

    The WebGL UV data cache. Can be used as quad UV.

    baseTexture: BaseRenderTexture

    The base texture that this texture uses.

    defaultAnchor: Point

    Anchor point that is used as default if sprite is created with this texture. Changing the defaultAnchor at a later point of time will not update Sprite's anchor point.

    {0,0}
    
    defaultBorders?: ITextureBorders

    Default width of the non-scalable border that is used if 9-slice plane is created with this texture.

    7.2.0

    PIXI.NineSlicePlane

    destroyed: boolean

    Has the texture been destroyed?

    filterFrame: null | Rectangle

    Stores sourceFrame when this texture is inside current filter stack.

    You can read it inside filters.

    filterPoolKey: null | string | number

    The key for pooled texture of FilterSystem.

    PIXI.RenderTexturePool

    noFrame: boolean

    Does this Texture have any frame data assigned to it?

    This mode is enabled automatically if no frame was passed inside constructor.

    In this mode texture is subscribed to baseTexture events, and fires update on any change.

    Beware, after loading or resize of baseTexture event can fired two times! If you want more control, subscribe on baseTexture itself.

    Any assignment of frame switches off noFrame mode.

    texture.on('update', () => {});
    
    orig: Rectangle

    This is the area of original texture, before it was put in atlas.

    textureCacheIds: string[]

    The ids under which this Texture has been added to the texture cache. This is automatically set as long as Texture.addToCache is used, but may not be set if a Texture is added directly to the TextureCache array.

    trim: Rectangle

    This is the trimmed area of original texture, before it was put in atlas Please call updateUvs() after you change coordinates of trim manually.

    uvMatrix: TextureMatrix

    Default TextureMatrix instance for this texture. By default, that object is not created because its heavy.

    valid: boolean

    This will let the renderer know if the texture is valid. If it's not then it cannot be rendered.

    prefixed: string | boolean

    Accessors

    • get frame(): Rectangle

      The frame specifies the region of the base texture that this texture uses. Please call updateUvs() after you change coordinates of frame manually.

      Returns Rectangle

    • set frame(frame: Rectangle): void

      Parameters

      Returns void

    • get framebuffer(): Framebuffer

      Shortcut to this.baseTexture.framebuffer, saves baseTexture cast.

      Returns Framebuffer

    • get height(): number

      The height of the Texture in pixels.

      Returns number

    • get multisample(): MSAA_QUALITY

      Shortcut to this.framebuffer.multisample.

      Returns MSAA_QUALITY

      PIXI.MSAA_QUALITY.NONE
      
    • set multisample(value: MSAA_QUALITY): void

      Parameters

      Returns void

    • get resolution(): number

      Returns resolution of baseTexture

      Returns number

    • get rotate(): number

      Indicates whether the texture is rotated inside the atlas set to 2 to compensate for texture packer rotation set to 6 to compensate for spine packer rotation can be used to rotate or mirror sprites See PIXI.groupD8 for explanation

      Returns number

    • set rotate(rotate: number): void

      Parameters

      • rotate: number

      Returns void

    • get width(): number

      The width of the Texture in pixels.

      Returns number

    • get EMPTY(): Texture<Resource>

      An empty texture, used often to not have to create multiple empty textures. Can not be destroyed.

      Returns Texture<Resource>

    • get WHITE(): Texture<CanvasResource>

      A white texture of 16x16 size, used for graphics and other things Can not be destroyed.

      Returns Texture<CanvasResource>

    Methods

    • Type Parameters

      • T extends string | symbol

      Parameters

      • event: T
      • fn: (...args: any[]) => void
      • Optionalcontext: any

      Returns this

    • Creates a new texture object that acts the same as this one.

      Returns Texture

      • The new texture
    • Destroys this texture

      Parameters

      • OptionaldestroyBase: boolean

        Whether to destroy the base texture as well

      Returns void

      PIXI.Texture#destroyed

    • Calls each of the listeners registered for a given event.

      Type Parameters

      • T extends string | symbol

      Parameters

      • event: T
      • ...args: any[]

      Returns boolean

    • Return an array listing the events for which the emitter has registered listeners.

      Returns (string | symbol)[]

    • Return the number of listeners listening to a given event.

      Parameters

      • event: string | symbol

      Returns number

    • Return the listeners registered for a given event.

      Type Parameters

      • T extends string | symbol

      Parameters

      • event: T

      Returns ((...args: any[]) => void)[]

    • Type Parameters

      • T extends string | symbol

      Parameters

      • event: T
      • Optionalfn: (...args: any[]) => void
      • Optionalcontext: any
      • Optionalonce: boolean

      Returns this

    • Add a listener for a given event.

      Type Parameters

      • T extends string | symbol

      Parameters

      • event: T
      • fn: (...args: any[]) => void
      • Optionalcontext: any

      Returns this

    • Protected

      Called when the base texture is updated

      Parameters

      Returns void

    • Add a one-time listener for a given event.

      Type Parameters

      • T extends string | symbol

      Parameters

      • event: T
      • fn: (...args: any[]) => void
      • Optionalcontext: any

      Returns this

    • Remove all listeners, or those of the specified event.

      Parameters

      • Optionalevent: string | symbol

      Returns this

    • Remove the listeners of a given event.

      Type Parameters

      • T extends string | symbol

      Parameters

      • event: T
      • Optionalfn: (...args: any[]) => void
      • Optionalcontext: any
      • Optionalonce: boolean

      Returns this

    • Resizes the RenderTexture.

      Parameters

      • desiredWidth: number

        The desired width to resize to.

      • desiredHeight: number

        The desired height to resize to.

      • OptionalresizeBaseTexture: boolean

        Should the baseTexture.width and height values be resized as well?

      Returns void

    • Changes the resolution of baseTexture, but does not change framebuffer size.

      Parameters

      • resolution: number

        The new resolution to apply to RenderTexture

      Returns void

    • Updates this texture on the gpu.

      Calls the TextureResource update.

      If you adjusted frame manually, please call updateUvs() instead.

      Returns void

    • Updates the internal WebGL UV cache. Use it after you change frame or trim of the texture. Call it after changing the frame

      Returns void

    • Adds a Texture to the global TextureCache. This cache is shared across the whole PIXI object.

      Parameters

      • texture: Texture

        The Texture to add to the cache.

      • id: string

        The id that the Texture will be stored against.

      Returns void

    • Helper function that creates a new Texture based on the source you provide. The source can be - frame id, image url, video url, canvas element, video element, base texture

      Type Parameters

      Parameters

      • source: TextureSource | TextureSource[]

        Source or array of sources to create texture from

      • Optionaloptions: IBaseTextureOptions<RO>

        See PIXI.BaseTexture's constructor for options.

      • Optionalstrict: boolean

        Enforce strict-mode, see PIXI.settings.STRICT_TEXTURE_CACHE.

      Returns Texture<R>

      The newly created texture

    • Create a texture from a source and add to the cache.

      Type Parameters

      Parameters

      • source: string | ImageSource

        The input source.

      • imageUrl: string

        File name of texture, for cache and resolving resolution.

      • Optionalname: string

        Human readable name for the texture cache. If no name is specified, only imageUrl will be used as the cache ID.

      • Optionaloptions: IBaseTextureOptions<any>

      Returns Promise<Texture<R>>

      • Output texture
    • Useful for loading textures via URLs. Use instead of Texture.from because it does a better job of handling failed URLs more effectively. This also ignores PIXI.settings.STRICT_TEXTURE_CACHE. Works for Videos, SVGs, Images.

      Type Parameters

      Parameters

      • url: string | string[]

        The remote URL or array of URLs to load.

      • Optionaloptions: IBaseTextureOptions<RO>

        Optional options to include

      Returns Promise<Texture<R>>

      • A Promise that resolves to a Texture.