UNPKG

@types/three

Version:
143 lines (142 loc) 5.55 kB
import { EventDispatcher } from "../../core/EventDispatcher.js"; import { Vector2 } from "../../math/Vector2.js"; import { Vector4 } from "../../math/Vector4.js"; import { DepthTexture } from "../../textures/DepthTexture.js"; import { FramebufferTexture } from "../../textures/FramebufferTexture.js"; export interface CanvasTargetEventMap { resize: {}; dispose: {}; } /** * CanvasTarget is a class that represents the final output destination of the renderer. * * @augments EventDispatcher */ declare class CanvasTarget extends EventDispatcher<CanvasTargetEventMap> { domElement: HTMLCanvasElement; _pixelRatio: number; _width: number; _height: number; _viewport: Vector4; _scissor: Vector4; _scissorTest: boolean; colorTexture: FramebufferTexture; depthTexture: DepthTexture; /** * Constructs a new CanvasTarget. * * @param {HTMLCanvasElement|OffscreenCanvas} domElement - The canvas element to render to. */ constructor(domElement: HTMLCanvasElement); /** * Returns the pixel ratio. * * @return {number} The pixel ratio. */ getPixelRatio(): number; /** * Returns the drawing buffer size in physical pixels. This method honors the pixel ratio. * * @param {Vector2} target - The method writes the result in this target object. * @return {Vector2} The drawing buffer size. */ getDrawingBufferSize(target: Vector2): Vector2; /** * Returns the renderer's size in logical pixels. This method does not honor the pixel ratio. * * @param {Vector2} target - The method writes the result in this target object. * @return {Vector2} The renderer's size in logical pixels. */ getSize(target: Vector2): Vector2; /** * Sets the given pixel ratio and resizes the canvas if necessary. * * @param {number} [value=1] - The pixel ratio. */ setPixelRatio(value?: number): void; /** * This method allows to define the drawing buffer size by specifying * width, height and pixel ratio all at once. The size of the drawing * buffer is computed with this formula: * ```js * size.x = width * pixelRatio; * size.y = height * pixelRatio; * ``` * * @param {number} width - The width in logical pixels. * @param {number} height - The height in logical pixels. * @param {number} pixelRatio - The pixel ratio. */ setDrawingBufferSize(width: number, height: number, pixelRatio: number): void; /** * Sets the size of the renderer. * * @param {number} width - The width in logical pixels. * @param {number} height - The height in logical pixels. * @param {boolean} [updateStyle=true] - Whether to update the `style` attribute of the canvas or not. */ setSize(width: number, height: number, updateStyle?: boolean): void; /** * Returns the scissor rectangle. * * @param {Vector4} target - The method writes the result in this target object. * @return {Vector4} The scissor rectangle. */ getScissor(target: Vector4): Vector4; /** * Defines the scissor rectangle. * * @param {number | Vector4} x - The horizontal coordinate for the lower left corner of the box in logical pixel unit. * Instead of passing four arguments, the method also works with a single four-dimensional vector. * @param {number} y - The vertical coordinate for the lower left corner of the box in logical pixel unit. * @param {number} width - The width of the scissor box in logical pixel unit. * @param {number} height - The height of the scissor box in logical pixel unit. */ setScissor(x: Vector4): void; setScissor(x: number, y: number, width: number, height: number): void; /** * Returns the scissor test value. * * @return {boolean} Whether the scissor test should be enabled or not. */ getScissorTest(): boolean; /** * Defines the scissor test. * * @param {boolean} boolean - Whether the scissor test should be enabled or not. */ setScissorTest(boolean: boolean): void; /** * Returns the viewport definition. * * @param {Vector4} target - The method writes the result in this target object. * @return {Vector4} The viewport definition. */ getViewport(target: Vector4): Vector4; /** * Defines the viewport. * * @param {number | Vector4} x - The horizontal coordinate for the lower left corner of the viewport origin in logical pixel unit. * @param {number} y - The vertical coordinate for the lower left corner of the viewport origin in logical pixel unit. * @param {number} width - The width of the viewport in logical pixel unit. * @param {number} height - The height of the viewport in logical pixel unit. * @param {number} minDepth - The minimum depth value of the viewport. WebGPU only. * @param {number} maxDepth - The maximum depth value of the viewport. WebGPU only. */ setViewport(x: Vector4): void; setViewport(x: number, y: number, width: number, height: number, minDepth?: number, maxDepth?: number): void; /** * Dispatches the resize event. * * @private */ _dispatchResize(): void; /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever this instance is no longer used in your app. * * @fires RenderTarget#dispose */ dispose(): void; } export default CanvasTarget;