Small World Engine API Reference - v0.76.20
    Preparing search index...

    Class TextureArray

    Represents a 2D Texture Array (sampler2DArray in WebGL2, texture_2d_array in WebGPU). All images must have the exact same dimensions and format.

    Hierarchy (View Summary)

    Index
    addressModeU: TextureWrap = TextureWrap.DEFAULT

    The wrapping mode for the U coordinate.

    addressModeV: TextureWrap = TextureWrap.DEFAULT

    The wrapping mode for the V coordinate.

    anisotropy: number = 1

    Desired anisotropic filtering level for this texture.

    generateMipmaps: boolean = true

    Whether mipmaps should be generated for this texture.

    image: ImageBitmap | HTMLImageElement | HTMLCanvasElement | undefined = undefined

    The underlying image, bitmap, or canvas data.

    images: (ImageBitmap | HTMLImageElement)[]
    isLoaded: boolean = false

    Whether the texture is fully loaded and ready for use.

    isTextureArray: boolean = true
    magFilter: TextureFilter = TextureFilter.DEFAULT

    The magnification filter.

    minFilter: TextureFilter = TextureFilter.DEFAULT

    The minification filter.

    needsUpdate: boolean = false

    Set to true after mutating image in place (e.g. redrawing a canvas) to force a GPU re-upload.

    offset: { x: number; y: number } = ...

    The UV offset.

    repeat: { x: number; y: number } = ...

    The UV repeat factors.

    • Flips the texture horizontally by modifying the UV offset and repeat.

      Returns this

      This texture instance for chaining.

    • Flips the texture vertically by modifying the UV offset and repeat.

      Returns this

      This texture instance for chaining.

    • Creates a texture backed directly by a canvas. Redraw the canvas and set needsUpdate = true to push the new pixels to the GPU on the next frame.

      Parameters

      • canvas: HTMLCanvasElement

        The canvas to use as the texture's pixel source.

      • Optionaloptions: TextureOptions

        Optional configuration options.

      Returns Texture

      A new Texture instance.

    • Creates a texture from an existing image or bitmap.

      Parameters

      • image: ImageBitmap | HTMLImageElement

        The image or bitmap data.

      • Optionaloptions: TextureOptions

        Optional configuration options.

      Returns Texture

      A new Texture instance.

    • Creates a TextureArray from an array of existing images or bitmaps.

      Parameters

      • images: (ImageBitmap | HTMLImageElement)[]

        Array of image or bitmap data.

      • Optionaloptions: TextureOptions

        Optional configuration options.

      Returns TextureArray

    • Loads a texture from a URL.

      Parameters

      • url: string

        The URL of the image.

      • Optionaloptions: TextureOptions

        Optional configuration options.

      Returns Promise<Texture>

      A promise that resolves to a new Texture instance.

    • Loads a TextureArray from an array of URLs.

      Parameters

      • urls: string[]

        Array of image URLs.

      • Optionaloptions: TextureOptions

        Optional configuration options.

      Returns Promise<TextureArray>