import { ByteType, ColorSpace, DataTexture, FloatType, HalfFloatType, IntType, Material, RenderTarget, ShortType, TextureDataType, UnsignedByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedInt101111Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, WebGPURenderer } from 'three/webgpu'; import { QuadRendererTextureOptions } from '../../../core/types'; /** * Utility Type that translates `three` texture types to their TypedArray counterparts. * * @category Utility * @group Utility */ export type TextureDataTypeToBufferType = TType extends typeof UnsignedByteType ? Uint8ClampedArray : TType extends typeof ByteType ? Int8Array : TType extends typeof ShortType ? Int16Array : TType extends typeof UnsignedShortType ? Uint16Array : TType extends typeof IntType ? Int32Array : TType extends typeof UnsignedIntType ? Uint32Array : TType extends typeof FloatType ? Float32Array : TType extends typeof HalfFloatType ? Uint16Array : TType extends typeof UnsignedShort4444Type ? Uint16Array : TType extends typeof UnsignedShort5551Type ? Uint16Array : TType extends typeof UnsignedInt248Type ? Uint32Array : TType extends typeof UnsignedInt5999Type ? Uint32Array : TType extends typeof UnsignedInt101111Type ? Uint32Array : never; export type QuadRendererOptions = { /** * Width of the render target */ width: number; /** * height of the renderTarget */ height: number; /** * TextureDataType of the renderTarget */ type: TType; /** * ColorSpace of the renderTarget */ colorSpace: ColorSpace; /** * material to use for rendering */ material: TMaterial; /** * Renderer instance to use */ renderer?: WebGPURenderer; /** * Additional renderTarget options */ renderTargetOptions?: QuadRendererTextureOptions; }; /** * Utility class used for rendering a texture with a material (WebGPU version) * * @deprecated Will be removed in v4.0.0. The WebGPU decode now happens in {@link GainMapNode}, use {@link HDRJPGNodeLoader}, {@link GainMapNodeLoader} or {@link gainMapNode}, see the [migration guide](https://github.com/MONOGRID/gainmap-js#migrating-to-v400). * @category Core * @group Core */ export declare class QuadRenderer { private _renderer; private _rendererIsDisposable; private _material; private _scene; private _camera; private _quad; private _renderTarget; private _width; private _height; private _type; private _colorSpace; private _supportsReadPixels; /** * Constructs a new QuadRenderer * * @param options Parameters for this QuadRenderer */ constructor(options: QuadRendererOptions); /** * Instantiates a temporary renderer * * @returns */ static instantiateRenderer(): WebGPURenderer; /** * Renders the input texture using the specified material */ render: () => Promise; /** * Obtains a Buffer containing the rendered texture. * * @throws Error if the browser cannot read pixels from this RenderTarget type. * @returns a TypedArray containing RGBA values from this renderer */ toArray(): Promise>; /** * Performs a readPixel operation in the renderTarget * and returns a DataTexture containing the read data * * @param options options * @returns */ toDataTexture(options?: QuadRendererTextureOptions): Promise; /** * If using a disposable renderer, it will dispose it. */ disposeOnDemandRenderer(): void; /** * Will dispose of **all** assets used by this renderer. * * * @param disposeRenderTarget will dispose of the renderTarget which will not be usable later * set this to true if you passed the `renderTarget.texture` to a `PMREMGenerator` * or are otherwise done with it. * * @example * ```js * const loader = new HDRJPGLoader(renderer) * const result = await loader.loadAsync('gainmap.jpeg') * const mesh = new Mesh(geometry, new MeshBasicMaterial({ map: result.renderTarget.texture }) ) * // DO NOT dispose the renderTarget here, * // it is used directly in the material * result.dispose() * ``` * * @example * ```js * const loader = new HDRJPGLoader(renderer) * const pmremGenerator = new PMREMGenerator( renderer ); * const result = await loader.loadAsync('gainmap.jpeg') * const envMap = pmremGenerator.fromEquirectangular(result.renderTarget.texture) * const mesh = new Mesh(geometry, new MeshStandardMaterial({ envMap }) ) * // renderTarget can be disposed here * // because it was used to generate a PMREM texture * result.dispose(true) * ``` */ dispose(disposeRenderTarget?: boolean): void; /** * Width of the texture */ get width(): number; set width(value: number); /** * Height of the texture */ get height(): number; set height(value: number); /** * The renderer used */ get renderer(): WebGPURenderer; /** * The `RenderTarget` used. */ get renderTarget(): RenderTarget; set renderTarget(value: RenderTarget); /** * The `Material` used. */ get material(): TMaterial; /** * */ get type(): TType; get colorSpace(): ColorSpace; }