Options
All
  • Public
  • Public/Protected
  • All
Menu

A class or interface that provide support for WebGL async read pixel/texture data extraction.

Hierarchy

  • TextureExtractor

Index

Constructors

  • new TextureExtractor(renderer: any, __namedParameters?: { callerName: any; controlHash: any; format: any }): TextureExtractor
  • Parameters

    • renderer: any
    • __namedParameters: { callerName: any; controlHash: any; format: any } = {}
      • callerName: any
      • controlHash: any
      • format: any

    Returns TextureExtractor

Properties

debug: boolean

Debug flag.

pixelBuffer: Uint8ClampedArray

The reference to the pixel buffer.

#renderer: Renderer

The WebGL2 renderer.

#glSync: WebGLSync

The reference to a WebGL2 sync object.

#format: FORMATS

The texture format on which the Texture Extractor must work.

#type: TYPES

The texture type on which the Texture Extractor must work.

#readFormat: FORMATS

The texture format on which the Texture Extractor should read.

#gpuBuffer: WebGLBuffer

The reference to the GPU buffer.

#createBuffer: boolean

To know if we need to create a GPU buffer.

#callerName: string

The caller name associated with this instance of texture extractor (optional, used for debug)

#generatedRenderTexture: RenderTexture

Generated RenderTexture for textures.

#compressor: TextureCompressor

The compressor worker wrapper

#queue: Semaphore = ...

Handling of the concurrency for the extraction (by default a queue of 1)

COMPRESSION_MODES: { NONE: number; BASE64: number } = ...

List of compression that could be applied with extraction

Type declaration

  • NONE: number
  • BASE64: number

Methods

  • Extract a rectangular block of pixels from the texture (without un-pre-multiplying).

    Parameters

    Returns Promise<any>

  • reset(): void
  • Free all the bound objects.

    Returns void

  • contextChange(): void
  • Called by the renderer contextChange runner.

    Returns void

  • Extract a rectangular block of pixels from the texture (without un-pre-multiplying).

    Parameters

    Returns Promise<any>

  • #compressBuffer(...args: any): Promise<string>
  • Compress the buffer and returns a base64 image.

    Parameters

    • Rest ...args: any

    Returns Promise<string>

  • #compressBufferWorker(buffer: Uint8ClampedArray, width: number, height: number, options?: { type: string; quality: number }): Promise<string>
  • Compress the buffer into a worker and returns a base64 image

    Parameters

    • buffer: Uint8ClampedArray

      Buffer to convert into a compressed base64 image.

    • width: number

      Width of the image.

    • height: number

      Height of the image.

    • options: { type: string; quality: number } = {}
      • type: string

        Format of the image.

      • quality: number

        Quality of the compression.

    Returns Promise<string>

  • #compressBufferLocal(buffer: Uint8ClampedArray, width: number, height: number, options?: { quality: number }): Promise<string>
  • Compress the buffer locally (but expand the buffer into a worker) and returns a base64 image. The image format is forced to jpeg.

    Parameters

    • buffer: Uint8ClampedArray

      Buffer to convert into a compressed base64 image.

    • width: number

      Width of the image.

    • height: number

      Height of the image.

    • options: { quality: number } = {}
      • quality: number

        Quality of the compression.

    Returns Promise<string>

  • #readPixels(frame: Rectangle, resolution: number): any
  • Prepare data for the asynchronous readPixel.

    Parameters

    Returns any

  • #getGPUBufferData(buffer: Uint8ClampedArray, width: number, height: number, bufSize: number): any
  • Retrieve the content of the GPU buffer and put it pixels. Returns an object with the pixel buffer and dimensions.

    Parameters

    • buffer: Uint8ClampedArray

      The pixel buffer.

    • width: number

      The width of the texture.

    • height: number

      The height of the texture.

    • bufSize: number

      The size of the buffer.

    Returns any

  • #getPixelCache(length: number): Uint8ClampedArray
  • Retrieve a pixel buffer of the given length. A cache is provided for the last length passed only (to avoid too much memory consumption)

    Parameters

    • length: number

      Length of the required buffer.

    Returns Uint8ClampedArray

    The cached or newly created buffer.

  • #wait(): Promise<any>
  • Wait for the synchronization object to resolve.

    Returns Promise<any>

  • #clear(options?: { buffer: boolean; syncObject: boolean; rt: boolean }): void
  • Clear some key properties.

    Parameters

    • options: { buffer: boolean; syncObject: boolean; rt: boolean } = {}
      • buffer: boolean
      • syncObject: boolean
      • rt: boolean

    Returns void

  • #consoleDebug(message: string): void
  • Convenience method to display the debug messages with the extractor.

    Parameters

    • message: string

      The debug message to display.

    Returns void

  • #consoleError(message: string): void
  • Convenience method to display the error messages with the extractor.

    Parameters

    • message: string

      The error message to display.

    Returns void

Accessors

  • get #readBufferMul(): number
  • Returns the read buffer width/height multiplier.

    Returns number