Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Arguments to readPixelsCompactAsync.

    interface ReadPixelsOpts<K extends TexelKind = TexelKind> {
        target: RenderTarget;
        kind: K;
        faceIndex?: number;
        x?: number;
        y?: number;
        width?: number;
        height?: number;
        flipY?: boolean;
        out?: TexelArray<K>;
        flipOut?: TexelArray<K>;
    }

    Type Parameters

    Index
    target: RenderTarget

    Source render target. Typed as the base RenderTarget so a cube target from either backend (WebGLCubeRenderTarget, or three/webgpu's CubeRenderTarget, which is NOT a WebGLRenderTarget) is accepted; see faceIndex.

    kind: K

    Pixel-format discriminator. Determines the returned typed-array kind.

    faceIndex?: number

    Cube face to read when target is a cube render target (0..5 in three's px, nx, py, ny, pz, nz order). Threaded into WebGL's activeCubeFaceIndex argument and WebGPU's faceIndex argument — the two signatures put it in different slots (after the destination buffer vs after textureIndex). Ignored for a 2D target.

    x?: number

    X offset in pixels (top-down convention). Defaults to 0. Full-target reads (the common case) leave this at 0; sub-region readers (e.g. the picking 5×5 voter) supply canvas-space top-down coords and the primitive converts to the backend's framebuffer convention internally.

    y?: number

    Y offset in pixels (canonical top-down, row 0 = top of source). The primitive flips this to the bottom-up framebuffer convention internally when caps.framebufferYDown === false. Defaults to 0.

    width?: number

    Region width in pixels. Defaults to target.width.

    height?: number

    Region height in pixels. Defaults to target.height.

    flipY?: boolean

    Default false. The primitive's canonical return convention is rows in top-down order (row 0 = top of the source target). Pass true to receive bottom-up rows instead — used by callers whose downstream consumers expect scene-space row order (e.g. EXR export).

    out?: TexelArray<K>

    Optional pre-allocated destination buffer for the raw readback. Must be exactly width * height * 4 elements of the right typed-array kind for kind. When provided, no fresh allocation is made for the raw readback; ideal for hot paths (e.g. picking) that fire at mouse-event rates.

    flipOut?: TexelArray<K>

    Optional pre-allocated destination buffer for the row-flipped output (only consulted when flipY is the default false). Must be the same size and kind as out, and a different buffer than out (the row-flip interleaves reads/writes across rows and cannot operate in place). When provided, the row-flip writes into this buffer instead of allocating one. The returned pixels is this buffer (not the raw out).