rhodonite
    Preparing search index...

    Class RenderTargetTexture

    A texture that can be used as a render target for off-screen rendering. This class extends AbstractTexture and implements IRenderable to provide functionality for rendering to texture, which is commonly used for post-processing effects, shadow mapping, and other advanced rendering techniques.

    Hierarchy (View Summary)

    Implements

    Index
    __canvasContext?: CanvasRenderingContext2D
    __engine: Engine
    __format: EnumIO = PixelFormat.RGBA
    __hasTransparentPixels: boolean = false
    __height: number = 0
    __htmlCanvasElement?: HTMLCanvasElement
    __htmlImageElement?: HTMLImageElement
    __img?: HTMLImageElement
    __internalFormat: TextureFormatEnum = TextureFormat.RGBA8
    __isDummyTexture: boolean = false
    __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

    currentMaxObjectCount: number = 0

    Current maximum object count for UID generation

    InvalidObjectUID: -1

    Invalid object UID constant

    • set _fbo(fbo: FrameBuffer): void

      Sets the framebuffer object associated with this render target texture.

      Parameters

      • fbo: FrameBuffer

        The FrameBuffer object to associate with this texture

      Returns void

    • get fbo(): FrameBuffer | undefined

      Gets the framebuffer object associated with this render target texture.

      Returns FrameBuffer | undefined

      The associated FrameBuffer object, or undefined if not set

    • get height(): number

      Gets the height of the texture in pixels.

      Returns number

      The texture height

    • set height(val: number): void

      Sets the height of the texture in pixels.

      Parameters

      • val: number

        The new height value

      Returns void

    • 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(): HTMLImageElement | undefined

      Gets the HTML image element associated with this texture.

      Returns HTMLImageElement | undefined

      The HTML image element or undefined if not available

    • get isDummyTexture(): boolean

      Checks whether this texture is marked as a dummy (placeholder) texture.

      Returns boolean

      True if the texture is marked as dummy, false otherwise

    • 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 name(): string

      Gets the name of the texture.

      Returns string

      The texture name

    • set name(name: string): void

      Sets the name of the texture.

      Parameters

      • name: string

        The new texture name

      Returns void

    • 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 textureUID(): number

      Gets the unique identifier for this texture.

      Returns number

      The unique texture UID

    • get uniqueName(): string

      Gets the unique name of this object

      Returns string

      The unique name string

    • get uri(): string | undefined

      Gets the URI/URL of the texture source.

      Returns string | undefined

      The texture URI or undefined if not set

    • get width(): number

      Gets the width of the texture in pixels.

      Returns number

      The texture width

    • set width(val: number): void

      Sets the width of the texture in pixels.

      Parameters

      • val: number

        The new width value

      Returns void

    • Internal

      Copies tag data from another RnObject instance to this object

      Parameters

      • rnObject: RnObject

        The source RnObject to copy tags from

      Returns void

    • Creates and initializes the render target texture with the specified parameters.

      Parameters

      • params: {
            format: TextureFormatEnum;
            height: number;
            mipLevelCount?: number;
            width: number;
        }

        Configuration object for the render target texture

        • format: TextureFormatEnum

          Internal format of the texture

        • height: number

          Height of the texture in pixels

        • OptionalmipLevelCount?: number

          Number of mip levels to generate (optional, defaults to full mip chain)

        • width: number

          Width of the texture in pixels

      Returns void

    • Creates an HTMLCanvasElement containing the texture data read from GPU. This is useful for displaying texture previews when htmlImageElement is not available. Works with both WebGL and WebGPU backends.

      Returns Promise<HTMLCanvasElement | undefined>

      Promise resolving to an HTMLCanvasElement with the texture content, or undefined if the texture is not ready or reading fails

    • Creates a cube texture view as a render target for the specified face and mip level. This method is currently not implemented and serves as a placeholder for future functionality.

      Parameters

      • _faceIdx: number
      • _mipLevel: number

      Returns void

    • Creates an internal canvas context for pixel manipulation operations. Uses existing canvas element if available, otherwise creates a new one.

      Returns void

    • Destroys all 3D API resources associated with this render target texture. This method should be called when the texture is no longer needed to free GPU memory.

      Returns boolean

      True if the resources were successfully destroyed

    • 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 render target texture. Mipmaps are pre-calculated, optimized sequences of images that accompany a main texture, intended to increase rendering speed and reduce aliasing artifacts.

      Returns void

    • Calculates the height of the texture at a specific mip level.

      Parameters

      • mipLevel: number

        The mip level to calculate height for

      Returns number

      The height at the specified mip level (minimum 1 pixel)

    • 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 MutableVector3
            | typeof Vector3
            | typeof Vector4
            | 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 the specified coordinates. The coordinate system has its origin at the bottom-left corner.

      Parameters

      • x: number

        Horizontal pixel position (0 is left edge)

      • y: number

        Vertical pixel position (0 is bottom edge)

      • OptionalargByteArray: Uint8Array<ArrayBufferLike>

        Optional pre-fetched pixel data array to avoid redundant GPU reads

      Returns Promise<Vector4>

      A promise that resolves to a Vector4 containing the RGBA pixel values (0-255)

    • Retrieves a complete tag object (name and value) for the specified tag name

      Parameters

      • tagName: string

        The name of the tag to retrieve

      Returns Tag

      A Tag object containing the name and value

    • 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

    • Converts the texture data to a TextureDataFloat object with the specified number of channels. This is useful for processing texture data in floating-point format.

      Parameters

      • channels: number

        The number of channels to include in the output (1-4)

      Returns TextureDataFloat

      A TextureDataFloat object containing the converted pixel data

    • Retrieves the pixel data from the render target texture. This operation reads back the texture data from GPU memory to CPU memory.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      A promise that resolves to a Uint8Array containing the pixel data

    • Reads the texture data from GPU and returns it as a Uint8Array. This method works with both WebGL and WebGPU backends. Useful for textures that don't have an associated htmlImageElement (e.g., dummy textures).

      Returns Promise<Uint8Array<ArrayBufferLike> | undefined>

      Promise resolving to the pixel data as a Uint8Array in RGBA format, or undefined if the texture is not ready or reading fails

    • Calculates the width of the texture at a specific mip level.

      Parameters

      • mipLevel: number

        The mip level to calculate width for

      Returns number

      The width at the specified mip level (minimum 1 pixel)

    • 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

    • Marks this texture as a dummy (placeholder) texture.

      Parameters

      • isDummy: boolean = true

        Whether to mark the texture as dummy (default: true)

      Returns void

    • 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

    • Removes a tag from this object

      Parameters

      • tagName: string

        The name of the tag to remove

      Returns void

    • Resizes the render target texture to the specified dimensions. This operation destroys the existing resources and creates new ones.

      Parameters

      • width: number

        New width in pixels

      • height: number

        New height in pixels

      Returns void

    • 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

    • Unregisters this object from all tracking collections. Should be called when the object is being destroyed.

      Returns void

    • 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

    • Internal

      Resets all static object tracking data. Used primarily for testing.

      Returns void

    • Retrieves an RnObject instance by its unique identifier

      Parameters

      • objectUid: number

        The unique identifier of the object to retrieve

      Returns RnObject | undefined

      The RnObject instance or undefined if not found or garbage collected

    • Retrieves an RnObject instance by its unique name

      Parameters

      • uniqueName: string

        The unique name of the object to retrieve

      Returns RnObject | undefined

      The RnObject instance or undefined if not found or garbage collected

    • 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 WeakRef<RnObject> | undefined

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