Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/threejs_4_deno/src/renderers/WebGLRenderer.d.ts>WebGLRenderer

A simple transformation of three.js for use within a Deno workflow
Go to Latest
class WebGLRenderer
implements Renderer
import { WebGLRenderer } from "https://deno.land/x/threejs_4_deno@v121/src/renderers/WebGLRenderer.d.ts";

The WebGL renderer displays your beautifully crafted scenes using WebGL, if your device supports it. This renderer has way better performance than CanvasRenderer.

Constructors

new
WebGLRenderer(parameters?: WebGLRendererParameters)

parameters is an optional object with properties defining the renderer's behaviour. The constructor also accepts no parameters at all. In all cases, it will assume sane defaults when parameters are missing.

Properties

autoClear: boolean

Defines whether the renderer should automatically clear its output before rendering.

autoClearColor: boolean

If autoClear is true, defines whether the renderer should clear the color buffer. Default is true.

autoClearDepth: boolean

If autoClear is true, defines whether the renderer should clear the depth buffer. Default is true.

autoClearStencil: boolean

If autoClear is true, defines whether the renderer should clear the stencil buffer. Default is true.

capabilities: WebGLCapabilities
clippingPlanes: any[]
context: WebGLRenderingContext

The HTML5 Canvas's 'webgl' context obtained from the canvas where the renderer will draw.

debug: WebGLDebug

Debug configurations.

domElement: HTMLCanvasElement

A Canvas where the renderer draws its output. This is automatically created by the renderer in the constructor (if not provided already); you just need to add it to your page.

extensions: WebGLExtensions
deprecated
gammaFactor: number
info: WebGLInfo
localClippingEnabled: boolean
maxMorphNormals: number
maxMorphTargets: number
outputEncoding: TextureEncoding

Default is LinearEncoding.

physicallyCorrectLights: boolean
pixelRatio: number
properties: WebGLProperties
renderLists: WebGLRenderLists
shadowMap: WebGLShadowMap
deprecated
shadowMapCullFace: CullFace
shadowMapDebug: boolean
deprecated
shadowMapEnabled: boolean
deprecated
shadowMapType: ShadowMapType
sortObjects: boolean

Defines whether the renderer should sort objects. Default is true.

state: WebGLState
toneMapping: ToneMapping
toneMappingExposure: number
deprecated
vr: boolean

Methods

deprecated
animate(callback: Function): void
clear(
color?: boolean,
depth?: boolean,
stencil?: boolean,
): void

Tells the renderer to clear its color, depth or stencil drawing buffer(s). Arguments default to true

clearColor(): void
clearDepth(): void
clearStencil(): void
clearTarget(
renderTarget: WebGLRenderTarget,
color: boolean,
depth: boolean,
stencil: boolean,
): void
compile(scene: Object3D, camera: Camera): void

Compiles all materials in the scene with the camera. This is useful to precompile shaders before the first rendering.

copyFramebufferToTexture(
position: Vector2,
texture: Texture,
level?: number,
): void

Copies a region of the currently bound framebuffer into the selected mipmap level of the selected texture. This region is defined by the size of the destination texture's mip level, offset by the input position.

copyTextureToTexture(
position: Vector2,
srcTexture: Texture,
dstTexture: Texture,
level?: number,
): void

Copies srcTexture to the specified level of dstTexture, offset by the input position.

dispose(): void
deprecated
enableScissorTest(boolean: any): any

Returns the current active cube face.

Returns the current active mipmap level.

getClearAlpha(): number

Returns a float with the current clear alpha. Ranges from 0 to 1.

Returns a THREE.Color instance with the current clear color.

getContext(): WebGLRenderingContext

Return the WebGL context.

deprecated
getMaxAnisotropy(): number
getPixelRatio(): number
deprecated
getPrecision(): string

Returns the current render target. If no render target is set, null is returned.

Copies the scissor area into target.

getScissorTest(): boolean

Returns true if scissor test is enabled; returns false otherwise.

Copies the viewport into target.

initTexture(texture: Texture): void

Initializes the given texture. Can be used to preload a texture rather than waiting until first render (which can cause noticeable lags due to decode and GPU upload overhead).

readRenderTargetPixels(
renderTarget: RenderTarget,
x: number,
y: number,
width: number,
height: number,
buffer: any,
activeCubeFaceIndex?: number,
): void
render(scene: Object3D, camera: Camera): void

Render a scene or an object using a camera. The render is done to a previously specified WebGLRenderTarget#renderTarget | .renderTarget set by calling WebGLRenderer#setRenderTarget | .setRenderTarget or to the canvas as usual.

By default render buffers are cleared before rendering but you can prevent this by setting the property WebGLRenderer#autoClear | autoClear to false. If you want to prevent only certain buffers being cleared you can set either the WebGLRenderer#autoClearColor | autoClearColor, WebGLRenderer#autoClearStencil | autoClearStencil or WebGLRenderer#autoClearDepth | autoClearDepth properties to false. To forcibly clear one ore more buffers call WebGLRenderer#clear | .clear.

renderBufferDirect(
camera: Camera,
scene: Scene,
material: Material,
object: Object3D,
geometryGroup: any,
): void
deprecated
resetGLState(): void

A build in function that can be used instead of requestAnimationFrame. For WebXR projects this function must be used.

setClearAlpha(alpha: number): void
setClearColor(color: Color | string | number, alpha?: number): void

Sets the clear color, using color for the color and alpha for the opacity.

setDrawingBufferSize(
width: number,
height: number,
pixelRatio: number,
): void
setFramebuffer(value: WebGLFramebuffer): void

Sets the given WebGLFramebuffer. This method can only be used if no render target is set via WebGLRenderer#setRenderTarget | .setRenderTarget.

setOpaqueSort(method: Function): void

Sets the custom opaque sort function for the WebGLRenderLists. Pass null to use the default painterSortStable function.

setPixelRatio(value: number): void
setRenderTarget(
renderTarget: RenderTarget | null,
activeCubeFace?: number,
activeMipmapLevel?: number,
): void

Sets the active render target.

setScissor(
x: Vector4 | number,
y?: number,
width?: number,
height?: number,
): void

Sets the scissor area from (x, y) to (x + width, y + height).

setScissorTest(enable: boolean): void

Enable the scissor test. When this is enabled, only the pixels within the defined scissor area will be affected by further renderer actions.

setSize(
width: number,
height: number,
updateStyle?: boolean,
): void

Resizes the output canvas to (width, height), and also sets the viewport to fit that size, starting in (0, 0).

setTransparentSort(method: Function): void

Sets the custom transparent sort function for the WebGLRenderLists. Pass null to use the default reversePainterSortStable function.

setViewport(
x: Vector4 | number,
y?: number,
width?: number,
height?: number,
): void

Sets the viewport to render from (x, y) to (x + width, y + height). (x, y) is the lower-left corner of the region.

deprecated
supportsBlendMinMax(): any
deprecated
supportsFloatTextures(): any
deprecated
supportsHalfFloatTextures(): any
deprecated
supportsInstancedArrays(): any
deprecated
supportsVertexTextures(): any