Class RenderTargetTexture2DArray

A 2D texture array that can be used as a render target. This class extends AbstractTexture and implements IRenderable to provide functionality for creating and managing 2D texture arrays that can be rendered to in graphics pipelines.

Hierarchy (view full)

Implements

Constructors

Properties

__canvasContext?: CanvasRenderingContext2D
__format: EnumIO = PixelFormat.RGBA
__hasTransparentPixels: boolean = false
__height: number = 0
__htmlCanvasElement?: HTMLCanvasElement
__htmlImageElement?: HTMLImageElement
__img?: HTMLImageElement
__internalFormat: TextureFormatEnum = TextureFormat.RGBA8
__isTextureReady: boolean = false
__level: number = 0
__mipLevelCount: number = 1
__name: string = 'untitled'
__startedToLoad: boolean = false
__type: ComponentTypeEnum = ComponentType.UnsignedByte
__uri?: string
__width: number = 0
_recommendedTextureSampler?: Sampler
_samplerResourceUid: number = -1
_tags: RnTags = {}

Collection of tags associated with this object

_textureResourceUid: number = -1

The unique identifier for the underlying texture resource

_textureViewAsRenderTargetResourceUid: number = -1

The unique identifier for the texture view used as a render target

_textureViewResourceUid: number = -1

The unique identifier for the texture view resource

InvalidObjectUID: -1 = -1

Invalid object UID constant

currentMaxObjectCount: number = 0

Current maximum object count for UID generation

Accessors

  • get htmlCanvasElement(): HTMLCanvasElement
  • Gets or creates an HTML canvas element with the texture content. If an image element exists, it will be drawn onto the canvas.

    Returns HTMLCanvasElement

    The HTML canvas element containing the texture data

  • get htmlImageElement(): undefined | HTMLImageElement
  • Gets the HTML image element associated with this texture.

    Returns undefined | HTMLImageElement

    The HTML image element or undefined if not available

  • get isTextureReady(): boolean
  • Checks if the texture is ready for use.

    Returns boolean

    True if the texture is ready, false otherwise

  • get isTransparent(): boolean
  • Checks if the texture contains transparent pixels.

    Returns boolean

    True if the texture has transparency, false otherwise

  • get objectUID(): number
  • Gets the unique object identifier

    Returns number

    The object's UID

  • get startedToLoad(): boolean
  • Checks if the texture has started loading.

    Returns boolean

    True if loading has started, false otherwise

  • get uniqueName(): string
  • Gets the unique name of this object

    Returns string

    The unique name string

  • get uri(): undefined | string
  • Gets the URI/URL of the texture source.

    Returns undefined | string

    The texture URI or undefined if not set

Methods

  • Changes the render target layer for WebGPU rendering. This method creates a new texture view targeting a specific layer of the array.

    Parameters

    • layerIndex: number

      The index of the layer to target for rendering

    Returns void

  • Creates and initializes the 2D texture array with the specified parameters.

    Parameters

    • params: {
          arrayLength: number;
          format: EnumIO;
          height: number;
          internalFormat: TextureFormatEnum;
          level: number;
          type: ComponentTypeEnum;
          width: number;
      }

      Configuration object for texture creation

      • arrayLength: number

        Number of layers in the texture array

      • format: EnumIO

        Pixel format of the texture (default: RGBA)

      • height: number

        Height of the texture in pixels

      • internalFormat: TextureFormatEnum

        Internal format of the texture (default: RGB8)

      • level: number

        Mipmap level (default: 0)

      • type: ComponentTypeEnum

        Component type of the texture data (default: UnsignedByte)

      • width: number

        Width of the texture in pixels

    Returns void

  • Downloads the texture pixel data as a PNG image file. This method creates a canvas, draws the texture data to it, and triggers a download of the resulting image.

    Returns Promise<void>

  • Generates mipmaps for the texture. This creates lower resolution versions of the texture for improved rendering performance and quality when the texture is viewed at different distances.

    Returns void

  • Retrieves image data from a rectangular region of the texture. Creates an internal canvas context if one doesn't exist.

    Parameters

    • x: number

      The x-coordinate of the top-left corner

    • y: number

      The y-coordinate of the top-left corner

    • width: number

      The width of the region

    • height: number

      The height of the region

    Returns ImageData

    ImageData object containing the pixel data

  • Gets a single pixel value at the specified coordinates as a specific type. Supports various color and vector types for different use cases.

    Parameters

    • x: number

      The x-coordinate of the pixel

    • y: number

      The y-coordinate of the pixel

    • typeClass:
          | typeof Vector3
          | typeof Vector4
          | typeof MutableVector3
          | typeof MutableVector4
          | typeof ColorRgb
          | typeof ColorRgba

      The class type to return the pixel as (ColorRgb, ColorRgba, Vector3, etc.)

    Returns any

    An instance of the specified type containing the pixel data

  • Gets the pixel data at the specified coordinates as a raw Uint8ClampedArray. This provides direct access to the RGBA values as 8-bit integers.

    Parameters

    • x: number

      The x-coordinate of the pixel

    • y: number

      The y-coordinate of the pixel

    Returns Uint8ClampedArray

    A Uint8ClampedArray containing the RGBA pixel data

  • Gets the pixel value at a specific coordinate in the texture. The coordinate system has its origin at the bottom-left corner.

    Parameters

    • x: number

      Horizontal pixel position (0 is left)

    • y: number

      Vertical pixel position (0 is bottom)

    • OptionalargByteArray: Uint8Array

      Optional pre-fetched pixel data array. If not provided, data will be fetched from GPU

    Returns Promise<Vector4>

    Promise that resolves to a Vector4 containing the RGBA pixel values

  • Retrieves the value associated with a specific tag name

    Parameters

    • tagName: string

      The name of the tag whose value to retrieve

    Returns any

    The tag value, or undefined if the tag doesn't exist

  • Retrieves the pixel data from the texture as a byte array. This is an asynchronous operation that reads back data from the GPU.

    Returns Promise<Uint8Array>

    Promise that resolves to a Uint8Array containing the pixel data

  • Checks whether this object has a tag with the specified name

    Parameters

    • tagName: string

      The name of the tag to check for

    Returns boolean

    True if the tag exists (value is not null/undefined), false otherwise

  • Checks if this object has a tag with the specified name and value

    Parameters

    • tagName: string

      The tag name to match

    • tagValue: string

      The tag value to match

    Returns boolean

    True if the object has a matching tag, false otherwise

  • Checks if this object has all the specified tags with exactly matching values

    Parameters

    • tags: RnTags

      Object containing tag names as keys and expected values

    Returns boolean

    True if all specified tags exist with matching values, false otherwise

  • Checks if the object's combined tag string contains all the provided search strings. This allows for flexible searching within tag names and values.

    Parameters

    • stringArray: string[]

      Array of strings that must all be present in the combined tag string

    Returns boolean

    True if all strings are found in the combined tag string, false otherwise

  • Sets a specific channel value for a pixel at the given coordinates. Useful for modifying individual color channels (R, G, B, A).

    Parameters

    • x: number

      The x-coordinate of the pixel

    • y: number

      The y-coordinate of the pixel

    • channelIdx: number

      The channel index (0=R, 1=G, 2=B, 3=A)

    • value: number

      The new value for the channel (0-255)

    Returns void

  • Attempts to set a tag on this object. If the tag already exists, it will be replaced.

    Parameters

    • tag: Tag

      The tag object containing the name and value to set

    Returns boolean

    True if the tag was successfully set, false if the tag name contains invalid characters

  • Attempts to set a unique name for this object

    Parameters

    • name: string

      The desired unique name

    • toAddNameIfConflict: boolean

      If true, appends UID to make name unique when conflicts occur; if false, fails on conflict

    Returns boolean

    True if the name was successfully set, false if there was a conflict and toAddNameIfConflict was false

  • Validates that a tag string contains only allowed characters (alphanumeric and underscore)

    Parameters

    • val: string

      The string to validate

    Returns boolean

    True if the string contains only valid characters, false if it contains invalid characters

  • Searches for the first object that has a specific tag with the given value

    Parameters

    • tag: string

      The tag name to search for

    • value: string

      The tag value to match

    Returns undefined | WeakRef<RnObject>

    WeakRef to the first matching object, or undefined if not found