gameforge - v0.1.12
    Preparing search index...

    Class CompressedTextureResource

    Resource for compressed texture formats, as follows: S3TC/DXTn (& their sRGB formats), ATC, ASTC, ETC 1/2, PVRTC, BPTC (BC6H, BC7).

    Compressed textures improve performance when rendering is texture-bound. The texture data stays compressed in graphics memory, increasing memory locality and speeding up texture fetches. These formats can also be used to store more detail in the same amount of memory.

    For most developers, container file formats are a better abstraction instead of directly handling raw texture data. PixiJS provides native support for the following texture file formats (via PIXI.loadBasis, PIXI.loadKTX, and PIXI.loadDDS):

    .dds - the DirectDraw Surface file format stores DXTn (DXT-1,3,5) data or BCn (BC6H, BC7). See PIXI.parseDDS .ktx - the Khronos Texture Container file format supports storing all the supported WebGL compression formats. See PIXI.parseKTX. .basis - the BASIS supercompressed file format stores texture data in an internal format that is transcoded to the compression format supported on the device at runtime. It also supports transcoding into a uncompressed format as a fallback; you must install the @pixi/basis-loader, @pixi/basis-transcoder packages separately to use these files. See PIXI.BasisParser.

    The loaders for the aforementioned formats use CompressedTextureResource internally. It is strongly suggested that they be used instead.

    Since CompressedTextureResource inherits BlobResource, you can provide it a URL pointing to a file containing the raw texture data (with no file headers!):

    import { CompressedTextureResource, INTERNAL_FORMATS } from '@pixi/compressed-textures';
    import { BaseTexture, Texture, ALPHA_MODES } from 'pixi.js';

    // The resource backing the texture data for your textures.
    // NOTE: You can also provide a ArrayBufferView instead of a URL. This is used when loading data from a container file
    // format such as KTX, DDS, or BASIS.
    const compressedResource = new CompressedTextureResource('bunny.dxt5', {
    format: INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT5_EXT,
    width: 256,
    height: 256,
    });

    // You can create a base-texture to the cache, so that future `Texture`s can be created using the `Texture.from` API.
    const baseTexture = new BaseTexture(compressedResource, { pmaMode: ALPHA_MODES.NPM });

    // Create a Texture to add to the TextureCache
    const texture = new Texture(baseTexture);

    // Add baseTexture & texture to the global texture cache
    BaseTexture.addToCache(baseTexture, 'bunny.dxt5');
    Texture.addToCache(texture, 'bunny.dxt5');

    PIXI

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • source: string | BufferType

        the buffer/URL holding the compressed texture data

      • options: ICompressedTextureResourceOptions
        • format

          the compression format

        • width

          the image width in pixels.

        • height

          the image height in pixels.

        • level

          the mipmap levels stored in the compressed texture, including level 0.

        • levelBuffers

          the buffers for each mipmap level. CompressedTextureResource can allows you to pass null for source, for cases where each level is stored in non-contiguous memory.

      Returns CompressedTextureResource

    Properties

    _height: number

    Internal height of the resource.

    _width: number

    Internal width of the resource.

    buffer: null | ViewableBuffer

    The viewable buffer on the data.

    The data of this resource.

    destroyed: boolean

    If resource has been destroyed.

    false
    

    The compression format

    internal: boolean

    true if resource is created by BaseTexture useful for doing cleanup with BaseTexture destroy and not cleaning up resources that were created externally.

    levels: number

    The number of mipmap levels stored in the resource buffer.

    1
    
    loaded: boolean
    origin: null | string

    The URL of the texture file.

    src: string

    The url of the resource

    unpackAlignment: 1 | 2 | 4 | 8

    The alignment of the rows in the data.

    Accessors

    • get height(): number

      The height of the resource.

      Returns number

    • get valid(): boolean

      Has been validated

      Returns boolean

    • get width(): number

      The width of the resource.

      Returns number

    Methods

    • Bind to a parent BaseTexture

      Parameters

      Returns void

    • Call when destroying resource, unbind any BaseTexture object before calling this method, as reference counts are maintained internally.

      Returns void

    • Destroy and don't use after this.

      Returns void

    • Protected

      Returns void

    • Trigger a resize event

      Parameters

      • width: number

        X dimension

      • height: number

        Y dimension

      Returns void

    • Set the style, optional to override

      Parameters

      Returns boolean

      • true is success
    • Unbind to a parent BaseTexture

      Parameters

      Returns void

    • Has been updated trigger event.

      Returns void

    • Parameters

      • renderer: Renderer

        A reference to the current renderer

      • _texture: BaseTexture

        the texture

      • _glTexture: GLTexture

        texture instance for this webgl context

      Returns boolean

    • Used to auto-detect the type of resource.

      Parameters

      • source: unknown

        The source object

      Returns source is BufferType

      true if buffer source