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

    Class Texture

    Represents a 2D texture.

    Hierarchy (View Summary)

    Index
    • Protected constructor. Use static factory methods to create instances.

      Parameters

      • Optionalimage: ImageBitmap | HTMLImageElement | HTMLCanvasElement

        Optional initial image data.

      • options: TextureOptions = {}

        Optional configuration options.

      Returns Texture

    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.

    isLoaded: boolean = false

    Whether the texture is fully loaded and ready for use.

    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 an empty texture placeholder.

      Parameters

      • Optionaloptions: TextureOptions

        Optional configuration options.

      Returns Texture

      A new empty Texture instance.

    • 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.

    • 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.