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

    Class RenderTarget

    A specialized texture that can be rendered to by a Renderer.

    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.

    depth: boolean

    Whether this render target includes a depth buffer.

    generateMipmaps: boolean = true

    Whether mipmaps should be generated for this texture.

    height: number

    The height of the render target in pixels.

    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.

    width: number

    The width of the render target in pixels.

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

    • Resizes the render target. Note: The underlying renderer will recreate the GPU resources on the next frame.

      Parameters

      • width: number

        The new width.

      • height: number

        The new height.

      Returns void

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