Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...
    • Drop WebGPU's per-row buffer padding from a readback typed array.

      WebGPU's copyTextureToBuffer (used internally by WebGPURenderer.readRenderTargetPixelsAsync) requires bytesPerRow to be a multiple of 256 (WebGPU spec § "Texture & buffer copy alignment"). Three.js sizes the returned typed array to match the padded GPU layout, so when width * bytesPerTexel isn't already a multiple of 256 the array contains junk bytes at the end of every row.

      This helper returns a row-compacted view sized exactly width * height * bytesPerTexel. When the input already matches the compact size (no padding required), the input is returned unchanged to avoid an allocation. Both WebGL2-returned arrays (always compact) and WebGPU-returned arrays for aligned widths hit the no-op path.

      Same math as the PickingSystem.readbackAndVote deinterlace loop; extracted so the post-processing capture/screenshot paths can share it (previously they assumed compact rows under WebGPU and produced corrupted output for canvas widths whose row stride wasn't a multiple of 256 bytes).

      Type Parameters

      • T extends
            | Uint8Array<ArrayBufferLike>
            | Float32Array<ArrayBufferLike>
            | Uint16Array<ArrayBufferLike>

      Parameters

      • raw: T

        The typed array returned by WebGPURenderer.readRenderTargetPixelsAsync.

      • width: number

        Image width in pixels.

      • height: number

        Image height in pixels.

      • bytesPerTexel: number

        4 for RGBA8/Uint8, 8 for RGBA16F/Uint16, 16 for RGBA32F/Float32.

      Returns T

      Either raw itself (when no compaction is needed) or a new typed array of the same concrete type sized for the compact layout.