From e415d19503d51590d29e8e2ff6849934cf68c798 Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Thu, 27 Jul 2023 20:40:33 -0400 Subject: [PATCH] Core: WebGLRenderTarget extends RenderTarget --- types/three/src/Three.d.ts | 1 + types/three/src/core/RenderTarget.d.ts | 78 +++++++++++++++++++ .../src/renderers/WebGLRenderTarget.d.ts | 76 +----------------- 3 files changed, 82 insertions(+), 73 deletions(-) create mode 100644 types/three/src/core/RenderTarget.d.ts diff --git a/types/three/src/Three.d.ts b/types/three/src/Three.d.ts index 00d82c05f..588c1968d 100644 --- a/types/three/src/Three.d.ts +++ b/types/three/src/Three.d.ts @@ -41,6 +41,7 @@ export * from './cameras/Camera.js'; /** * Core */ +export * from './core/RenderTarget.js'; export * from './core/Uniform.js'; export * from './core/UniformsGroup.js'; export * from './core/InstancedBufferGeometry.js'; diff --git a/types/three/src/core/RenderTarget.d.ts b/types/three/src/core/RenderTarget.d.ts new file mode 100644 index 000000000..fa960ad92 --- /dev/null +++ b/types/three/src/core/RenderTarget.d.ts @@ -0,0 +1,78 @@ +import { Vector4 } from '../math/Vector4.js'; +import { Texture } from '../textures/Texture.js'; +import { DepthTexture } from '../textures/DepthTexture.js'; +import { EventDispatcher } from './EventDispatcher.js'; +import { + Wrapping, + TextureDataType, + TextureEncoding, + MinificationTextureFilter, + MagnificationTextureFilter, + ColorSpace, +} from '../constants.js'; + +export interface RenderTargetOptions { + wrapS?: Wrapping | undefined; + wrapT?: Wrapping | undefined; + magFilter?: MagnificationTextureFilter | undefined; + minFilter?: MinificationTextureFilter | undefined; + generateMipmaps?: boolean | undefined; // true; + format?: number | undefined; // RGBAFormat; + type?: TextureDataType | undefined; // UnsignedByteType; + anisotropy?: number | undefined; // 1; + colorSpace?: ColorSpace | undefined; + depthBuffer?: boolean | undefined; // true; + stencilBuffer?: boolean | undefined; // false; + depthTexture?: DepthTexture | undefined; + /** + * Defines the count of MSAA samples. Can only be used with WebGL 2. Default is **0**. + * @default 0 + */ + samples?: number; + /** @deprecated Use 'colorSpace' in three.js r152+. */ + encoding?: TextureEncoding | undefined; +} + +export class RenderTarget extends EventDispatcher { + constructor(width?: number, height?: number, options?: RenderTargetOptions); + + readonly isRenderTarget: true; + + width: number; + height: number; + depth: number; + + scissor: Vector4; + /** + * @default false + */ + scissorTest: boolean; + viewport: Vector4; + texture: TTexture; + + /** + * @default true + */ + depthBuffer: boolean; + + /** + * @default true + */ + stencilBuffer: boolean; + + /** + * @default null + */ + depthTexture: DepthTexture; + + /** + * Defines the count of MSAA samples. Can only be used with WebGL 2. Default is **0**. + * @default 0 + */ + samples: number; + + setSize(width: number, height: number, depth?: number): void; + clone(): this; + copy(source: RenderTarget): this; + dispose(): void; +} diff --git a/types/three/src/renderers/WebGLRenderTarget.d.ts b/types/three/src/renderers/WebGLRenderTarget.d.ts index a922e3aeb..b45490859 100644 --- a/types/three/src/renderers/WebGLRenderTarget.d.ts +++ b/types/three/src/renderers/WebGLRenderTarget.d.ts @@ -1,78 +1,8 @@ -import { Vector4 } from '../math/Vector4.js'; import { Texture } from '../textures/Texture.js'; -import { DepthTexture } from '../textures/DepthTexture.js'; -import { EventDispatcher } from '../core/EventDispatcher.js'; -import { - Wrapping, - TextureDataType, - TextureEncoding, - MinificationTextureFilter, - MagnificationTextureFilter, - ColorSpace, -} from '../constants.js'; +import { RenderTarget, RenderTargetOptions } from '../core/RenderTarget.js'; -export interface WebGLRenderTargetOptions { - wrapS?: Wrapping | undefined; - wrapT?: Wrapping | undefined; - magFilter?: MagnificationTextureFilter | undefined; - minFilter?: MinificationTextureFilter | undefined; - generateMipmaps?: boolean | undefined; // true; - format?: number | undefined; // RGBAFormat; - type?: TextureDataType | undefined; // UnsignedByteType; - anisotropy?: number | undefined; // 1; - colorSpace?: ColorSpace | undefined; - depthBuffer?: boolean | undefined; // true; - stencilBuffer?: boolean | undefined; // false; - depthTexture?: DepthTexture | undefined; - /** - * Defines the count of MSAA samples. Can only be used with WebGL 2. Default is **0**. - * @default 0 - */ - samples?: number; - /** @deprecated Use 'colorSpace' in three.js r152+. */ - encoding?: TextureEncoding | undefined; -} - -export class WebGLRenderTarget extends EventDispatcher { - constructor(width?: number, height?: number, options?: WebGLRenderTargetOptions); +export class WebGLRenderTarget extends RenderTarget { + constructor(width?: number, height?: number, options?: RenderTargetOptions); readonly isWebGLRenderTarget: true; - - width: number; - height: number; - depth: number; - - scissor: Vector4; - /** - * @default false - */ - scissorTest: boolean; - viewport: Vector4; - texture: TTexture; - - /** - * @default true - */ - depthBuffer: boolean; - - /** - * @default true - */ - stencilBuffer: boolean; - - /** - * @default null - */ - depthTexture: DepthTexture; - - /** - * Defines the count of MSAA samples. Can only be used with WebGL 2. Default is **0**. - * @default 0 - */ - samples: number; - - setSize(width: number, height: number, depth?: number): void; - clone(): this; - copy(source: WebGLRenderTarget): this; - dispose(): void; }